Skip to content

Getting started ​

1. Get an API key ​

Create a key in the dashboard (Developers → API keys) or with the API. Keys look like:

PrefixModeEffect
vi_live_…LiveReal calls and messages, billed to your balance.
vi_test_…Test modeSimulated calls and messages, no charges, same events and webhooks.

Keep keys on your server. Browsers get a short-lived stream token instead.

2. Install an SDK ​

bash
npm i @kolwire/sdk
bash
pip install kolwire

Both SDKs read KOLWIRE_API_KEY from the environment when you don't pass a key.

ts
import { Kolwire } from "@kolwire/sdk";

const vi = new Kolwire({ apiKey: process.env.KOLWIRE_API_KEY });
const page = await vi.numbers.list({ limit: 10 });
console.log(page.data);
python
from kolwire import Kolwire

client = Kolwire()  # reads KOLWIRE_API_KEY
for number in client.numbers.list(limit=10):
    print(number.phone_number)

3. Raw HTTP ​

Base URL: https://api.kolwire.com/v1. Authenticate with a bearer token:

bash
curl https://api.kolwire.com/v1/calls \
  -H "Authorization: Bearer $KOLWIRE_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{"from":"+15550001111","to":"+15550002222","agent_id":"agt_123"}'

Conventions ​

Errors ​

Non-2xx responses have one shape:

json
{ "error": { "code": "invalid_request", "message": "Validation failed", "details": [ … ] } }
Statuscode (typical)SDK error class
400invalid_requestBadRequestError
401unauthorizedAuthenticationError
402insufficient_fundsInsufficientFundsError
403forbiddenPermissionDeniedError
404not_foundNotFoundError
409conflict (incl. idempotency key reuse with a different body)ConflictError
422unprocessableUnprocessableEntityError
429rate_limitedRateLimitError
5xxinternalInternalServerError

Network failures raise APIConnectionError (APITimeoutError on timeouts). All API errors expose status, code, details and the request id.

ts
import { NotFoundError, APIError } from "@kolwire/sdk";

try {
  await vi.calls.get("call_missing");
} catch (err) {
  if (err instanceof NotFoundError) console.log("no such call");
  else if (err instanceof APIError) console.log(err.status, err.code, err.details, err.requestId);
  else throw err;
}
python
from kolwire import NotFoundError, APIError

try:
    client.calls.get("call_missing")
except NotFoundError:
    print("no such call")
except APIError as err:
    print(err.status, err.code, err.details)

Pagination ​

Lists take ?limit= (1–100, default 20) and ?starting_after=<cursor> and return:

json
{ "data": [ … ], "has_more": true, "next_cursor": "call_abc" }

The SDKs paginate for you:

ts
const first = await vi.calls.list({ limit: 50 });              // one page
for await (const call of vi.calls.list({ status: "completed" })) { /* every call */ }
const recent = await vi.calls.list().toArray(200);             // up to 200 items
python
for call in client.calls.list(status="completed"):   # every call
    ...
page = client.calls.list(limit=50).get_page()        # one page

Idempotency ​

Send an Idempotency-Key header on POST requests; retrying with the same key returns the original result instead of placing a second call or sending a second message. The SDKs generate a key for every POST/PATCH automatically and reuse it across their retries. Pass your own to make retries safe across process restarts:

ts
await vi.messages.create({ from, to, body: "Your code is 1234" }, { idempotencyKey: `otp-${userId}-${nonce}` });
python
client.messages.create(from_=sender, to=to, body="Your code is 1234",
                       request_options={"idempotency_key": f"otp-{user_id}-{nonce}"})

Retries and rate limits ​

The API allows 600 requests per minute per key and returns 429 with Retry-After when you exceed it. The SDKs retry 408, 429 and 5xx responses, timeouts and connection errors twice by default, with exponential backoff (honouring Retry-After). Configure with maxRetries / max_retries on the client or per request.

Next steps ​