Skip to content

Overview

Serves the HTTP API of the Apifonica Voicebot: it manages scenarios, agents, numbers, contacts and segments, places calls and reads back what each one did, and administers an account’s users.

Authentication

Every authenticated request carries Authorization: Bearer <token>. The same header accepts several credential kinds, told apart server-side.

By credential:

  • Session token: issued to a user by POST /v1/a/auth/regular (email + password), by consuming a magic link, or by consuming a password reset; it is scoped to the user’s account, or to the tenant for a tenant-level user, and carries the user’s roles.
  • API key: issued to a user through POST /v1/a/user/{sid}/api-key or POST /v1/t/user/{sid}/api-key. It acts with that user’s roles at that user’s level: an account-level user’s key acts as the account, and a tenant-level user’s key acts across the tenant’s accounts. A key stops authenticating while its user is not active and works again once they are.

A permission is named <resource>:<action> or <resource>:<sub_resource>:<action>, and the action is read, write or manage. On one resource manage includes write, and write includes read. A user gets permissions from the roles it holds. GET /v1/a/profile lists the caller’s permissions, and GET /v1/a/role lists the roles an account-level user can hold.

The extensions:

  • x-athena-permission: names the permission the operation needs; none means the operation checks no permission.
  • x-athena-field-permissions: names the permission a field of the request body needs.
  • x-athena-include-permissions: names the permission a value of include needs.

Tenant provisioning is performed by administrators over the internal network and is documented in the internal API reference.

Operating on another scope

By principal:

  • A tenant-level principal, a tenant-level user’s session or API key, acts across the tenant’s accounts, so it picks its target with the X-Account-Sid header.
  • An account-scoped principal may omit the header.

The named account must belong to the principal’s tenant.

Refused when:

  • A tenant-level principal omits the header.
  • An account-scoped principal names an account that is not its own.
  • The named account belongs to another tenant: it is refused as outside the credential’s scope.
  • The named account does not exist: it is not found.

Request tracing

Every response carries the trace id of its request in the X-Trace-ID header, as 32 lowercase hexadecimal characters. A path that differs from a route only by a trailing slash is answered with a redirect to that route, and the redirect carries no X-Trace-ID header.

A request may name its own trace id in a header.

The headers:

  • traceparent: is the W3C header; a valid one takes precedence over X-Trace-ID.
  • X-Trace-ID: 32 hexadecimal characters or a UUID; the response returns it in lowercase and without dashes.

A request with no valid id in either header is served under a new id.

Compressed request bodies

A request body may be compressed. The Content-Encoding header names the compression: gzip or br.

Every limit of an endpoint applies to the decompressed body.

Refused when:

  • Content-Encoding names another compression.
  • The body cannot be decompressed as named.
  • The decompressed body is larger than 128 MiB.

Lists

Refused when:

  • A limit is above the list’s maximum.
  • An order_by, filter_or or include name is one that its parameter does not accept.

Errors

An error response carries an error field that names the case. A client branches on error; the text in message is for people.

Routes under /v1/a/adapters/ list their errors in their own responses, and this section does not cover them.

Common to every resource

These errors have the same status and meaning on every resource. An operation that cannot answer one, or answers it in its own way, says so in its responses.

Status error Meaning
401 unauthenticated Refuses a request that cannot be authenticated.
Returned when:
- The request carries no usable credential.
- The user, account or tenant behind the credential is not active.
403 permission_denied The credential is valid and in scope, but the caller’s roles do not grant the permission the operation needs.
404 not_found Refuses an identifier that names no resource the caller can use.
Returned when:
- No live resource with this identifier is visible to the caller.
- The resource the identifier names belongs to another account.
405 method_not_allowed The path exists and does not accept this method.
500 internal The server failed to answer; the request did not take effect and may be retried. Any operation can answer it, so no operation lists it.

All errors

Every error this API answers itself. An operation lists the ones it can answer in its responses.

Status error Meaning
400 bad_request Refuses a request whose form is wrong.
Returned when:
- The body, a path parameter or a query parameter does not parse.
- Content-Encoding names a compression the API does not accept, or the body cannot be decompressed as named.
- A brick to validate names a type or a version the API does not know.
- A data field path or a column name in the body is not well formed, or a key of a row’s data is empty or holds a dot.
- A node position in the constructor of a scenario save carries one of x and y without the other.
- The operation needs a WebSocket upgrade, and the request is not one.
message names what failed.
400 country_code_invalid Refuses the country_code of the request.
Returned when:
- country_code is not a known country.
- country_code is not accepted with the type given.
400 external_id_required The tenant declares this resource type in managed_resources, which makes external_id required, and the request carries none.
400 file_column_name_too_long A heading of the file normalises to a key longer than 64 characters, or a path of the data of a list of rows is longer.
400 file_columns_clash Refuses the columns of the file.
Returned when:
- Two headings of the file normalise to the same key.
- A heading of the file normalises to a key that another heading nests under, such as address beside address.city.
- A column rename names the column itself or a column a row of the source already holds.
message names the key.
400 file_empty The file holds no row after its headings, or the list of rows is empty.
400 file_encoding_unsupported Refuses the encoding of the csv file.
Returned when:
- The csv file is not UTF-8 text.
- The csv file holds a NUL character.
400 file_malformed The file does not read as the type its Content-Type declares.
400 file_no_usable_rows Refuses the upload: it reads, and every row of it is rejected.
The data:
- data.rows: counts the rows of the upload.
- data.reasons: counts the rows by reason.
400 file_number_column_missing No heading of the file normalises to number.
400 file_too_many_columns The file holds more than 30 named columns, or the data of a list of rows more than 29 paths, the number counted as the 30th.
400 file_too_many_rows The file or the list of rows holds more than 100 000 rows.
400 file_type_unsupported The Content-Type of the file part is neither csv nor xlsx; the file is not read.
400 identifier_type_invalid type names an unknown way of reading a number.
400 missing_scope_header The credential acts for a tenant or for the platform, and the request names no account in X-Account-Sid (or no tenant in X-Tenant-Sid).
400 query_invalid Refuses the query expression of a contact filter, or the condition of a routing, in the request.
Returned when:
- The expression cannot be read.
- A data.<path> or a contact.<path> names a field no contact of the account holds.
- A data.<path> or a contact.<path> names a field that holds fields of its own.
- A routing condition compares a field with a value or an operator the field does not take, or a contact.<path> with a value of a type the field cannot hold.
- The expression holds too many comparisons or characters.
message names what is wrong and where.
400 scope_conflict Refuses the value of the scope header.
Returned when:
- The scope header names an account or tenant the credential does not cover.
- The scope header carries a value that is not an id of that kind.
400, 422 validation_failed Refuses a body that does not pass validation.
Returned when:
- The body does not parse.
- The body lacks a required field.
- The body carries a value that is not accepted.
message names the field.
401 magic_invalid Refuses the sign-in token.
Returned when:
- The token is unknown, already spent or expired.
- The user of the token is no longer active.
401 password_invalid Refuses a sign-in with an address and a password.
Returned when:
- The address is unknown.
- The password is wrong.
- The user is inactive.
- The user has no password set.
401 unauthenticated Refuses a request that cannot be authenticated.
Returned when:
- The request carries no usable credential.
- The user, account or tenant behind the credential is not active.
403 access_denied Refuses the request because of a permission the caller does not hold.
Returned when:
- The request assigns, creates, edits or deletes a role that carries a permission the caller does not hold.
- The request writes to a user whose roles carry such a permission.
403 no_user_principal The credential has no person behind it, so a self endpoint cannot answer for it.
403 permission_denied The credential is valid and in scope, but the caller’s roles do not grant the permission the operation needs.
403 self_administration The target is the caller’s own user, which the user operations do not change or delete. PATCH /v1/a/profile on the account plane edits the caller’s own name and email.
403 tenant_managed Refuses a write that belongs to the tenant, made by a caller without the role tenant_admin.
Returned when:
- The tenant declares this resource type in managed_resources.
- The tenant administers this SMS provider.
404 agent_not_found No live agent with this id.
404 audio_not_found Refuses the audio file name in the request.
Returned when:
- No stored file with this name is in the caller’s account.
- The name is malformed.
404 automation_attempt_not_found No attempt of this automation with this id.
404 automation_contact_not_found The automation has not taken this contact.
404 automation_not_found No live automation with this id.
404 communication_not_found Refuses the communication id in the request.
Returned when:
- No communication has this id.
- The communication with this id was deleted.
404 communication_result_not_found No result delivery with this id.
404 contact_export_not_found Refuses the export job id in the request.
Returned when:
- No export job has this id.
- The job was removed 7 days after it finished.
404 contact_not_found No live contact with this id.
404 limit_policy_not_found No live limit policy with this id.
404 not_found Refuses an identifier that names no resource the caller can use.
Returned when:
- No live resource with this identifier is visible to the caller.
- The resource the identifier names belongs to another account.
404 number_not_found No live number of the account with this id or external identifier.
404 number_pool_not_found No live number pool of the account with this id or external identifier.
404 routing_not_found No live routing with this id on the agent.
404 scenario_not_found Refuses a scenario id the caller cannot see.
Returned when:
- No scenario with this id exists.
- The scenario belongs to an account outside the caller’s tenant.
- The scenario belongs to another account of the tenant and is not shared for copy.
404 scenario_version_not_found No version record of the scenario with this axis number and draft flag.
404 segment_not_found No live segment of the account with this id.
404 sms_provider_not_found No live SMS provider of the account with this id.
404 source_not_found No source with this id in the segment addressed.
404 source_row_not_found No row with this id in the source addressed.
405 method_not_allowed The path exists and does not accept this method.
409 agent_active_calls A call of the agent is being dialled or is in progress.
409 agent_concurrent_update Another write to the same agent landed first; read the agent again and retry.
409 automation_requires_published_scenario Refuses an agent change that activates the agent or gives an active agent a new scenario, while that scenario has no published version and the agent has automations that are not archived. data.automations names up to twenty of them.
409 communication_active The call is being dialled or is in progress; delete it once it ends, or with hard=true.
409 communication_result_target_conflict Another delivery of the same communication already holds the target URL.
409 conflict The write collides with the current state of the resource; message says what collided.
409 contact_changed The contact does not have the revision the request carries.
409 contact_field_in_use The condition of a live routing of an agent that is not archived reads the data field or a field under it; data.routings names them, the first twenty of them.
409 contact_in_use Live automations hold a segment the contact is in; data.automations names them.
409 email_conflict Another live user, at either level, already holds the email address.
409 external_id_conflict Another live resource of the same kind and scope already holds the external identifier.
409 limit_policy_in_use Live automations name the policy; data.automations names them.
409 number_external_id_conflict Another live number of the account holds the external_id.
409 number_identifier_conflict The identifier is registered platform-wide already, possibly by an account the caller cannot see.
409 number_in_use Agents that are not archived use the number, bound to it or to its pool; data.agents names them, the first twenty of them.
409 number_pool_external_id_conflict Another live pool of the account holds the external_id.
409 number_pool_in_use Agents use the pool; data.agents names them, the first twenty of them.
409 scenario_in_use Agents that are not archived reference the scenario, or live routings of agents that are not archived play it; data.agents and data.routings name them, the first twenty of each.
409 segment_default_read_only The account’s default segment takes no edit, no source and no delete.
409 segment_in_use Live automations hold the segment, or the condition of a live routing of an agent that is not archived names it; data.automations or data.routings names them.
409 segment_publish_running A publish of the segment’s sources is running; until it ends the sources take no write and no second publish. A publish that stopped without finishing counts as running for five minutes after it last worked.
409 sms_provider_in_use Agents that are not archived reference the provider; data.agents names them, the first twenty of them.
413 payload_too_large The body exceeds the size limit of the operation.
422 agent_archived The agent is archived and accepts no change.
422 agent_calling_schedule_invalid Refuses the calling schedule in the request.
Returned when:
- The calling schedule names an unknown strategy.
- The calling schedule carries no schedules.
- The calling schedule carries a schedule that never opens.
422 agent_gateway_inactive The agent is active and its gateway has no active number.
422 agent_invalid Refuses the agent in the request.
Returned when:
- The gateway is neither a number nor a pool.
- scenario_sid is empty.
- The body sets status to archived.
- A referenced scenario, number or pool is missing or deleted.
422 agent_lines_exceeded The lines figure takes the account’s agents past its allocation.
422 agent_lines_under_policies The lines figure is below what the agent’s limit policies reserve.
422 agent_name_in_use Another agent of the account holds the name; archived and deleted agents do not count.
422 agent_not_archived The agent is not archived, and only an archived agent can be deleted.
422 agent_number_in_pool The number belongs to a pool.
422 agent_number_in_use Another agent holds the number.
422 agent_timezone_invalid timezone is not an IANA zone name.
422 agent_timezone_required The calling schedule needs a timezone, and the agent has none.
422 automation_archived The automation is archived and accepts no change.
422 automation_attempt_end_missing The move leaves an attempt without an end anywhere but last in the schedule.
422 automation_attempt_ends_before_start ends_at is not after starts_at.
422 automation_attempt_opened An attempt of the automation has opened, so its agent, segment and mode no longer change.
422 automation_attempt_overlaps The window overlaps another attempt of the automation.
422 automation_attempt_past Refuses a moment or an attempt that is not in the future.
Returned when:
- The moment is in the past.
- The attempt is already running or past.
422 automation_attempts_waiting The automation holds attempts waiting to open, so its mode does not change.
422 automation_mode_manual The automation is in the manual mode, which takes no scheduled attempts.
422 automation_name_in_use Another live automation of the target agent holds the name.
422 automation_run_under_way A run is idle or in progress; the action waits for it to stop.
422 automation_scenario_unpublished The agent’s scenario has never been published.
422 automation_segment_claimed Another live automation holds the segment.
422 communication_invalid Refuses the dispatch body.
Returned when:
- The body names an agent, scenario, version, draft, recipient or variable that is missing, out of scope or malformed.
- A recipient is a phone number with no country calling code.
- A recipient is a placeholder for a withheld number.
- The body names an automation_sid.
- The body names an agent that is archived.
- A data key is a system variable.
- A data key holds null, an object or an array.
- A test call finds no account number to dial from.
- The body sends is_test: false with scenario_sid, prefer_draft: true or draft: true, or sends prefer_draft and draft with different values.
message says which. The data keys contact and contact.{path} are never refused.
422 connected_agent_sms_settings_not_set The version being published has an SMS brick, and agents that are not archived and have no SMS settings reference the scenario; data.agents names them, the first twenty of them.
422 contact_data_limit Refuses contact data the account cannot hold.
Returned when:
- The contact data would break a limit of its account.
- The contact data is already past a limit, and the write leaves it past.
- A value has another type than its field holds across the account’s contacts.
- An item of an array is an object, an array or null.
data names the limit, the field and the numbers or the types.
422 contact_field_conflict Refuses the rename of a field in the contact data.
Returned when:
- The new path lies inside the old one or holds it.
- A contact of the account holds a value at the new path or on the way to it.
- A contact holds a value that is not an object on the way to the new path.
data.field names the field in the way, and data.contact the first such contact when one is named.
422 contact_invalid Refuses the contact number in the request.
Returned when:
- The number is missing.
- The number cannot be brought to the stored form.
data.reason names why, as a code.
422 contact_limit_reached The account holds as many contacts as its limit allows, and the request would add one more.
422 contact_number_taken The account already holds a contact with this number.
422 invalid_role Refuses a role named in the request.
Returned when:
- The role does not exist.
- The role is a tenant role named for an account-level user.
422 limit_policy_name_in_use Another live policy of the same agent holds the name.
422 limit_policy_over_agent The policies of the agent, this one included, reserve more lines than the agent has.
422 number_identifier_invalid The identifier is not a SIP identity the platform accepts.
422 number_pool_invalid name is blank.
422 routing_default_locked The request changes, moves or deletes the default routing.
422 routing_invalid Refuses the routing in the request.
Returned when:
- The name is empty.
- The position is outside the agent’s list.
- The scenario does not exist on the account.
- The condition names a segment that the account does not hold.
422 routing_name_in_use Another live routing of the same agent holds the name, or the name is default in any letter case.
422 scenario_copy_failed A resource the scenario or template names cannot be copied, so nothing is created and no resource is left behind.
422 scenario_invalid The patch unsets type, name or constructor.
422 scenario_sms_sender_required The published version of the agent’s scenario has an SMS brick, and the agent has no SMS settings.
422 scenario_validation_failed The constructor is missing, or the constructor or a brick checked alone does not pass validation; data.errors.scenario lists each failure.
422 scenario_version_immutable The record is a published version or a frozen draft; only the current work-in-progress draft is deletable.
422 segment_invalid Refuses the segment or source in the request.
Returned when:
- name is empty.
- The source kind is not one the platform offers.
- auto_update is set on a source kind that cannot be followed.
422 segment_name_in_use Another live segment of the account already holds the name; a deleted segment releases its name.
422 sms_provider_invalid Refuses the SMS configuration.
Returned when:
- The sender is missing.
- The alpha or number named is not the provider’s.
- The provider config is incomplete.
422 sms_provider_name_taken Another live provider of the account holds the name.
422 sms_send_invalid Refuses a send that names no usable target.
Returned when:
- to is missing.
- Neither an agent nor a provider with a sender is given.
422 sms_settings_missing The agent named has no SMS settings.
422 source_conflict Two draft sources supply the same number with different data.
422 source_contact_limit The batch would add more contacts than the account can take; GET …/source/-/validate shows how many it can.
422 source_data_limit A merged contact of the batch would break a data limit of the account; GET …/source/-/validate names it.
422 source_nothing_to_publish The segment has no draft source.
422 source_published The source is published; its rows and its reset_reach no longer change.
422 source_removed The source is removed and takes no write.
422 source_row_duplicate The source already holds a row with this number.
429 rate_limited More requests than the operation allows in its window; wait and retry.
500 internal The server failed to answer; the request did not take effect and may be retried. Any operation can answer it, so no operation lists it.

Information

  • OpenAPI version: 3.1.0

Carries a user session token or a user’s API key.

By credential:

  • Session tokens come from POST /v1/a/auth/regular or a consumed magic link.
  • API keys are issued through the user and profile routes.

Security scheme type: http