Concepts
Organizations
Section titled “Organizations”Everything in AirFone belongs to an organization: numbers, assistants, contacts, calls. Keys act for one organization.
A developer account can exist without one. When you sign up you get a sandbox organization of your own. A business can invite you into its organization, and you can publish connectors that any organization installs.
Test and live mode
Section titled “Test and live mode”Every organization has test and live data, kept apart. Test keys contain _test_, live keys contain _live_.
In test mode:
- Calls are simulated. No phone rings, and a scripted caller talks to your assistant.
- WhatsApp and SMS go to a simulated inbox you can see in the console.
- AI usage comes from a free test quota.
- Webhooks fire exactly as in live mode, with
"livemode": false.
Your sandbox organization takes test keys only. Live keys are made in your business organization, with no request or approval: live use is paid from that organization’s credit. When the credit runs out, live calls are refused with 402 and a message saying how much to add.
| Key | Prefix | Where it lives | What it can do |
|---|---|---|---|
| Secret | af_sk_ | Your server only | Everything the organization allows |
| Restricted | af_rk_ | Your server, or a service you trust less | Only the scopes you pick |
| Publishable | af_pk_ | Web pages and apps | Open widget sessions on the domains you list |
Send a secret or restricted key as Authorization: Bearer af_sk_.... A secret key is shown once when created. If one leaks, roll it in the console: the old key keeps working for the grace period you pick (none, 1 hour or 24 hours), then stops.
Scopes
Section titled “Scopes”Restricted keys carry scopes in the form resource:read or resource:write. Write includes read.
calls, messages, agents, contacts, records, webhooks, events, usage, connectors.
A call without the scope it needs gets 403 with code missing_scope, and the error names the scope.
Idempotency
Section titled “Idempotency”Send Idempotency-Key on every POST. If a request times out, send it again with the same key and you get the first result instead of a second call or message. Keys are kept for 24 hours. Reusing a key with a different body returns 422 idempotency_key_reused; a key whose first request is still running returns 409 idempotency_in_progress.
Versions
Section titled “Versions”The API is versioned by date. Your account is pinned to the version current when you made your first request. Send AirFone-Version: 2026-10-04 to choose one per request. Breaking changes only ever arrive in a new version, and every response includes the version that served it.
Errors
Section titled “Errors”Every error has the same shape:
{ "error": { "type": "invalid_request_error", "code": "validation_failed", "message": "name is required.", "request_id": "req_8c1f" }}type groups errors by status: invalid_request_error, authentication_error, permission_error, not_found_error, conflict_error, rate_limit_error and api_error. Match on code, which is stable. Every code and what to do about it is in Errors.
Rate limits
Section titled “Rate limits”Each key may make 120 requests a minute unless AirFone has raised it for you. Past the limit a request gets 429 with a Retry-After header: wait that many seconds and try again. Publishable keys are also limited per visitor IP.
Request ids
Section titled “Request ids”Every response has an AirFone-Request-Id header, and every error repeats it as request_id. Look it up under Logs in the console, and include it when you contact support.