Documentation menu

API reference

Calls

Place outbound calls, hang up live ones, and list or fetch call records.

GET/calls/

List call records for your account, newest first.

Query parameters

NameTypeRequiredDefaultDescription
directionstringOptionalinbound, outbound, or internal (end-user ↔ end-user, on-net).
statusstringOptionalinitiated, ringing, answered, completed, or failed.
searchstringOptionalMatch against the from / to numbers.
from_dtstringOptionalISO-8601 lower bound on creation time.
to_dtstringOptionalISO-8601 upper bound.
limitintegerOptional501–200.
offsetintegerOptional0Rows to skip.

Returns { calls: array<Call>, total, limit, offset }.

POST/calls/originate

Place an outbound call. We dial to, present from as the caller ID, and on answer fetch call-control verbs from url.

Body

FieldTypeRequiredDefaultDescription
tostringRequiredDestination number in E.164, e.g. +254711111111.
fromstringRequiredA DID you own, presented as caller ID.
urlstringRequiredYour webhook that returns verbs for the answered call.
timeoutintegerOptional30Seconds to wait for an answer.
customPayloadobjectOptionalArbitrary JSON echoed back on the call's events and record.

Header Idempotency-Key: string (optional, recommended — see idempotency). Returns a Call object. Errors 402 insufficient balance, 429 traffic cap (see rate limits).

curl https://sauti-pbx.services.co.ke/api/calls/originate \
  -H "Authorization: Bearer sk_live_..." \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: order-4021" \
  -d '{ "to": "+254711111111", "from": "+254709080010",
       "url": "https://yourapp.com/handle-call" }'

// → 201 Created
{ "uuid": "6f1c8e2a-...", "sid": "call_9Xk2", "status": "initiated", … }
POST/calls/hangup

End a live call. Idempotent — hanging up an already-ended call returns its record unchanged. Also available as GET /calls/hangup/{sid} or GET /calls/hangup?sid=.

If the call has already ended on the switch but our record still shows it live, this brings the record up to date and returns it terminal with reasonCode END.0504 — so a call can always be cleared, never left stuck.

FieldTypeRequiredDescription
sidstringRequiredThe call's sid.

Returns a Call object.

GET/calls/{uuid}

Fetch a single call record by its uuid. Returns a Call object, or 404.

The Call object

FieldTypeDescription
uuidstringStable identifier.
sidstringHuman-friendly call id, e.g. call_9Xk2.
directionstringinbound, outbound, or internal (end-user ↔ end-user, on-net).
from_number / to_numberstringThe two ends of the call.
statusstringinitiated · ringing · answered · completed · failed.
reason_codestringTerminal outcome code, e.g. END.0200. See reason codes.
reason_labelstringReadable label for reason_code.
duration_secondsinteger, nullableTotal call length.
talk_secondsinteger, nullableConnected (billed) time.
coststringCharge in KES.
tts_secondsintegerSeconds of speech synthesised.
customPayloadobject, nullableWhat you attached at originate.
started_at / answered_at / ended_at / created_atstring, nullableISO-8601 timestamps (created_at always set).