Getting started
1. Get an API key
Create a key in the dashboard (Developers → API keys) or with the API. Keys look like:
| Prefix | Mode | Effect |
|---|---|---|
vi_live_… | Live | Real calls and messages, billed to your balance. |
vi_test_… | Test mode | Simulated 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
npm i @kolwire/sdkpip install kolwireBoth SDKs read KOLWIRE_API_KEY from the environment when you don't pass a key.
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);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:
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:
{ "error": { "code": "invalid_request", "message": "Validation failed", "details": [ … ] } }| Status | code (typical) | SDK error class |
|---|---|---|
| 400 | invalid_request | BadRequestError |
| 401 | unauthorized | AuthenticationError |
| 402 | insufficient_funds | InsufficientFundsError |
| 403 | forbidden | PermissionDeniedError |
| 404 | not_found | NotFoundError |
| 409 | conflict (incl. idempotency key reuse with a different body) | ConflictError |
| 422 | unprocessable | UnprocessableEntityError |
| 429 | rate_limited | RateLimitError |
| 5xx | internal | InternalServerError |
Network failures raise APIConnectionError (APITimeoutError on timeouts). All API errors expose status, code, details and the request id.
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;
}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:
{ "data": [ … ], "has_more": true, "next_cursor": "call_abc" }The SDKs paginate for you:
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 itemsfor call in client.calls.list(status="completed"): # every call
...
page = client.calls.list(limit=50).get_page() # one pageIdempotency
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:
await vi.messages.create({ from, to, body: "Your code is 1234" }, { idempotencyKey: `otp-${userId}-${nonce}` });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.