Calls API
Phone calls: placing them, following them, hanging up.
The same operations are in the interactive API reference, and the whole contract is in the OpenAPI document.
GET/v1/calls
List calls
Returns the organization's calls of every kind (assistant, direct, conference and phone-network), newest first. A key acts for the whole organization, so the list is organization-wide, not limited to one person's calls.
Needs calls:read. A test key sees the sandbox's calls only; test and live data never mix. Reading is free.
Filters combine. q matches words said on the call or part of the other party's number. missed=true keeps only calls nobody took. Each row is named from the contacts book when its number matches a contact, so contact_id and contact_name can be null for numbers you have never saved.
Paged, newest first: limit is 1 to 100 (default 50, out of range values are clamped) and cursor is the next_cursor of the previous page. The cursor is opaque and never built by the client; a cursor this API did not return is a 400. has_more is true while another page exists. There is no total.
Scope calls:read. Accepts: API key or personal access token. Open in the API reference
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
q | query | string | No | Words said on the call, or part of the number. Blank values are ignored. |
missed | query | boolean | No | When true, only calls nobody took. |
limit | query | integer | No | How many items to return. Default 50, at most 100. |
cursor | query | string | No | The `next_cursor` of the previous page. Opaque; never built by the client. |
AirFone-Version | header | string | No | The API version to use, as a date. Defaults to the version the account was pinned to. |
POST/v1/calls
Place a call
Queues an outbound call in which the assistant phones a number and talks about the agenda you give. The call is not dialled inside this request. The answer says it is queued, and the call appears in the call list once the dialler picks it up.
Needs calls:write.
Test and live. With a test key nothing is dialled, nothing is charged and the status is simulated; the attempt is kept so you can see what you tried, and livemode is false. With a live key the call is real.
Cost. A live call is paid from the organization's credit, using the same balance check as bulk calls. With no credit the request is refused with 402 insufficient_credit and nothing is queued.
Rules that still apply. Calling hours apply, so a call requested outside them waits for the next window. The agenda is screened, and a screened agenda is refused. A number marked do not contact is refused with 400. A number that is not yet a contact is added to the contacts book as one, before the call is queued.
Scheduling. call_at can be any time up to 60 days ahead. When absent the call is requested for now. A call_at further out is refused.
Idempotency. Send an Idempotency-Key. Repeating the request with the same key returns the first answer instead of queueing a second call to the same person. Without a key, a retry after a timeout can ring someone twice.
The 409 here means calling is not configured on the server, or the idempotency key was reused with a different body.
Scope calls:write. Accepts: API key or personal access token. Open in the API reference
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
Idempotency-Key | header | string | No | Makes a POST safe to repeat: the same key returns the first result for 24 hours. The same key with a different body is refused with `422 idempotency_key_reused`; while the first request still runs, `409 idempotency_in_progress`. |
AirFone-Version | header | string | No | The API version to use, as a date. Defaults to the version the account was pinned to. |
GET/v1/calls/{id}
Get a call
Returns one call: its kind, status, timing, the other party's number and, when the number matches a saved contact, who that is.
Needs calls:read. Reading is free. A call that belongs to another organization, or to the other mode (a live id with a test key), answers 404 as if it did not exist.
While a call is on, status is active, ended_at is null and duration_seconds is the time so far. Poll this, or subscribe to the call.ended event, to learn when it finishes.
Scope calls:read. Accepts: API key or personal access token. Open in the API reference
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | Yes | The resource id. |
AirFone-Version | header | string | No | The API version to use, as a date. Defaults to the version the account was pinned to. |
POST/v1/calls/{id}/hangup
Hang up a call
Ends a call in progress for everyone on it, including the assistant and any person who has joined. Phone-network legs are closed as well.
Needs calls:write. Hanging up is free, and the minutes used so far are billed as usual.
Safe to repeat. A call that is already over, or whose room has already gone, is closed without error and the answer is still 204, so there is no need for an Idempotency-Key. The only way to get 404 is a call id that is not this organization's.
Do not use this to cancel a call that is still queued: it has no live call to end yet.
Scope calls:write. Accepts: API key or personal access token. Open in the API reference
| Parameter | In | Type | Required | Description |
|---|---|---|---|---|
id | path | string | Yes | The resource id. |
AirFone-Version | header | string | No | The API version to use, as a date. Defaults to the version the account was pinned to. |