# Voicebot API reference ## Account API 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 `. 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 `:` or `::`, 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.` or a `contact.` names a field no contact of the account holds.
- A `data.` or a `contact.` 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.` 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. | ### List scenarios `GET /v1/a/scenario` Operation id: `GetScenariosList` The caller's own account alone: a scenario another account shared for copy is readable by id, never listed here. Rows carry the whole constructor, so a page of them is large; other resources embed a trimmed form instead. Parameters: - `limit` (query, integer): Page size, max 500 (default 100). - `offset` (query, integer) - `order_by` (query, string): Sets the sort field: `created_at`, `name` or `is_published`. Values: - `created_at`: is the default. - `is_published`: with `desc`, puts the published scenarios first, newest first within each side. - `order` (query, string): Sort direction: asc | desc (default desc). Anything else is refused. - `type` (query, string) - `sid` (query, string) - `name` (query, string): Case-insensitive substring of the name. A `filter_or` search supersedes it: send both and this one is dropped. - `filter_or` (query, string): Names the fields, comma-separated, that filter_query OR-searches. Values: - `id`: matched exactly. - `name`: matched as a substring, case-insensitive. - `filter_query` (query, string): Search term matched across the fields named in filter_or. Either one sent without the other is refused. - `is_published` (query, boolean): Narrows the list by whether a version has been published. Values: - `false`: returns the scenarios that exist as a draft only. - Omitted: both are returned. - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `500`: Internal server error Response body (`200`): Content type `application/json`: - `items` (array of object, required) - `id` (string, required) - `type` (enum(constructor), required) - `name` (string, required) - `template` (string, required) - `description` (string, required) - `account_sid` (string, required) - `constructor` (Constructor | null, required) - `fix_communication_ttl` (integer, required) - `is_shared_for_copy` (boolean, required): Shares the scenario for read and copy with other accounts of the owning tenant. Rules: - The permission of each operation still applies. - Outside the owning tenant, the scenario is absent. - Writes are unaffected. - `GET /v1/a/scenario` still lists the caller's own account alone. - A shared scenario does resolve into another resource's `included` map. - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) - `version` (integer, required) - `draft_exists` (boolean, required) - `is_published` (boolean, required): Says whether a version has been published. false while the scenario exists as a draft only. - `total` (integer (int64), required): Counts the scenarios matching the query, ignoring paging. - `limit` (integer, required): Reports the page size applied to this request. - `offset` (integer, required): Reports the offset applied to this request. - `has_more` (boolean, required): Says whether records beyond this page match the query. ### Create scenario `POST /v1/a/scenario` Operation id: `CreateScenario` Creates a scenario. A `fix_communication_ttl` that is omitted, or sent as 0, is stored as 3600. By mode: - Without `draft: true`, the scenario is published as version 1, and that version is filed in its history. - With `draft: true`, nothing is published: `version` stays 0 and the content lands as the work-in-progress draft. A publish is refused while a JavaScript brick names an edge function the account does not hold; a draft save is not refused. Parameters: - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Request body: Content type `application/json`: - `type` (enum(constructor), required) - `name` (string, required) - `template` (string) - `fix_communication_ttl` (integer) - `is_shared_for_copy` (boolean) - `constructor` (object) - `bricks` (object): Holds the properties of a brick, one key per brick type. Rules: - A text property reads a variable when it holds `{{name}}`, and a contact field when it holds `{{contact.}}`; the call puts the value in place when the brick runs. - A number, a boolean and an enum property take no variable. - `start_call`, `inbound_call`, `outbound_call`, `recording_setup`, `tree`, `start_tree`, `end_tree` and `end`: no property takes a variable. - `condition_group` and `assignment`: only `value` takes a variable. - `webhook`: only the method, the URL, the body, the names and values of the headers and of the form fields, the basic-auth username and password, the bearer token, the proxy URL, and the `path` and `set_if_not_found` of a response mapping take a variable. - A property that names a variable to write, such as `variable` of a response mapping or of `increment`, is written to and not read. - The guide with examples: https://docs.aiva.apifonica.com/guides/build/variables/ - `audio` (object) - `v1` (array of object) - `audio_file` (object) - `v1` (array of object) - `audio_tts` (object) - `v1` (array of object) - `sms` (object) - `v1` (array of object) - `goal` (object) - `v1` (array of object) - `end_call` (object) - `v1` (array of object) - `assignment` (object) - `v1` (array of object) - `increment` (object) - `v1` (array of object) - `condition_group` (object) - `v1` (array of object) - `start_tree` (object) - `v1` (array of object) - `start_call` (object) - `v1` (array of object) - `v2` (array of object) - `outbound_call` (object) - `v1` (array of object) - `inbound_call` (object) - `v1` (array of object) - `end` (object) - `v1` (array of object) - `call_transfer` (object) - `v1` (array of object) - `question` (object) - `v1` (array of object) - `webhook` (object) - `v1` (array of object) - `data_mapping` (object) - `v1` (array of object) - `tree` (object) - `v1` (array of object) - `end_tree` (object) - `v1` (array of object) - `background_audio` (object) - `v1` (array of object) - `javascript` (object) - `v1` (array of object) - `warm_up_tts` (object) - `v1` (array of object) - `business_metric` (object) - `v1` (array of object) - `ai_agent` (object) - `v1` (array of object) - `send_dtmf` (object) - `v1` (array of object) - `recording_setup` (object) - `v1` (array of object) - `transcription` (object) - `v1` (array of object) - `forest` (object) - `trees` (array of object) - `description` (string) - `tree_id` (string) - `nodes` (array of object) - `properties` (object) - `engine_version` (enum(v3)): Any value sent is stored as v3. - `draft` (boolean): Creates the scenario unpublished when true. Rules: - The content is saved as its work-in-progress draft. - `version` stays 0 until the first publish. - `validate` (boolean): Gates two independent checks. The checks: - Constructor content validation is honoured only together with `draft: true`. When false, an incomplete work-in-progress draft is saved. - Classifier readiness is honoured on a publish. When false, the publish is not blocked by a referenced classifier version that is not trained. A publish always validates content, whatever the value. Responses: - `201`: Created - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `422`: Unprocessable - `500`: Internal server error Response body (`201`): Content type `application/json`: - `id` (string, required) - `type` (enum(constructor), required) - `name` (string, required) - `template` (string, required) - `description` (string, required) - `account_sid` (string, required) - `constructor` (Constructor | null, required) - `fix_communication_ttl` (integer, required) - `is_shared_for_copy` (boolean, required): Shares the scenario for read and copy with other accounts of the owning tenant. Rules: - The permission of each operation still applies. - Outside the owning tenant, the scenario is absent. - Writes are unaffected. - `GET /v1/a/scenario` still lists the caller's own account alone. - A shared scenario does resolve into another resource's `included` map. - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) - `version` (integer, required) - `draft_exists` (boolean, required) - `is_published` (boolean, required): Says whether a version has been published. false while the scenario exists as a draft only. ### Get scenario `GET /v1/a/scenario/{id}` Operation id: `GetScenario` Reads one scenario. For a scenario of another account: - One shared for copy is also readable by other accounts of the owning tenant. - Any other foreign scenario, and any scenario outside the owning tenant, reads as absent. Parameters: - `id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `500`: Internal server error Response body (`200`): Content type `application/json`: - `id` (string, required) - `type` (enum(constructor), required) - `name` (string, required) - `template` (string, required) - `description` (string, required) - `account_sid` (string, required) - `constructor` (Constructor | null, required) - `fix_communication_ttl` (integer, required) - `is_shared_for_copy` (boolean, required): Shares the scenario for read and copy with other accounts of the owning tenant. Rules: - The permission of each operation still applies. - Outside the owning tenant, the scenario is absent. - Writes are unaffected. - `GET /v1/a/scenario` still lists the caller's own account alone. - A shared scenario does resolve into another resource's `included` map. - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) - `version` (integer, required) - `draft_exists` (boolean, required) - `is_published` (boolean, required): Says whether a version has been published. false while the scenario exists as a draft only. ### Delete scenario `DELETE /v1/a/scenario/{id}` Operation id: `DeleteScenario` Soft delete. Refused while an agent references the scenario or a routing of an agent plays it; an archived agent and its routings do not count. Parameters: - `id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `409`: Conflict - `500`: Internal server error Response body (`200`): Content type `application/json`: - `code` (string, required) - `reason` (string, required) ### Update scenario `PATCH /v1/a/scenario/{id}` Operation id: `PatchScenario` Saves the scenario, as a publish or as a draft. Only the owning account writes the scenario: a scenario another account shared for copy is readable but not writable. On a publish: - A change of `name` or `constructor` files the next version in the scenario's history. - A move of a node or a new order of the outputs of a brick is not a change of `constructor`. - Without such a change, `version` stays. - Without such a change, the latest version takes the node positions and the order of outputs that the request sends. - Any pending draft is left untouched. Refused when: - A publish whose constructor has an SMS brick while an agent that is not archived references the scenario and has no SMS settings. - A publish has a JavaScript brick that names an edge function the account does not hold. A draft save is not refused for either. Parameters: - `id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Request body: Content type `application/json`: - `type` (enum(constructor)) - `name` (string) - `template` (string) - `fix_communication_ttl` (integer) - `is_shared_for_copy` (boolean) - `constructor` (Constructor | null) - `draft` (boolean) - `validate` (boolean): Gates two independent checks. The checks: - Constructor content validation is honoured only together with `draft: true`. When false, an incomplete work-in-progress draft is saved. - Classifier readiness is honoured on a publish. When false, the publish is not blocked by a referenced classifier version that is not trained. A publish always validates content, whatever the value. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `422`: Unprocessable - `500`: Internal server error Response body (`200`): Content type `application/json`: - `id` (string, required) - `type` (enum(constructor), required) - `name` (string, required) - `template` (string, required) - `description` (string, required) - `account_sid` (string, required) - `constructor` (Constructor | null, required) - `fix_communication_ttl` (integer, required) - `is_shared_for_copy` (boolean, required): Shares the scenario for read and copy with other accounts of the owning tenant. Rules: - The permission of each operation still applies. - Outside the owning tenant, the scenario is absent. - Writes are unaffected. - `GET /v1/a/scenario` still lists the caller's own account alone. - A shared scenario does resolve into another resource's `included` map. - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) - `version` (integer, required) - `draft_exists` (boolean, required) - `is_published` (boolean, required): Says whether a version has been published. false while the scenario exists as a draft only. ### Copy scenario `POST /v1/a/scenario/{id}/copy` Operation id: `CopyScenario` Copies a scenario into the caller's account. By source: - An own scenario is copied. - A shared-for-copy scenario of another account of the same tenant is copied. - Any other foreign scenario reads as absent. The copy starts unpublished: `version` 0, the content as its work-in-progress draft. Rules for a shared scenario of another account: - Every classifier, edge function, RAG document and audio file it names is created again in the caller's account, and the copy names the new ones. - Webhook authentication is not copied. Refused when: - The scenario belongs to another account, and the account made another copy less than a minute ago. A copy of a template counts. - A resource of the shared scenario cannot be copied. Nothing is created then. Parameters: - `id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `201`: Created - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `422`: Unprocessable - `429`: Too many requests - `500`: Internal server error Response body (`201`): Content type `application/json`: - `id` (string, required) - `type` (enum(constructor), required) - `name` (string, required) - `template` (string, required) - `description` (string, required) - `account_sid` (string, required) - `constructor` (Constructor | null, required) - `fix_communication_ttl` (integer, required) - `is_shared_for_copy` (boolean, required): Shares the scenario for read and copy with other accounts of the owning tenant. Rules: - The permission of each operation still applies. - Outside the owning tenant, the scenario is absent. - Writes are unaffected. - `GET /v1/a/scenario` still lists the caller's own account alone. - A shared scenario does resolve into another resource's `included` map. - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) - `version` (integer, required) - `draft_exists` (boolean, required) - `is_published` (boolean, required): Says whether a version has been published. false while the scenario exists as a draft only. ### List scenario placeholders `GET /v1/a/scenario/{id}/placeholders` Operation id: `GetScenarioPlaceholders` Lists every variable the stored scenario names, deduplicated: the keys to supply as `data` when dialling it. Rules: - A variable named in a `{{…}}` placeholder is listed. - A variable a brick sets is listed. - System variables are left out. A draft-only save leaves the set unchanged. Parameters: - `id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `500`: Internal server error Response body (`200`): Content type `application/json`: - `placeholders` (array of string, required) ### Run webhook brick configuration `POST /v1/a/scenario/webhook/run` Operation id: `RunScenarioWebhook` Runs the configuration against the supplied test variables; no stored scenario changes. Rules: - A target that cannot be reached gives a successful answer carrying `status: "fail"`. - A target that answers `300` or above gives a successful answer carrying `status: "fail"`. - Only an invalid configuration is an error response. Request body: Content type `application/json`: - `properties` (object, required) - `request` (object, required) - `method` (string, required) - `url` (string, required) - `body` (object) - `data` (string) - `type` (string) - `form_values` (array of object) - `authentication` (object) - `type` (string) - `basic` (object) - `bearer` (object) - `header` (object) - `headers` (array of object) - `insecure_skip_verify` (boolean) - `proxy` (object) - `url` (string) - `attach_call_metadata` (boolean) - `timeout` (number (float)) - `options` (object) - `async` (boolean) - `timeout` (number (float)) - `response_mapping` (object) - `variables` (array of object) - `name` (string): Names the target variable, written as a placeholder. Returned unwrapped in `variables`. - `source` (string): Picks where the value is read from. Values: - `body`: `path` holds a JSONPath. - `header`: `path` holds the header name. - `path` (string) - `set_if_not_found` (string) - `storage` (object): Holds the test variable values placeholders are compiled against. A `{{contact.}}` placeholder is read from the `contact` value, which holds the contact's data as JSON text. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `422`: Unprocessable - `500`: Internal server error Response body (`200`): Content type `application/json`: - `status` (string, required): Reports the outcome the scenario would branch on — `processed` or `fail`. - `error` (string, required): Carries the failure detail; empty when the outcome is `processed`. - `variables` (object | null, required): Variables the response mapping extracted. - `curl` (string, required): Reproduces the request as a curl command. - `redirects` (array | null, required) - `response` (WebhookRunResponse | null, required): Carries the response received; `null` when the target never answered. ### Validate scenario `POST /v1/a/scenario/{id}/validate` Operation id: `ValidateScenario` Runs the checks of a publish on a body and stores nothing: the constructor, the classifier versions its bricks pin, and the edge functions its JavaScript bricks name. By `id`: - `-`: runs the checks of publishing a new scenario. - The id of a stored scenario: runs the checks of publishing its next version, the SMS settings of the agents that run it included. Parameters: - `id` (path, string, required): Names the stored scenario whose next version is checked, or `-` for a new scenario. - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Request body: Content type `application/json`: - `type` (enum(constructor), required) - `name` (string, required) - `constructor` (object) - `bricks` (object): Holds the properties of a brick, one key per brick type. Rules: - A text property reads a variable when it holds `{{name}}`, and a contact field when it holds `{{contact.}}`; the call puts the value in place when the brick runs. - A number, a boolean and an enum property take no variable. - `start_call`, `inbound_call`, `outbound_call`, `recording_setup`, `tree`, `start_tree`, `end_tree` and `end`: no property takes a variable. - `condition_group` and `assignment`: only `value` takes a variable. - `webhook`: only the method, the URL, the body, the names and values of the headers and of the form fields, the basic-auth username and password, the bearer token, the proxy URL, and the `path` and `set_if_not_found` of a response mapping take a variable. - A property that names a variable to write, such as `variable` of a response mapping or of `increment`, is written to and not read. - The guide with examples: https://docs.aiva.apifonica.com/guides/build/variables/ - `audio` (object) - `v1` (array of object) - `audio_file` (object) - `v1` (array of object) - `audio_tts` (object) - `v1` (array of object) - `sms` (object) - `v1` (array of object) - `goal` (object) - `v1` (array of object) - `end_call` (object) - `v1` (array of object) - `assignment` (object) - `v1` (array of object) - `increment` (object) - `v1` (array of object) - `condition_group` (object) - `v1` (array of object) - `start_tree` (object) - `v1` (array of object) - `start_call` (object) - `v1` (array of object) - `v2` (array of object) - `outbound_call` (object) - `v1` (array of object) - `inbound_call` (object) - `v1` (array of object) - `end` (object) - `v1` (array of object) - `call_transfer` (object) - `v1` (array of object) - `question` (object) - `v1` (array of object) - `webhook` (object) - `v1` (array of object) - `data_mapping` (object) - `v1` (array of object) - `tree` (object) - `v1` (array of object) - `end_tree` (object) - `v1` (array of object) - `background_audio` (object) - `v1` (array of object) - `javascript` (object) - `v1` (array of object) - `warm_up_tts` (object) - `v1` (array of object) - `business_metric` (object) - `v1` (array of object) - `ai_agent` (object) - `v1` (array of object) - `send_dtmf` (object) - `v1` (array of object) - `recording_setup` (object) - `v1` (array of object) - `transcription` (object) - `v1` (array of object) - `forest` (object) - `trees` (array of object) - `description` (string) - `tree_id` (string) - `nodes` (array of object) - `properties` (object) - `engine_version` (enum(v3)): Any value sent is stored as v3. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `422`: Unprocessable - `500`: Internal server error Response body (`200`): Content type `application/json`: - `valid` (boolean, required): Reports that the body passes every check of a publish; always true, because a body that fails a check is refused. ### List system variables `GET /v1/a/scenario/system-variables` Operation id: `GetSystemVariables` Lists the system variables: the variables the platform sets during a call. Rules: - A scenario reads one without declaring it, by writing `{{name}}` in a brick property or a text. - The scenario's placeholders leave it out. The name forms: - A fixed name, such as `call.id` or `last_webhook.body`, names one variable. - A name with a part in `{ }`, such as `action.webhook.{brick_id}.status` or `sip.headers.{header}`, names one variable for each value of that part. - `contact.{path}`: names one field of the contact's data, the object `contact` holds. For a name with a part in `{ }`: - A scenario fills the part in when it reads the variable: `{{action.webhook.w1.status}}` for the webhook brick `w1`, `{{sip.headers.X-Customer-Id}}` for that SIP header. - The filled-in part holds no dot. For `contact.{path}`: - Its part in `{ }` is a path and may hold dots. - The path is one or more keys joined by single dots, each key made of Latin letters, digits, `-` and `_`. - A key of digits only is a position in a list, counted from 0: `{{contact.address.city}}` is `city` inside `address`, `{{contact.phones.0}}` is the first item of `phones`. On a read of a contact field: - A field is read as text: a number or a boolean as it is written in the data, an object or a list as JSON text. - A path that leads to no field, or to a field that holds `null`, is read as empty text. On a write of a contact field: - A write sets the field to text, whatever the field held before. - A write creates the objects and lists the path names when the data does not hold them. - A position in a list is written when the list holds it or when it is the next free one. - A write whose path does not fit the data changes nothing, and the call continues. When the call ends: - Each written field is stored on the contact as the type the field holds across the account's contacts. - A value that does not read as that type, or that breaks a data limit of the account, is not stored, and the field keeps what it held. Static reference data: the same list for every caller, no paging, no filtering. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `500`: Internal server error Response body (`200`): Content type `application/json`: - `system_variables` (array of object, required) - `name` (string, required): Written without the `{{ }}` of a placeholder. - `writable` (boolean, required): Says whether a scenario may write to the variable. ### Validate one brick `POST /v1/a/brick/-/validate` Operation id: `ValidateBrick` Checks one brick and answers with the errors the same brick gets when its scenario is saved; nothing is stored. Rules: - The checks that read the rest of the scenario are not run: the bricks and nodes it holds, the links in `forest`, the tree a `tree` brick runs, and the bricks a `warm_up_tts` brick names. - The errors carry no `tree_id` and no `node_id`. Request body: Content type `application/json`: - `type` (string, required): Names the brick type, a key of `constructor.bricks`. - `version` (string, required): Names the brick version, a key under that type. - `brick` (object, required): Carries the brick in the shape a scenario stores it under `constructor.bricks..`. Responses: - `204`: No content - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `422`: Unprocessable - `500`: Internal server error ### List scenario versions `GET /v1/a/scenario-version` Operation id: `ListScenarioVersions` Lists the history of one scenario. Rules: - `scenario_sid`: is required, because the list covers one scenario. - `draft`: picks an axis; without it, published versions and draft records interleave. Every row carries its whole snapshot, so a default page can hold 100 complete constructors. Parameters: - `scenario_sid` (query, string, required): Scenario whose version records are listed. - `limit` (query, integer): Page size, max 500 (default 100). - `offset` (query, integer) - `order` (query, string): Sort direction: asc | desc (default desc). Anything else is refused. - `order_by` (query, string): Sort field. Accepted: created_at, version (default created_at). - `draft` (query, boolean): Selects the kind of record the list returns. Values: - `true`: lists draft records, by `draft_version`. - `false`: lists published versions, by `version`. - Omitted: lists both. - `version` (query, integer): Exact-match filter on the published axis number; AND-combined with the other list filters. - `draft_version` (query, integer): Exact-match filter on the draft axis number; AND-combined with the other list filters. - `filter_or` (query, string): Names the fields to OR-search via `filter_query`, comma-separated. Values: - `id`: matched exactly. - `content_hash`: matched exactly. - `filter_query` (query, string): Search term matched across the fields named in filter_or. Either one sent without the other is refused. - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `500`: Internal server error Response body (`200`): Content type `application/json`: - `items` (array of object, required) - `id` (string, required) - `scenario_sid` (string, required) - `version` (integer | null) - `draft_version` (integer | null) - `content_hash` (string, required): Identifies the content of the record. Node positions and the order of brick outputs are not content. - `snapshot` (object, required) - `name` (string, required) - `constructor` (Constructor | null) - `created_at` (string (date-time), required) - `total` (integer (int64), required): Counts the versions matching the query, ignoring paging. - `limit` (integer, required): Reports the page size applied to this request. - `offset` (integer, required): Reports the offset applied to this request. - `has_more` (boolean, required): Says whether records beyond this page match the query. ### Get scenario version `GET /v1/a/scenario-version/by-scenario` Operation id: `GetScenarioVersionByScenario` Addresses one version record by parent scenario plus axis number. Parameters: - `scenario_sid` (query, string, required): Parent scenario whose version record is addressed. - `version` (query, integer, required): Addresses a record by its axis number. By `draft`: - `draft=false`: the number is the published `version`. - `draft=true`: the number is the `draft_version`. `draft_version` 0 is the current work-in-progress draft. - `draft` (query, boolean): Selects the axis; the default is `false`. Values: - `false`: selects the published record, where `version` equals the number. - `true`: selects the draft record, where `draft_version` equals the number. - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `500`: Internal server error Response body (`200`): Content type `application/json`: - `id` (string, required) - `scenario_sid` (string, required) - `version` (integer | null) - `draft_version` (integer | null) - `content_hash` (string, required): Identifies the content of the record. Node positions and the order of brick outputs are not content. - `snapshot` (object, required) - `name` (string, required) - `constructor` (Constructor | null) - `created_at` (string (date-time), required) ### Delete draft record `DELETE /v1/a/scenario-version/by-scenario` Operation id: `DeleteScenarioVersionByScenario` Deletes the current work-in-progress draft (`draft_version` 0), addressed by parent scenario plus axis number. Refused when: - The record is a published version. - The record is a frozen draft record, which is immutable. Parameters: - `scenario_sid` (query, string, required): Parent scenario whose version record is addressed. - `version` (query, integer, required): Addresses a record by its axis number. By `draft`: - `draft=false`: the number is the published `version`. - `draft=true`: the number is the `draft_version`. `draft_version` 0 is the current work-in-progress draft. - `draft` (query, boolean): Selects the axis; the default is `false`. Values: - `false`: selects the published record, where `version` equals the number. - `true`: selects the draft record, where `draft_version` equals the number. - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: Deleted - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `422`: Unprocessable - `500`: Internal server error Response body (`200`): Content type `application/json`: - `code` (string, required) - `reason` (string, required) ### List numbers `GET /v1/a/number` Operation id: `ListNumbers` Lists the numbers. The fields: - `is_used`: says whether an agent holds the number. - `agent_sid`: names the holding agent. - `pool_sid`: names the pool the number belongs to. The parameters: - `is_used=false`: returns only the numbers an agent can take. - `include=agent`: resolves the holding agent into `included`. - `include=number_pool`: resolves the pool into `included`. Parameters: - `limit` (query, integer): Page size, max 500 (default 100). - `offset` (query, integer) - `status` (query, string) - `identifier` (query, string): Exact match on the whole identifier. Name `identifier` in `filter_or` to match a fragment of one. - `pool_sid` (query, string) - `filter_or` (query, string): Comma-separated field names to OR-search via filter_query. Accepted: identifier, name (both substring, case-insensitive). - `filter_query` (query, string): Search term matched across the fields named in filter_or. - `order_by` (query, string): Sort field. Accepted: created_at, name, identifier (default created_at). - `order` (query, string): Sort direction: asc | desc (default desc). - `is_used` (query, boolean): Narrows the list by whether an agent already holds the number. Values: - `false`: returns the ones free for an agent to take. - Omitted: both are returned. - `include` (query, string): Comma-separated related resources to resolve into `included`. Accepted: number_pool, agent. - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `500`: Internal server error Response body (`200`): Content type `application/json`: - `items` (array of object, required) - `id` (string, required) - `account_sid` (string, required) - `identifier` (string, required) - `name` (string, required) - `external_id` (string, required): Carries the key the client system provisioning this number assigned to it. Unique among the account's live numbers when set. - `pool_sid` (string | null, required) - `status` (enum(active, inactive), required) - `is_used` (boolean, required): Says whether an agent already holds this number. Rules: - Only an active or inactive agent counts as holding it. - Archiving that agent releases it. - An agent that reaches the number only through its pool does not hold it. - `agent_sid` (string | null, required): Identifies the agent that holds this number; null while none does. - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) - `total` (integer (int64), required): Counts the numbers matching the query, ignoring paging. - `limit` (integer, required): Reports the page size applied to this request. - `offset` (integer, required): Reports the offset applied to this request. - `has_more` (boolean, required): Says whether records beyond this page match the query. - `included` (object, required): Carries the related resources resolved for this response, one map per relation under the relation's name, keyed by the related resource's own id (`included.number_pool[id]`, `included.agent[agent_sid]`). Rules: - A relation's map is present whenever it was requested. - A requested relation's map is empty when nothing resolved. - A reference the caller may not read is absent from the map, and the number keeps its sid. - `number_pool` (object) - `agent` (object) ### Create number `POST /v1/a/number` Operation id: `CreateNumber` Registers a SIP identity for the account. Rules: - The identifier is unique platform-wide. - `status`: defaults to active. - `pool_sid`: places the number in a pool at creation. While the tenant declares `number` in `managed_resources`: - Only a caller with the role `tenant_admin` creates one. - `external_id` is required. Parameters: - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Request body: Content type `application/json`: - `identifier` (string, required): Starts with a letter or digit. - `name` (string) - `external_id` (string) - `pool_sid` (string | null) - `status` (enum(active, inactive)) Responses: - `201`: Created - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `409`: Conflict - `422`: Unprocessable - `500`: Internal server error Response body (`201`): Content type `application/json`: - `id` (string, required) - `account_sid` (string, required) - `identifier` (string, required) - `name` (string, required) - `external_id` (string, required): Carries the key the client system provisioning this number assigned to it. Unique among the account's live numbers when set. - `pool_sid` (string | null, required) - `status` (enum(active, inactive), required) - `is_used` (boolean, required): Says whether an agent already holds this number. Rules: - Only an active or inactive agent counts as holding it. - Archiving that agent releases it. - An agent that reaches the number only through its pool does not hold it. - `agent_sid` (string | null, required): Identifies the agent that holds this number; null while none does. - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) ### Get number by external identifier `GET /v1/a/number/-/external/{external_id}` Operation id: `GetNumberByExternalID` Resolves the number the calling account gave this key, without the caller knowing the platform id. Parameters: - `external_id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `500`: Internal server error Response body (`200`): Content type `application/json`: - `id` (string, required) - `account_sid` (string, required) - `identifier` (string, required) - `name` (string, required) - `external_id` (string, required): Carries the key the client system provisioning this number assigned to it. Unique among the account's live numbers when set. - `pool_sid` (string | null, required) - `status` (enum(active, inactive), required) - `is_used` (boolean, required): Says whether an agent already holds this number. Rules: - Only an active or inactive agent counts as holding it. - Archiving that agent releases it. - An agent that reaches the number only through its pool does not hold it. - `agent_sid` (string | null, required): Identifies the agent that holds this number; null while none does. - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) ### Delete number by external identifier `DELETE /v1/a/number/-/external/{external_id}` Operation id: `DeleteNumberByExternalID` Soft-deletes, as by id, the number the calling account gave this key, without the caller knowing the platform id. The key is released for reuse by a live number. Refused when: - An agent uses the number, as by id. - The tenant declares `number` in `managed_resources` and the caller does not have the role `tenant_admin`. Parameters: - `external_id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `204`: No content - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `409`: Conflict - `500`: Internal server error ### Get number `GET /v1/a/number/{id}` Operation id: `GetNumber` Returns the registered number. The fields: - `pool_sid`: names the pool the number sits in. - `agent_sid`: names the agent that holds it. The parameters: - `include=number_pool`: resolves the pool into `included`, the same map the list answers with. - `include=agent`: resolves the agent into `included`, the same map the list answers with. Parameters: - `id` (path, string, required) - `include` (query, string): Comma-separated related resources to resolve into `included`. Accepted: number_pool, agent. - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `500`: Internal server error Response body (`200`): Content type `application/json`: - `id` (string, required) - `account_sid` (string, required) - `identifier` (string, required) - `name` (string, required) - `external_id` (string, required): Carries the key the client system provisioning this number assigned to it. Unique among the account's live numbers when set. - `pool_sid` (string | null, required) - `status` (enum(active, inactive), required) - `is_used` (boolean, required): Says whether an agent already holds this number. Rules: - Only an active or inactive agent counts as holding it. - Archiving that agent releases it. - An agent that reaches the number only through its pool does not hold it. - `agent_sid` (string | null, required): Identifies the agent that holds this number; null while none does. - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) - `included` (object, required): Carries the related resources resolved for this response, one map per relation under the relation's name, keyed by the related resource's own id (`included.number_pool[id]`, `included.agent[agent_sid]`). Rules: - A relation's map is present whenever it was requested. - A requested relation's map is empty when nothing resolved. - A reference the caller may not read is absent from the map, and the number keeps its sid. - `number_pool` (object) - `agent` (object) ### Delete number `DELETE /v1/a/number/{id}` Operation id: `DeleteNumber` Deletes the number. Refused when: - An agent that is not archived is bound to the number. - An agent that is not archived is bound to the pool the number belongs to. - The tenant declares `number` in `managed_resources` and the caller does not have the role `tenant_admin`. Detaching the number from its pool releases it from the pool's agents. Parameters: - `id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `204`: Deleted - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `409`: Conflict - `500`: Internal server error ### Update number `PATCH /v1/a/number/{id}` Operation id: `PatchNumber` Updates the number. Rules: - A new identifier stays subject to the platform-wide uniqueness rule. - While the tenant declares `number` in `managed_resources`, a caller without the role `tenant_admin` may send `status`, in either direction, and nothing else. - A number an agent holds does not join a pool. Effects: - `status: inactive` switches off the active agent that holds the number. - A number that leaves its pool, or turns inactive, switches off the active agents of the pool when the pool keeps no active number. - `status: active` switches on no agent. Parameters: - `id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Request body: Content type `application/json`: - `identifier` (string): Starts with a letter or digit. - `name` (string) - `external_id` (string) - `pool_sid` (string | null) - `status` (enum(active, inactive)) Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `409`: Conflict - `422`: Unprocessable - `500`: Internal server error Response body (`200`): Content type `application/json`: - `id` (string, required) - `account_sid` (string, required) - `identifier` (string, required) - `name` (string, required) - `external_id` (string, required): Carries the key the client system provisioning this number assigned to it. Unique among the account's live numbers when set. - `pool_sid` (string | null, required) - `status` (enum(active, inactive), required) - `is_used` (boolean, required): Says whether an agent already holds this number. Rules: - Only an active or inactive agent counts as holding it. - Archiving that agent releases it. - An agent that reaches the number only through its pool does not hold it. - `agent_sid` (string | null, required): Identifies the agent that holds this number; null while none does. - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) ### List number pools `GET /v1/a/number-pool` Operation id: `ListNumberPools` A pool row names no members: membership is held on the number, as its `pool_sid`. Ask for `include=number` to resolve each pool's numbers into `included`. Parameters: - `limit` (query, integer): Page size, max 500 (default 100). - `offset` (query, integer) - `status` (query, string) - `filter_or` (query, string): Names the fields, comma-separated, that filter_query OR-searches. Values: - `id`: matched exactly. - `name`: matched as a substring, case-insensitive. - `filter_query` (query, string): Search term matched across the fields named in filter_or. - `order_by` (query, string): Sort field. Accepted: created_at, name (default created_at). - `order` (query, string): Sort direction: asc | desc (default desc). - `include` (query, string): Comma-separated related resources to resolve into `included`. Accepted: number. - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `500`: Internal server error Response body (`200`): Content type `application/json`: - `items` (array of object, required) - `id` (string, required) - `account_sid` (string, required) - `name` (string, required) - `external_id` (string, required): Carries the key the client system provisioning this pool assigned to it. Unique among the account's live pools when set. - `status` (enum(active, inactive), required) - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) - `total` (integer (int64), required): Counts the pools matching the query, ignoring paging. - `limit` (integer, required): Reports the page size applied to this request. - `offset` (integer, required): Reports the offset applied to this request. - `has_more` (boolean, required): Says whether records beyond this page match the query. - `included` (object, required): Carries the related resources resolved for this response, one map per relation under the relation's name, keyed by the related resource's own id (`included.number[id]`). Rules: - A to-many relation is keyed the same way, and each number carries its `pool_sid`. - A relation's map is present whenever it was requested. - A requested relation's map is empty when nothing resolved. - A reference the caller may not read is absent from the map, and the pool keeps its sid. - `number` (object) ### Create number pool `POST /v1/a/number-pool` Operation id: `CreateNumberPool` Creates an empty pool. Rules: - Numbers join by being patched into it, not by being named here. - `status`: defaults to active. While the tenant declares `number_pool` in `managed_resources`: - Only a caller with the role `tenant_admin` creates one. - `external_id` is required. Parameters: - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Request body: Content type `application/json`: - `name` (string, required) - `external_id` (string) - `status` (enum(active, inactive)) Responses: - `201`: Created - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `409`: Conflict - `422`: Unprocessable - `500`: Internal server error Response body (`201`): Content type `application/json`: - `id` (string, required) - `account_sid` (string, required) - `name` (string, required) - `external_id` (string, required): Carries the key the client system provisioning this pool assigned to it. Unique among the account's live pools when set. - `status` (enum(active, inactive), required) - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) ### Get number pool by external identifier `GET /v1/a/number-pool/-/external/{external_id}` Operation id: `GetNumberPoolByExternalID` Resolves the number pool the calling account gave this key, without the caller knowing the platform id. Parameters: - `external_id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `500`: Internal server error Response body (`200`): Content type `application/json`: - `id` (string, required) - `account_sid` (string, required) - `name` (string, required) - `external_id` (string, required): Carries the key the client system provisioning this pool assigned to it. Unique among the account's live pools when set. - `status` (enum(active, inactive), required) - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) ### Delete number pool by external identifier `DELETE /v1/a/number-pool/-/external/{external_id}` Operation id: `DeleteNumberPoolByExternalID` Soft-deletes, as by id, the number pool the calling account gave this key, without the caller knowing the platform id. The key is released for reuse by a live pool. Refused when: - Agents use the pool. - The tenant declares `number_pool` in `managed_resources` and the caller does not have the role `tenant_admin`. Parameters: - `external_id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `204`: No content - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `409`: Conflict - `500`: Internal server error ### Get number pool `GET /v1/a/number-pool/{id}` Operation id: `GetNumberPool` Returns the pool row, which names no members. Rules: - `include=number`: resolves the members into `included`, capped the way the list caps them. - `GET /v1/a/number?pool_sid=…`: pages through all the members. Parameters: - `id` (path, string, required) - `include` (query, string): Comma-separated related resources to resolve into `included`. Accepted: number. - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `500`: Internal server error Response body (`200`): Content type `application/json`: - `id` (string, required) - `account_sid` (string, required) - `name` (string, required) - `external_id` (string, required): Carries the key the client system provisioning this pool assigned to it. Unique among the account's live pools when set. - `status` (enum(active, inactive), required) - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) - `included` (object, required): Carries the related resources resolved for this response, one map per relation under the relation's name, keyed by the related resource's own id (`included.number[id]`). Rules: - A to-many relation is keyed the same way, and each number carries its `pool_sid`. - A relation's map is present whenever it was requested. - A requested relation's map is empty when nothing resolved. - A reference the caller may not read is absent from the map, and the pool keeps its sid. - `number` (object) ### Delete number pool `DELETE /v1/a/number-pool/{id}` Operation id: `DeleteNumberPool` Deletes the pool. Refused when: - Agents use the pool. - The tenant declares `number_pool` in `managed_resources` and the caller does not have the role `tenant_admin`. Parameters: - `id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `204`: Deleted - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `409`: Conflict - `500`: Internal server error ### Update number pool `PATCH /v1/a/number-pool/{id}` Operation id: `PatchNumberPool` Updates the pool's own name, external identifier and status. Rules: - Membership is not here: a number joins or leaves by having its `pool_sid` patched. - While the tenant declares `number_pool` in `managed_resources`, a caller without the role `tenant_admin` may send `status`, in either direction, and nothing else. Effects: - `status: inactive` switches off the active agents of the pool. - `status: active` switches on no agent. Parameters: - `id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Request body: Content type `application/json`: - `name` (string) - `external_id` (string) - `status` (enum(active, inactive)) Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `409`: Conflict - `422`: Unprocessable - `500`: Internal server error Response body (`200`): Content type `application/json`: - `id` (string, required) - `account_sid` (string, required) - `name` (string, required) - `external_id` (string, required): Carries the key the client system provisioning this pool assigned to it. Unique among the account's live pools when set. - `status` (enum(active, inactive), required) - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) ### List communications `GET /v1/a/communication` Operation id: `ListCommunications` Lists the calls, newest first. Rules: - This resource takes no sort parameters. - Rows carry everything the single read does. - `include` resolves a row's agent, scenario, result deliveries, contact, automation and run into `included`. - A call placed by hand resolves no automation and no run. Parameters: - `limit` (query, integer): Page size, max 500 (default 100). - `offset` (query, integer) - `show_deleted` (query, boolean): Include soft-deleted rows when true. - `filter_or` (query, string): Names the fields, comma-separated, that filter_query OR-searches. Values: - `call_sid`: matched exactly. - `recipient`: matched as a substring, case-insensitive. - `filter_query` (query, string): Search term matched across the fields named in filter_or. - `draft` (query, boolean): Narrows the list by the kind of scenario version the run used. Values: - `true`: lists the runs on a draft, which have `draft_version` set. - `false`: lists the runs on a published version, which have `version` set. - Omitted: lists both kinds, and the calls of an agent not dialled yet, which have neither. - `version` (query, integer): Published scenario version the run used. - `draft_version` (query, integer): Draft scenario version the run used. - `scenario_sid` (query, string): Filter by the scenario recorded on the communication. - `agent_sid` (query, string) - `recipient` (query, string): Exact match on the whole recipient as the communication records it; a dispatched phone number is recorded in the stored form, digits only. Name `recipient` in `filter_or` to match a fragment of one. - `direction` (query, enum(inbound, outbound)) - `call_sid` (query, string) - `status` (query, enum(new, ready, dialing, in_progress, in_progress_offline, bounced, done, failed, drifted, stopped)) - `call_status` (query, enum(trying, ringing, answered, busy, rejected, no_answer, voicemail, incomplete, completed, failed, tech_canceled, abandoned)) - `automation_sid` (query, string): Narrows the list to the calls one automation produced. - `is_test` (query, boolean) - `created_at_from` (query, string (date-time)) - `created_at_to` (query, string (date-time)) - `duration_min` (query, integer): Shortest call duration to return, in seconds, inclusive. - `duration_max` (query, integer): Longest call duration to return, in seconds, inclusive. - `include` (query, string): Comma-separated related resources to resolve into `included`. Accepted: agent, scenario, communication_result, contact, automation, automation_attempt. - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `500`: Internal server error Response body (`200`): Content type `application/json`: - `items` (array of object, required) - `id` (string, required) - `account_sid` (string, required) - `agent_sid` (string, required) - `scenario_sid` (string, required): Names the scenario the communication runs. Empty on a call of an agent that is not dialled or answered yet: the agent's routings choose its scenario then. - `automation_sid` (string | null, required): Names the automation that produced this call. Empty for a call no automation placed. - `contact_sid` (string | null, required): Names the person this call is for. Empty where the other party could not be identified as a contact. - `version` (integer | null, required): Names the published scenario version; null when the run used a draft, and on a call of an agent that is not dialled or answered yet. - `draft_version` (integer | null, required): Names the draft scenario version; null when the run used a published version. At most one of version / draft_version is set. - `automation_attempt_sid` (string | null, required): Names the run within that automation. Empty for a call no run produced. - `recipient` (string, required) - `direction` (enum(inbound, outbound), required) - `communication_status` (enum(new, ready, dialing, in_progress, in_progress_offline, bounced, done, failed, drifted, stopped), required): Where the call stands. `stopped` is the one that is not an outcome: the call was asked for and never placed, because the work that asked for it was switched off first, so the person is still to reach. `in_progress_offline` is a call that has ended while its scenario still runs the bricks that need no call; the line is free, and the outcome follows when the scenario ends. - `call_status` (CallStatus | null, required) - `reason` (string, required): Explains why the communication reached its current status. Values: - `agent_at_capacity`: is a stable token for a call refused because the agent was at capacity. - `no_published_routing`: is a stable token for an outbound call through an agent that is not a test and found no routing with a published scenario. The call is `failed` and is not retried. - `no_number_to_dial_from`: is a stable token for a call with no number to dial from. The call is `failed` and is not retried. - Every other value is free text. Rules: - It is taken from the last status change that gave a reason. - A move to `ready` clears it. - `data` (object | null, required) - `variables` (object | null, required): Records the variables the call ended with; null until the call reaches a final status. `call.dialog-TEXT`, `call.dialog-BASE64` and the system variables of the last and the current brick (`last_question.*`, `last_webhook.*` and the other `last_.*` families, `current_brick.*`) are not kept. `contact` holds the contact's data as JSON text, the fields the call wrote included: `{{contact.first_name}}` in a brick is `first_name` inside it. - `communication_status_history` (array of object, required): Records every change of `communication_status`, oldest first. - `from` (enum(new, ready, dialing, in_progress, in_progress_offline, bounced, done, failed, drifted, stopped), required): Where the call stands. `stopped` is the one that is not an outcome: the call was asked for and never placed, because the work that asked for it was switched off first, so the person is still to reach. `in_progress_offline` is a call that has ended while its scenario still runs the bricks that need no call; the line is free, and the outcome follows when the scenario ends. - `to` (enum(new, ready, dialing, in_progress, in_progress_offline, bounced, done, failed, drifted, stopped), required): Where the call stands. `stopped` is the one that is not an outcome: the call was asked for and never placed, because the work that asked for it was switched off first, so the person is still to reach. `in_progress_offline` is a call that has ended while its scenario still runs the bricks that need no call; the line is free, and the outcome follows when the scenario ends. - `reason` (string) - `call_sid` (string) - `at` (string (date-time), required) - `call_status_history` (array of object, required): Records every change of `call_status`, oldest first; `[]` while the call has no telephony state. - `from` (CallStatus | null, required): Null on the first change, when the call had no telephony state yet. - `to` (enum(trying, ringing, answered, busy, rejected, no_answer, voicemail, incomplete, completed, failed, tech_canceled, abandoned), required): Reports the telephony state of the call. Values: - `trying`, `ringing` and `answered` are transient: the call is still running. - Every other value is final. - `abandoned`: is an inbound call the caller ended before it was answered. - `reason` (string): Explains why the call moved to this state; absent when the change had no reason. - `at` (string (date-time), required) - `scheduled_at` (string | null (date-time), required) - `timezone` (string, required): Names the IANA zone the calling window is read in: the agent's, else the account's. Rules: - The field is empty on an inbound call. - The field is empty when neither the agent nor the account names one. - When the field is empty, the window is read in UTC. - `next_call_at` (string (date-time), required): Records the earliest moment the dispatcher may place the call; the moment is a floor, not a schedule. Rules: - The moment is `scheduled_at` or the creation time. - After a bounce, the retry backoff sets the moment. - The call is never placed before this moment. - A call that is due outside the agent's calling window is moved to the window's next opening when it is claimed. - `call_attempt_number` (integer, required) - `executor_id` (string | null, required) - `call_sid` (string | null, required) - `duration` (integer, required): Reports the call duration between answer and hangup, in seconds; 0 until the call completes. - `is_test` (boolean, required): Says whether this is a test communication. - `prefer_draft` (boolean, required): Says whether the test call asked for the draft of its scenario first. `draft_version` says whether it played one. - `consent_granted` (boolean, required): Says whether personal-data recording consent was granted for the call. - `has_recording` (boolean, required): Says whether a stored call recording exists for this communication. - `has_call_history` (boolean, required): Says whether a saved call history exists for this communication: the document `GET /v1/a/communication/{id}/history` serves. - `number` (CommunicationNumber | null, required): Records the account's number the call went out from or came in on. A communication created before this field existed carries its agent's number from that time as a best guess. Null when: - The call is not placed or answered yet. - A communication created before this field existed has no agent. - `result_payload` (CommunicationResultPayload | null, required): Records the call's result, set once when the call reaches `done`, `failed` or `drifted`. Null when: - The call has not reached one of these statuses yet. - The call is `stopped`. - The call finished before this field existed. - `routing_sid` (string | null, required): Names the routing of the agent that chose the scenario of the call, the default routing included. Null when: - The call has no agent. - The call is a scenario test call. - The call of an agent is not dialled yet. - The call was placed before routing existed. - `routing_plan` (CommunicationRoutingPlan | null, required): Records how the agent's routings chose the scenario of the call. Null whenever `routing_sid` is null. - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) - `total` (integer (int64), required): Counts the communications matching the query, ignoring paging. - `limit` (integer, required): Reports the page size applied to this request. - `offset` (integer, required): Reports the offset applied to this request. - `has_more` (boolean, required): Says whether records beyond this page match the query. - `included` (object, required): Carries the related resources resolved for this response, one map per relation under the relation's name. Rules: - Each map is keyed by the related resource's own id (`included.agent[id]`). - A to-many relation is keyed the same way. - Each result delivery carries its `communication_sid`. - A relation's map is present whenever it was requested. - A map is empty if nothing resolved. - A reference the caller may not read is absent from the map, and the communication keeps its sid. - `agent` (object) - `scenario` (object) - `communication_result` (object) - `contact` (object): Resolves the contact each `contact_sid` names, in the list row shape. - `automation` (object): Resolves the automation each `automation_sid` names; a call placed by hand resolves nothing here. - `automation_attempt` (object): Resolves the run each `automation_attempt_sid` names; a call placed by hand resolves nothing here. ### Create communication (agent call or scenario test) `POST /v1/a/communication/-/dispatch` Operation id: `DispatchCommunication` Records the call and answers with the row in status `new`; the platform places it afterwards, so the outcome is read back from the row. Rules: - Exactly one of `agent_sid` and `scenario_sid` is given. - The recipient, in its stored form, is matched to the `number` of a contact of the account. - The answer names the contact in `contact_sid`. Effects: - When the account holds no such contact, one is created. - The contact stays when the call is deleted or never placed. Refused when: - A contact has to be created and the account already holds as many contacts as its limit allows. - A value of `contact.data` has another type than its field holds across the account's contacts. - The contact's data, with `contact.data` merged in, would be past a data limit of the account, data stored before the limit was lowered included. - A test call finds no free account number and its scenario has no agent that is not archived. Parameters: - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Request body: Content type `application/json`: - `recipient` (string, required): Names the person to call. Rules: - A value with a letter is an alphanumeric identifier, kept as sent. - Any other value is a phone number in the international form, with or without a leading `00`, recorded and dialled in the stored form of a contact's `number` (`37123112233`). - `agent_sid` (string): An agent of another account, or an archived one, is refused. - `automation_sid` (string): A dispatch that sends it is refused. - `scheduled_at` (string (date-time)) - `data` (object): Sets the variables of the call from a flat map of scalar values (string/number/boolean). Rules: - The map is not written onto the contact. - The keys `contact` and `contact.{path}` are accepted with any value and set nothing. - `contact` (object | null): Carries what the caller knows about the person the call is for. - `data` (object | null): Merges into the contact's data. Rules: - A key given here replaces the same key. - A nested object given here changes only the keys it names inside that object, at any depth. - Every other key stays. - A key set to `null` removes it. - Null, absent or `{}` leaves the data as it is. The call starts with the contact's data in the `contact` variable. - `scenario_sid` (string): Names the scenario to dial directly, for a test call. - `is_test` (boolean): Marks the call as a test call. Rules: - A test call through an agent takes every routing of the agent, a routing whose scenario has no published version included. - A call through an agent that is not a test passes over such a routing. When no routing with a published scenario holds, it fails with the reason `no_published_routing`. - A call through a test agent, a call with `prefer_draft`, and a call through `scenario_sid` are test calls. - `prefer_draft` (boolean): Makes a test call play the draft of its scenario first. Values: - `true`: plays the current draft, frozen on first use; the published version when the scenario has no draft. - Omitted: plays the published version; a test call through an agent plays the draft when the scenario has no published version. - `draft` (boolean): Means the same as `prefer_draft`. Responses: - `201`: Created - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `422`: Unprocessable - `500`: Internal server error Response body (`201`): Content type `application/json`: - `id` (string, required) - `account_sid` (string, required) - `agent_sid` (string, required) - `scenario_sid` (string, required): Names the scenario the communication runs. Empty on a call of an agent that is not dialled or answered yet: the agent's routings choose its scenario then. - `automation_sid` (string | null, required): Names the automation that produced this call. Empty for a call no automation placed. - `contact_sid` (string | null, required): Names the person this call is for. Empty where the other party could not be identified as a contact. - `version` (integer | null, required): Names the published scenario version; null when the run used a draft, and on a call of an agent that is not dialled or answered yet. - `draft_version` (integer | null, required): Names the draft scenario version; null when the run used a published version. At most one of version / draft_version is set. - `automation_attempt_sid` (string | null, required): Names the run within that automation. Empty for a call no run produced. - `recipient` (string, required) - `direction` (enum(inbound, outbound), required) - `communication_status` (enum(new, ready, dialing, in_progress, in_progress_offline, bounced, done, failed, drifted, stopped), required): Where the call stands. `stopped` is the one that is not an outcome: the call was asked for and never placed, because the work that asked for it was switched off first, so the person is still to reach. `in_progress_offline` is a call that has ended while its scenario still runs the bricks that need no call; the line is free, and the outcome follows when the scenario ends. - `call_status` (CallStatus | null, required) - `reason` (string, required): Explains why the communication reached its current status. Values: - `agent_at_capacity`: is a stable token for a call refused because the agent was at capacity. - `no_published_routing`: is a stable token for an outbound call through an agent that is not a test and found no routing with a published scenario. The call is `failed` and is not retried. - `no_number_to_dial_from`: is a stable token for a call with no number to dial from. The call is `failed` and is not retried. - Every other value is free text. Rules: - It is taken from the last status change that gave a reason. - A move to `ready` clears it. - `data` (object | null, required) - `variables` (object | null, required): Records the variables the call ended with; null until the call reaches a final status. `call.dialog-TEXT`, `call.dialog-BASE64` and the system variables of the last and the current brick (`last_question.*`, `last_webhook.*` and the other `last_.*` families, `current_brick.*`) are not kept. `contact` holds the contact's data as JSON text, the fields the call wrote included: `{{contact.first_name}}` in a brick is `first_name` inside it. - `communication_status_history` (array of object, required): Records every change of `communication_status`, oldest first. - `from` (enum(new, ready, dialing, in_progress, in_progress_offline, bounced, done, failed, drifted, stopped), required): Where the call stands. `stopped` is the one that is not an outcome: the call was asked for and never placed, because the work that asked for it was switched off first, so the person is still to reach. `in_progress_offline` is a call that has ended while its scenario still runs the bricks that need no call; the line is free, and the outcome follows when the scenario ends. - `to` (enum(new, ready, dialing, in_progress, in_progress_offline, bounced, done, failed, drifted, stopped), required): Where the call stands. `stopped` is the one that is not an outcome: the call was asked for and never placed, because the work that asked for it was switched off first, so the person is still to reach. `in_progress_offline` is a call that has ended while its scenario still runs the bricks that need no call; the line is free, and the outcome follows when the scenario ends. - `reason` (string) - `call_sid` (string) - `at` (string (date-time), required) - `call_status_history` (array of object, required): Records every change of `call_status`, oldest first; `[]` while the call has no telephony state. - `from` (CallStatus | null, required): Null on the first change, when the call had no telephony state yet. - `to` (enum(trying, ringing, answered, busy, rejected, no_answer, voicemail, incomplete, completed, failed, tech_canceled, abandoned), required): Reports the telephony state of the call. Values: - `trying`, `ringing` and `answered` are transient: the call is still running. - Every other value is final. - `abandoned`: is an inbound call the caller ended before it was answered. - `reason` (string): Explains why the call moved to this state; absent when the change had no reason. - `at` (string (date-time), required) - `scheduled_at` (string | null (date-time), required) - `timezone` (string, required): Names the IANA zone the calling window is read in: the agent's, else the account's. Rules: - The field is empty on an inbound call. - The field is empty when neither the agent nor the account names one. - When the field is empty, the window is read in UTC. - `next_call_at` (string (date-time), required): Records the earliest moment the dispatcher may place the call; the moment is a floor, not a schedule. Rules: - The moment is `scheduled_at` or the creation time. - After a bounce, the retry backoff sets the moment. - The call is never placed before this moment. - A call that is due outside the agent's calling window is moved to the window's next opening when it is claimed. - `call_attempt_number` (integer, required) - `executor_id` (string | null, required) - `call_sid` (string | null, required) - `duration` (integer, required): Reports the call duration between answer and hangup, in seconds; 0 until the call completes. - `is_test` (boolean, required): Says whether this is a test communication. - `prefer_draft` (boolean, required): Says whether the test call asked for the draft of its scenario first. `draft_version` says whether it played one. - `consent_granted` (boolean, required): Says whether personal-data recording consent was granted for the call. - `has_recording` (boolean, required): Says whether a stored call recording exists for this communication. - `has_call_history` (boolean, required): Says whether a saved call history exists for this communication: the document `GET /v1/a/communication/{id}/history` serves. - `number` (CommunicationNumber | null, required): Records the account's number the call went out from or came in on. A communication created before this field existed carries its agent's number from that time as a best guess. Null when: - The call is not placed or answered yet. - A communication created before this field existed has no agent. - `result_payload` (CommunicationResultPayload | null, required): Records the call's result, set once when the call reaches `done`, `failed` or `drifted`. Null when: - The call has not reached one of these statuses yet. - The call is `stopped`. - The call finished before this field existed. - `routing_sid` (string | null, required): Names the routing of the agent that chose the scenario of the call, the default routing included. Null when: - The call has no agent. - The call is a scenario test call. - The call of an agent is not dialled yet. - The call was placed before routing existed. - `routing_plan` (CommunicationRoutingPlan | null, required): Records how the agent's routings chose the scenario of the call. Null whenever `routing_sid` is null. - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) ### Get communication `GET /v1/a/communication/{id}` Operation id: `GetCommunication` Returns one call of the caller's account; a deleted one reads as absent. Rules: - The recording and the saved call history are not in the row: `has_recording` and `has_call_history` say whether their sub-resources will serve anything. - `include` resolves the agent, scenario, result deliveries, contact, automation and run into `included`, the same maps the list answers with. Parameters: - `id` (path, string, required) - `include` (query, string): Comma-separated related resources to resolve into `included`. Accepted: agent, scenario, communication_result, contact, automation, automation_attempt. - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `500`: Internal server error Response body (`200`): Content type `application/json`: - `id` (string, required) - `account_sid` (string, required) - `agent_sid` (string, required) - `scenario_sid` (string, required): Names the scenario the communication runs. Empty on a call of an agent that is not dialled or answered yet: the agent's routings choose its scenario then. - `automation_sid` (string | null, required): Names the automation that produced this call. Empty for a call no automation placed. - `contact_sid` (string | null, required): Names the person this call is for. Empty where the other party could not be identified as a contact. - `version` (integer | null, required): Names the published scenario version; null when the run used a draft, and on a call of an agent that is not dialled or answered yet. - `draft_version` (integer | null, required): Names the draft scenario version; null when the run used a published version. At most one of version / draft_version is set. - `automation_attempt_sid` (string | null, required): Names the run within that automation. Empty for a call no run produced. - `recipient` (string, required) - `direction` (enum(inbound, outbound), required) - `communication_status` (enum(new, ready, dialing, in_progress, in_progress_offline, bounced, done, failed, drifted, stopped), required): Where the call stands. `stopped` is the one that is not an outcome: the call was asked for and never placed, because the work that asked for it was switched off first, so the person is still to reach. `in_progress_offline` is a call that has ended while its scenario still runs the bricks that need no call; the line is free, and the outcome follows when the scenario ends. - `call_status` (CallStatus | null, required) - `reason` (string, required): Explains why the communication reached its current status. Values: - `agent_at_capacity`: is a stable token for a call refused because the agent was at capacity. - `no_published_routing`: is a stable token for an outbound call through an agent that is not a test and found no routing with a published scenario. The call is `failed` and is not retried. - `no_number_to_dial_from`: is a stable token for a call with no number to dial from. The call is `failed` and is not retried. - Every other value is free text. Rules: - It is taken from the last status change that gave a reason. - A move to `ready` clears it. - `data` (object | null, required) - `variables` (object | null, required): Records the variables the call ended with; null until the call reaches a final status. `call.dialog-TEXT`, `call.dialog-BASE64` and the system variables of the last and the current brick (`last_question.*`, `last_webhook.*` and the other `last_.*` families, `current_brick.*`) are not kept. `contact` holds the contact's data as JSON text, the fields the call wrote included: `{{contact.first_name}}` in a brick is `first_name` inside it. - `communication_status_history` (array of object, required): Records every change of `communication_status`, oldest first. - `from` (enum(new, ready, dialing, in_progress, in_progress_offline, bounced, done, failed, drifted, stopped), required): Where the call stands. `stopped` is the one that is not an outcome: the call was asked for and never placed, because the work that asked for it was switched off first, so the person is still to reach. `in_progress_offline` is a call that has ended while its scenario still runs the bricks that need no call; the line is free, and the outcome follows when the scenario ends. - `to` (enum(new, ready, dialing, in_progress, in_progress_offline, bounced, done, failed, drifted, stopped), required): Where the call stands. `stopped` is the one that is not an outcome: the call was asked for and never placed, because the work that asked for it was switched off first, so the person is still to reach. `in_progress_offline` is a call that has ended while its scenario still runs the bricks that need no call; the line is free, and the outcome follows when the scenario ends. - `reason` (string) - `call_sid` (string) - `at` (string (date-time), required) - `call_status_history` (array of object, required): Records every change of `call_status`, oldest first; `[]` while the call has no telephony state. - `from` (CallStatus | null, required): Null on the first change, when the call had no telephony state yet. - `to` (enum(trying, ringing, answered, busy, rejected, no_answer, voicemail, incomplete, completed, failed, tech_canceled, abandoned), required): Reports the telephony state of the call. Values: - `trying`, `ringing` and `answered` are transient: the call is still running. - Every other value is final. - `abandoned`: is an inbound call the caller ended before it was answered. - `reason` (string): Explains why the call moved to this state; absent when the change had no reason. - `at` (string (date-time), required) - `scheduled_at` (string | null (date-time), required) - `timezone` (string, required): Names the IANA zone the calling window is read in: the agent's, else the account's. Rules: - The field is empty on an inbound call. - The field is empty when neither the agent nor the account names one. - When the field is empty, the window is read in UTC. - `next_call_at` (string (date-time), required): Records the earliest moment the dispatcher may place the call; the moment is a floor, not a schedule. Rules: - The moment is `scheduled_at` or the creation time. - After a bounce, the retry backoff sets the moment. - The call is never placed before this moment. - A call that is due outside the agent's calling window is moved to the window's next opening when it is claimed. - `call_attempt_number` (integer, required) - `executor_id` (string | null, required) - `call_sid` (string | null, required) - `duration` (integer, required): Reports the call duration between answer and hangup, in seconds; 0 until the call completes. - `is_test` (boolean, required): Says whether this is a test communication. - `prefer_draft` (boolean, required): Says whether the test call asked for the draft of its scenario first. `draft_version` says whether it played one. - `consent_granted` (boolean, required): Says whether personal-data recording consent was granted for the call. - `has_recording` (boolean, required): Says whether a stored call recording exists for this communication. - `has_call_history` (boolean, required): Says whether a saved call history exists for this communication: the document `GET /v1/a/communication/{id}/history` serves. - `number` (CommunicationNumber | null, required): Records the account's number the call went out from or came in on. A communication created before this field existed carries its agent's number from that time as a best guess. Null when: - The call is not placed or answered yet. - A communication created before this field existed has no agent. - `result_payload` (CommunicationResultPayload | null, required): Records the call's result, set once when the call reaches `done`, `failed` or `drifted`. Null when: - The call has not reached one of these statuses yet. - The call is `stopped`. - The call finished before this field existed. - `routing_sid` (string | null, required): Names the routing of the agent that chose the scenario of the call, the default routing included. Null when: - The call has no agent. - The call is a scenario test call. - The call of an agent is not dialled yet. - The call was placed before routing existed. - `routing_plan` (CommunicationRoutingPlan | null, required): Records how the agent's routings chose the scenario of the call. Null whenever `routing_sid` is null. - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) - `included` (object, required): Carries the related resources resolved for this response, one map per relation under the relation's name. Rules: - Each map is keyed by the related resource's own id (`included.agent[id]`). - A to-many relation is keyed the same way. - Each result delivery carries its `communication_sid`. - A relation's map is present whenever it was requested. - A map is empty if nothing resolved. - A reference the caller may not read is absent from the map, and the communication keeps its sid. - `agent` (object) - `scenario` (object) - `communication_result` (object) - `contact` (object): Resolves the contact each `contact_sid` names, in the list row shape. - `automation` (object): Resolves the automation each `automation_sid` names; a call placed by hand resolves nothing here. - `automation_attempt` (object): Resolves the run each `automation_attempt_sid` names; a call placed by hand resolves nothing here. ### Delete communication `DELETE /v1/a/communication/{id}` Operation id: `DeleteCommunication` Removes the communication from every list and read, except the communication list with `show_deleted=true`, and from the figures of the automation that placed it. The record is kept until its retention period ends, so an outcome that arrives afterwards still lands on it; a second delete finds nothing. `hard=true` erases the record instead, and takes no exceptions: it is what a caller reaches for once the ordinary delete has refused, since a call recorded as running when it is merely stuck otherwise leaves the record, and the account holding it, undeletable. The data of the communication is erased with the record; a part that could not be erased at that moment stays. An outcome arriving afterwards has nowhere to land. Parameters: - `id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. - `hard` (query, boolean): Erases the record rather than marking it deleted. Responses: - `204`: Deleted - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `409`: Conflict - `500`: Internal server error ### Get call history (proxied or presigned link) `GET /v1/a/communication/{id}/history` Operation id: `GetCommunicationHistory` Serves the saved call history of the call. By mode: - `mode=proxy`: is the default and streams the JSON itself. - `mode=url`: answers with a time-bounded presigned link instead. A call with no stored history has nothing to serve. Parameters: - `id` (path, string, required) - `mode` (query, string): Selects how the call history is returned; the default is `proxy`. Values: - `proxy`: streams the history JSON in the response body. - `url`: returns a presigned download link instead. - `expire` (query, integer): Sets the presigned link lifetime in seconds. Rules: - It applies in url mode only. - The default is 3600 (1h). - Anything outside 1 to 604800 (7d) is refused. - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: Returns what the mode asks for. By mode: - `url`: returns a presigned link. - `proxy`: returns the raw call-history JSON. - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `500`: Internal server error Response body (`200`): Content type `application/json`: - `signed_url` (string, required) - `expires_at` (string (date-time), required) ### Stream the call history events of a call (WebSocket) `GET /v1/a/communication/{id}/events` Operation id: `StreamCommunicationEvents` Opens a WebSocket that carries the call history events of the call, one event in each text frame. Rules: - While the call runs, a client first receives the events the call already produced, up to the first 1000, and then each new event as it happens. - The stream of a running call can leave an event out; a gap in `seq` shows it. - After the call, every stored event of the call is sent in `seq` order. - A call that has not started to dial has nothing to stream. - A finished call with no stored events has nothing to stream either: one that produced none, or one whose events are still being stored after its end. The connection: - It closes with the normal close code when the events end, and with an error close code when the stream breaks. - A connection that ends without the normal close code was lost. - A new connection sends the events from the first one again, and `seq` identifies the events a client already holds. Parameters: - `id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `101`: The connection is a WebSocket now; each text frame is one call history event. - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `500`: Internal server error ### Get call recording (proxied or presigned link) `GET /v1/a/communication/{id}/recording` Operation id: `GetCommunicationRecording` Serves the call's recording. By mode: - `mode=proxy`: is the default and streams the audio itself. - `mode=url`: answers with a time-bounded presigned link instead. A call with no recording has nothing to serve. Parameters: - `id` (path, string, required) - `mode` (query, string): Selects how the call history is returned; the default is `proxy`. Values: - `proxy`: streams the history JSON in the response body. - `url`: returns a presigned download link instead. - `expire` (query, integer): Sets the presigned link lifetime in seconds. Rules: - It applies in url mode only. - The default is 3600 (1h). - Anything outside 1 to 604800 (7d) is refused. - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: Returns what the mode asks for. By mode: - `url`: returns a presigned link. - `proxy`: returns the raw recording audio. - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `500`: Internal server error Response body (`200`): Content type `application/json`: - `signed_url` (string, required) - `expires_at` (string (date-time), required) ### Get speech recording (proxied or presigned link) `GET /v1/a/communication/{id}/speech-recording` Operation id: `GetCommunicationSpeechRecording` Serves one recognition recording of the call, located by the `path` a saved-history entry carries. By mode: - `mode=proxy`: is the default and streams the audio itself. - `mode=url`: answers with a time-bounded presigned link instead. Parameters: - `id` (path, string, required) - `path` (query, string, required): Names the recording by the storage reference the saved call history carries in `speech_recognition_recording`. Rules: - The reference is a `gs://` URI. - For a history saved before the URI form, the reference is a bucket-qualified path. Refused when: - The reference is unknown. - The reference is malformed. - The reference is out of scope. - `mode` (query, string): Selects how the call history is returned; the default is `proxy`. Values: - `proxy`: streams the history JSON in the response body. - `url`: returns a presigned download link instead. - `expire` (query, integer): Sets the presigned link lifetime in seconds. Rules: - It applies in url mode only. - The default is 3600 (1h). - Anything outside 1 to 604800 (7d) is refused. - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: Returns what the mode asks for. By mode: - `url`: returns a presigned link. - `proxy`: returns the raw recording audio. - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `500`: Internal server error Response body (`200`): Content type `application/json`: - `signed_url` (string, required) - `expires_at` (string (date-time), required) ### Count calls `GET /v1/a/analytics/call` Operation id: `GetCallAnalytics` Counts the account's calls over one period, cut into buckets in the account's time zone. By period: - `today`: has one bucket per hour from midnight. - `30d`: has one bucket per day over today and the 29 days before it. - `12m`: has one bucket per month over the current month and the 11 before it. Rules: - The buckets end with the one that holds the current time. - A bucket with no calls carries zeros. - A call whose communication was erased is not counted. - Test calls are left out unless `is_test=true`. - `group_by=agent`: fills `by_agent` in every bucket and returns those agents in `included.agents`; a call with no agent counts in its bucket and in `totals` only. - `group_by=routing`: fills `by_routing` in every bucket and returns those routings in `included.routings`; a call no routing chose counts in its bucket and in `totals` only. - `agent_sid`: counts one agent's calls. Refused when `agent_sid` names an agent outside the account; it is answered as not found. Parameters: - `period` (query, enum(today, 30d, 12m), required): Sets the period the counts cover. Values: - `today`: counts by hour. - `30d`: counts by day. - `12m`: counts by month. - `group_by` (query, enum(agent, routing)): Splits every bucket. Values: - `agent`: splits by agent. - `routing`: splits by the routing that chose the scenario of the call. - `agent_sid` (query, string): Narrows the counts to one agent of the account. - `is_test` (query, boolean): true counts test calls instead of customer calls. - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `500`: Internal server error Response body (`200`): Content type `application/json`: - `period` (object, required) - `from` (string (date-time), required): Marks the start of the first bucket. - `to` (string (date-time), required): Marks the end of the bucket that holds the current time. - `timezone` (string, required): Names the IANA zone the buckets are cut in: the account's, or Europe/Warsaw when it has none. - `interval` (enum(hour, day, month), required) - `totals` (object, required) - `total` (integer (int64), required) - `outbound` (integer (int64), required) - `inbound` (integer (int64), required) - `call_duration` (integer (int64), required): Seconds, summed over the calls. - `call_duration_excluding_transfer` (integer (int64), required): Seconds, summed over the calls, without the time spent on a transferred leg. - `buckets` (array of any, required) - `total` (integer (int64), required) - `outbound` (integer (int64), required) - `inbound` (integer (int64), required) - `call_duration` (integer (int64), required): Seconds, summed over the calls. - `call_duration_excluding_transfer` (integer (int64), required): Seconds, summed over the calls, without the time spent on a transferred leg. - `start` (string (date-time), required) - `by_agent` (object | null, required): Counts per agent id; null unless group_by=agent. A call with no agent is absent here. - `by_routing` (object | null, required): Counts per routing id; null unless group_by=routing. A call no routing chose is absent here. - `included` (CallAnalyticsIncluded | null, required): null unless group_by is set. ### Read lines in use `GET /v1/a/analytics/lines` Operation id: `GetLineAnalytics` Reads the account's lines at this moment: the lines the account may use, the lines given to its agents, and the calls held now. Rules: - A call is held from the moment it is dialled or answered until it ends. - Answered and placed calls count together. - A test call is counted like any call. The figures: - Every agent of the account that is not archived is listed with its own figures. - `lines_assigned` is the sum over the agents. - `lines_in_use` counts every call the account holds, a call with no agent included, so it can be above the sum over the agents. Parameters: - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `500`: Internal server error Response body (`200`): Content type `application/json`: - `account_lines` (integer, required): Calls the account may hold at once across its agents. - `lines_assigned` (integer, required): Sums the lines over agents. - `lines_in_use` (integer, required): Counts the calls the account holds now, a call with no agent included. - `agents` (array of object, required): Lists every agent of the account that is not archived, newest first. - `agent_sid` (string, required) - `lines` (integer, required): Calls this agent may hold at once. - `lines_in_use` (integer, required): Calls this agent holds now, answered and placed together. ### Read the account's use of its contact limits `GET /v1/a/analytics/contacts` Operation id: `GetContactAnalytics` Reads how much of its contact limits the account uses: its contacts against the contact limit, the data fields its contacts hold, and the bytes of all their data. Rules: - The contacts and the fields are counted at the moment of the read. - The bytes are summed every 15 minutes. Parameters: - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `500`: Internal server error Response body (`200`): Content type `application/json`: - `contacts` (object, required) - `current` (integer, required): Counts the account's contacts. - `limit` (integer, required): Reports the account's contact limit. - `fields` (array of object, required): Lists every data field the account's contacts hold, by name. - `name` (string, required): Names the field by its dotted path. - `type` (enum(string, number, boolean, array), required): Names the one type every contact of the account holds at the field. - `contacts` (integer, required): Counts the contacts that hold the field. - `data_bytes` (object, required) - `total` (integer (int64), required): Sums the bytes of every value of the contacts' data, each array item on its own. - `computed_at` (string | null (date-time), required): Records when the total was summed, at most 15 minutes before; null until the first sum, while total is 0. ### List result deliveries `GET /v1/a/communication-result` Operation id: `ListResultDeliveries` Lists the result deliveries, which appear on their own. Rules: - One delivery is filed per distinct target configured on the call's agent. - A delivery is filed when the call reaches a terminal status. - This API creates none and deletes none. Rows carry the attempt count and the full attempt history, here as much as in the single read. Parameters: - `limit` (query, integer (int64)): Page size, max 500 (default 100). - `offset` (query, integer (int64)) - `status` (query, enum(new, in_progress, delivered, undelivered, failed)) - `communication_sid` (query, string) - `include` (query, string): Comma-separated related resources to resolve into `included`. Accepted: communication. - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `500`: Internal server error Response body (`200`): Content type `application/json`: - `items` (array of object, required) - `id` (string, required) - `communication_sid` (string, required) - `account_sid` (string, required) - `target_url` (string, required) - `status` (enum(new, in_progress, delivered, undelivered, failed), required) - `attempts` (integer, required) - `next_attempt_at` (string (date-time), required) - `status_changed_at` (string (date-time), required) - `last_error` (string, required) - `last_response_status` (integer | null, required) - `history` (array | null, required) - `delivered_at` (string | null (date-time), required) - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) - `total` (integer (int64), required): Counts the result deliveries matching the query, ignoring paging. - `limit` (integer, required): Reports the page size applied to this request. - `offset` (integer, required): Reports the offset applied to this request. - `has_more` (boolean, required): Says whether records beyond this page match the query. - `included` (object, required): Carries the related resources resolved for this response, one map per relation under the relation's name. Rules: - Each map is keyed by the related resource's own id (`included.communication[id]`). - A relation's map is present whenever it was requested. - A map is empty if nothing resolved. - A reference the caller may not read is absent from the map, and the delivery keeps its sid. - `communication` (object) ### Get result delivery `GET /v1/a/communication-result/{id}` Operation id: `GetCommunicationResult` The target receives the call's `result_payload`; `include=communication` resolves the call into `included`, the same map the list answers with. Parameters: - `id` (path, string, required) - `include` (query, string): Comma-separated related resources to resolve into `included`. Accepted: communication. - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `500`: Internal server error Response body (`200`): Content type `application/json`: - `id` (string, required) - `communication_sid` (string, required) - `account_sid` (string, required) - `target_url` (string, required) - `status` (enum(new, in_progress, delivered, undelivered, failed), required) - `attempts` (integer, required) - `next_attempt_at` (string (date-time), required) - `status_changed_at` (string (date-time), required) - `last_error` (string, required) - `last_response_status` (integer | null, required) - `history` (array | null, required) - `delivered_at` (string | null (date-time), required) - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) - `included` (object, required): Carries the related resources resolved for this response, one map per relation under the relation's name. Rules: - Each map is keyed by the related resource's own id (`included.communication[id]`). - A relation's map is present whenever it was requested. - A map is empty if nothing resolved. - A reference the caller may not read is absent from the map, and the delivery keeps its sid. - `communication` (object) ### Update result delivery `PATCH /v1/a/communication-result/{id}` Operation id: `PatchCommunicationResult` Edits the target; status, attempts and history stay system-managed. Parameters: - `id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Request body: Content type `application/json`: - `target_url` (string) Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `409`: Conflict - `500`: Internal server error Response body (`200`): Content type `application/json`: - `id` (string, required) - `communication_sid` (string, required) - `account_sid` (string, required) - `target_url` (string, required) - `status` (enum(new, in_progress, delivered, undelivered, failed), required) - `attempts` (integer, required) - `next_attempt_at` (string (date-time), required) - `status_changed_at` (string (date-time), required) - `last_error` (string, required) - `last_response_status` (integer | null, required) - `history` (array | null, required) - `delivered_at` (string | null (date-time), required) - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) ### Resend result delivery `POST /v1/a/communication-result/{id}/resend` Operation id: `ResendCommunicationResult` Resets the delivery whatever its current status: its status goes back to new and its attempt counters are cleared. The history survives, and the next delivery run picks the delivery up. Parameters: - `id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `500`: Internal server error Response body (`200`): Content type `application/json`: - `id` (string, required) - `communication_sid` (string, required) - `account_sid` (string, required) - `target_url` (string, required) - `status` (enum(new, in_progress, delivered, undelivered, failed), required) - `attempts` (integer, required) - `next_attempt_at` (string (date-time), required) - `status_changed_at` (string (date-time), required) - `last_error` (string, required) - `last_response_status` (integer | null, required) - `history` (array | null, required) - `delivered_at` (string | null (date-time), required) - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) ### List contacts `GET /v1/a/contact` Operation id: `ListContacts` Lists the contacts; rows carry no `communication_history`, so read one contact for it. The `include` values: - `segment`: resolves the segments the page's contacts are in into `included`. - `segment_membership`: resolves into `included`, per contact, when it joined each segment, which source put it there and when it left. - `source`: resolves the sources those memberships name into `included`, with their `kind` and `filename`. Parameters: - `limit` (query, integer): Page size, max 500 (default 100). - `offset` (query, integer) - `filter_or` (query, string): Comma-separated field names to OR-search via filter_query. Accepted: number (substring, case-insensitive). - `filter_query` (query, string): Search term matched across the fields named in filter_or. - `query` (query, string): Narrows the set to the contacts an expression matches, for example `data.city = "Riga" AND last_call_at > 2026-10-01`. The expression: - A data field is written as `data.`, a nested one as `data.address.street`. - `id`, `number`, `created_at`, `updated_at` and `last_call_at` are written bare. - Comparisons are `=`, `!=`, `<`, `<=`, `>`, `>=`, `IN` and `NOT IN`, joined by `AND` and `OR` and grouped by parentheses. - `IN` takes a list of values in parentheses, `data.city IN ("Riga", "Tallinn")`, and matches when the field equals one of them. - `NOT IN` matches when the field equals none of them. - An `IN` or `NOT IN` list counts as one comparison. - A value is a number, `true` or `false`, a string in double quotes, a date `2026-10-01`, a time `18:00`, or a datetime in quotes `"2026-10-01 18:00"`. Rules: - Strings compare case-sensitively, byte by byte. - A date, a time and a datetime without an offset are read in the account's timezone. - A data value is cast to the type of the value it is compared with, as JavaScript casts it. - A value that does not cast, an object and an array never match. - A data field a contact lacks, and `last_call_at` of a contact never called, read as the zero value of the type. - The expression applies together with every other filter. - An expression holds at most 10 comparisons and 2000 characters. Refused when: - A `data.` names a field no contact of the account holds. - A `data.` names a field that holds fields of its own, such as `data.address` when contacts hold `data.address.street`. - `order_by` (query, string): Sort field. Accepted: created_at, number (default created_at). - `order` (query, string): Sort direction: asc | desc (default desc). - `include` (query, string): Comma-separated related resources to resolve into `included`. Accepted: segment, segment_membership, source. - `segment_ids` (query, string): Narrows the set to the contacts in the given segments, named by comma-separated segment ids. Rules: - A contact in any of them qualifies. - Naming the account's default segment matches every contact it holds. - An id naming no segment matches nothing rather than failing. - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `500`: Internal server error Response body (`200`): Content type `application/json`: - `items` (array of object, required) - `id` (string, required) - `account_sid` (string, required): Names the account that owns the contact. - `number` (string, required): Identifies the contact within the account, in the stored form. By type: - A phone number is stored as its country calling code followed by the national number, digits only (`37123112233`). - A SIP identifier is stored as it was sent. - `type` (IdentifierType | null, required): The identifier type the stored value was read as; `null` where the platform holds none. - `country_code` (string | null, required): Records the country the stored number belongs to, ISO 3166-1 alpha-2, lowercase. Null when: - The identifier is alphanumeric. - The number is outside any country's range. - The platform holds no country for the number. - `data` (object, required): Holds everything the account has on the person; `{}` when nothing is held. - `revision` (string, required): Hash of the contact's current `number`, `type`, `country_code` and `data`. An edit sends it back to prevent a lost update under concurrent writes. - `segment_sids` (array of string, required): Lists the account's segments this contact is currently in, its default segment included. - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) - `total` (integer (int64), required): Counts the contacts matching the query, ignoring paging. - `limit` (integer, required): Reports the page size applied to this request. - `offset` (integer, required): Reports the offset applied to this request. - `has_more` (boolean, required): Says whether records beyond this page match the query. - `included` (object, required): Carries the related resources resolved for this response, one map per relation under the relation's name. The relations: - `segment`: is keyed by the segment's own id (`included.segment[id]`), one entry for every id in a contact's `segment_sids`. - `segment_membership`: has no id of its own and is keyed by the contact's id (`included.segment_membership[contact_id]`), holding every membership the contact has had, newest first. - `source`: is keyed by the source's own id, one entry for each `source_sid` those memberships name; a membership with no `source_sid` resolves nothing. A relation's map is present whenever it was requested, empty if nothing resolved. - `segment` (object) - `segment_membership` (object) - `source` (object) ### Create contact `POST /v1/a/contact` Operation id: `CreateContact` Stores the contact with its number in the stored form. Rules: - `+371 23-11-22-33`, `0037123112233` and `37123112233` all store as `37123112233`. - `0501111222` with `country_code` `pl` stores as `48501111222`. - A number without an international mark and without a `country_code` is taken as international without the sign. - A person the account has is changed by id, never created again. Refused when: - The account holds as many contacts as its limit allows. - A `data` value has another type than its field holds across the account's contacts. Parameters: - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Request body: Content type `application/json`: - `number` (string, required): Identifies the contact, read by `type` and `country_code`. A phone number arrives with or without an international mark (`+` or `00`), loses its spaces and punctuation, and is stored as `37123112233`. Refused when: - The number cannot be brought to that form. - The account already holds the number. - `type` (enum(number, alphanumeric)): Declares what an identifier is. Values: - `number`: is a phone number, brought to the stored form before it is kept or compared. - `alphanumeric`: is a SIP identifier, kept as sent and checked only to start with a letter or a digit. A request that omits it means `number`, and a value outside the two is refused. - `country_code` (string): Supplies the country for a phone number that arrives without an international mark (`+` or `00`): `0501111222` with `pl` stores as `48501111222`. Rules: - It is an ISO 3166-1 alpha-2 code, in upper or lower case, from `GET /v1/a/info/countries`. - A number already in the international form ignores it. Refused when: - The code is unknown. - The code is sent with type `alphanumeric`. - `data` (object): Sets what the account holds on the person. Rules: - A field set to `null` is not stored. - Omitted means `{}`. Responses: - `201`: Created - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `422`: Unprocessable - `500`: Internal server error Response body (`201`): Content type `application/json`: - `id` (string, required) - `account_sid` (string, required): Names the account that owns the contact. - `number` (string, required): Identifies the contact within the account, in the stored form. By type: - A phone number is stored as its country calling code followed by the national number, digits only (`37123112233`). - A SIP identifier is stored as it was sent. - `type` (IdentifierType | null, required): The identifier type the stored value was read as; `null` where the platform holds none. - `country_code` (string | null, required): Records the country the stored number belongs to, ISO 3166-1 alpha-2, lowercase. Null when: - The identifier is alphanumeric. - The number is outside any country's range. - The platform holds no country for the number. - `data` (object, required): Holds everything the account has on the person; `{}` when nothing is held. - `data_usage` (object, required): Reports how much of the account's limits the contact's data takes, counted the way the limits count it. - `fields` (object, required) - `current` (integer, required): Counts the fields of the data, at any depth, an array as one field. - `limit` (integer, required): Reports the account's field limit. - `value_bytes` (integer, required): Reports the account's byte limit for one value and for each item of an array. - `array_items` (integer, required): Reports the account's limit for the items of one array. - `values` (array of object, required): Lists every field of the data by its dotted path, in path order. - `field` (string, required): Names the field by its dotted path. - `bytes` (integer, required): Counts the bytes of the value's text; for an array, those of its longest item. - `items` (integer): Counts the items of an array; absent for any other value. - `revision` (string, required): Hash of the contact's current `number`, `type`, `country_code` and `data`. An edit sends it back to prevent a lost update under concurrent writes. - `communication_history` (array of object, required): Lists the last 50 finished calls with the person. Rules: - The newest call comes first. - A deleted communication is not listed. - The list is `[]` when there is none. A call receives the same list at its start as the read-only `communication_history` system variable. - `communication_sid` (string, required): Names the communication that holds the full record of the call. - `direction` (enum(inbound, outbound), required) - `communication_status` (enum(new, ready, dialing, in_progress, in_progress_offline, bounced, done, failed, drifted, stopped), required): Where the call stands. `stopped` is the one that is not an outcome: the call was asked for and never placed, because the work that asked for it was switched off first, so the person is still to reach. `in_progress_offline` is a call that has ended while its scenario still runs the bricks that need no call; the line is free, and the outcome follows when the scenario ends. - `call_status` (CallStatus | null, required): `null` for a call that recorded no telephony state. - `reason` (string, required): Explains why the call ended in its status; empty when no reason was recorded. - `duration` (integer, required): Reports the call duration between answer and hangup, in seconds; 0 for a call that was not answered or never placed. - `scenario_sid` (string, required): Names the scenario the call ran; empty for a call that records no scenario. - `agent_sid` (string, required): Names the agent the call ran through; empty for a call with no agent. - `automation_sid` (string | null, required): Names the automation that placed the call; `null` for a call no automation placed. - `occurred_at` (string (date-time), required): Records when the call reached its final status. - `segment_sids` (array of string, required): Lists the account's segments this contact is currently in, its default segment included. - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) ### Rename or remove a data field on every contact `POST /v1/a/contact/-/data` Operation id: `ChangeContactDataField` Renames or removes one data field on every contact of the account that holds it, in one step. Refused when: - A rename finds a contact that holds a field at the new path, under it or on the way to it. No contact changes, the refusal names one such field, and the rename goes through once no contact holds any of them. - A removal names a field that the condition of a routing reads, or a field above one it reads, and the agent of that routing is not archived. No contact changes, and the refusal names the routings. Effects: - A rename rewrites every routing condition of the account that reads the field. - Scenarios that read the old field are not changed. Parameters: - `op` (query, enum(rename, delete), required): Selects whether the request renames or removes. - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Request body: Content type `application/json`: - `from` (string): Names the field to move. - `to` (string): Names where the field moves. - `field` (string): Names the field to remove. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `409`: Conflict - `422`: Unprocessable - `500`: Internal server error Response body (`200`): Content type `application/json`: - `updated` (integer, required): Counts the contacts that held the field and changed. ### List the fields and operators a query can use `GET /v1/a/contact/-/query-language` Operation id: `GetContactQueryLanguage` Lists what `query` on `GET /v1/a/contact` and on the export can name: the contact's own fields, every data field a contact of the account holds with the type it holds there, and the comparison operators. A data field leaves the list when no contact holds it any more. Parameters: - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `500`: Internal server error Response body (`200`): Content type `application/json`: - `fields` (array of object, required): Lists the contact's own fields first, then the data fields by name. - `name` (string, required): Names the field as a query writes it, `number` or `data.address.street`. - `type` (enum(string, number, boolean, array, datetime), required): Names the one type every contact of the account holds at the field. - `operators` (array of enum(=, !=, <, <=, >, >=, IN, NOT IN), required): Lists the comparison operators. ### Export contacts `POST /v1/a/contact/-/export` Operation id: `ExportContacts` Starts a job that writes every contact the selection matches to one csv file, and answers with the job in status `queued`. The selection is the list's own: `segment_ids`, `filter_or` + `filter_query`, `query` and `order_by` + `order` apply exactly as on `GET /v1/a/contact`. The file: - It is UTF-8 csv (RFC 4180). - The number is always the first column; `fields` orders the rest. - `data` unpacks at its position into one column per top-level key. - The header is the union of keys across the set, ordered by name. - A scalar is written as it is, a nested value as its JSON text, a key that is missing or `null` as an empty cell. - A data key or a data cell that begins with `=`, `+`, `-`, `@`, a tab or a carriage return, or with apostrophes before one of them, is written with one more leading apostrophe, so a spreadsheet does not read it as a formula. - The apostrophe stays visible in the cell, and it is removed when the file is supplied to a segment's source. Poll `GET /v1/a/contact/-/export/{id}` for the download link. Parameters: - `format` (query, string): File format. Accepted: csv (default). Any other value is refused. - `fields` (query, string): Lists the columns that follow the number, comma-separated, in the order given; the default is `number,data`. The accepted names are `id`, `number`, `data`, `created_at` and `updated_at`. Refused when: - A name is not on the list. - A name is repeated. - `segment_ids` (query, string): Narrows the set to the contacts in the given segments, named by comma-separated segment ids. Rules: - A contact in any of them qualifies. - Naming the account's default segment matches every contact it holds. - An id naming no segment matches nothing rather than failing. - `filter_or` (query, string): Comma-separated field names to OR-search via filter_query. Accepted: number (substring, case-insensitive). - `filter_query` (query, string): Search term matched across the fields named in filter_or. - `query` (query, string): Narrows the set to the contacts an expression matches, for example `data.city = "Riga" AND last_call_at > 2026-10-01`. The expression: - A data field is written as `data.`, a nested one as `data.address.street`. - `id`, `number`, `created_at`, `updated_at` and `last_call_at` are written bare. - Comparisons are `=`, `!=`, `<`, `<=`, `>`, `>=`, `IN` and `NOT IN`, joined by `AND` and `OR` and grouped by parentheses. - `IN` takes a list of values in parentheses, `data.city IN ("Riga", "Tallinn")`, and matches when the field equals one of them. - `NOT IN` matches when the field equals none of them. - An `IN` or `NOT IN` list counts as one comparison. - A value is a number, `true` or `false`, a string in double quotes, a date `2026-10-01`, a time `18:00`, or a datetime in quotes `"2026-10-01 18:00"`. Rules: - Strings compare case-sensitively, byte by byte. - A date, a time and a datetime without an offset are read in the account's timezone. - A data value is cast to the type of the value it is compared with, as JavaScript casts it. - A value that does not cast, an object and an array never match. - A data field a contact lacks, and `last_call_at` of a contact never called, read as the zero value of the type. - The expression applies together with every other filter. - An expression holds at most 10 comparisons and 2000 characters. Refused when: - A `data.` names a field no contact of the account holds. - A `data.` names a field that holds fields of its own, such as `data.address` when contacts hold `data.address.street`. - `order_by` (query, string): Sort field. Accepted: created_at, number (default created_at). - `order` (query, string): Sort direction: asc | desc (default desc). - `limit` (query, integer): Accepted and ignored: an export is always the whole matching set. - `offset` (query, integer): Accepted and ignored: an export is always the whole matching set. - `include` (query, string): Accepted and ignored: the file carries contacts only. - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `202`: Accepted - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `500`: Internal server error Response body (`202`): Content type `application/json`: - `id` (string, required) - `status` (enum(queued, running, completed, failed), required): Records the state of the job. Values: - `queued`: waits to run. - `running`: writes the file. - `completed`: carries `url`. - `failed`: carries `error`. - `created_at` (string (date-time), required) - `finished_at` (string | null (date-time), required): Records when the job completed or failed; `null` before that. - `url` (string, required): Points at the csv file with a signed download link, valid for 7 days; empty until the job completes. - `expires_at` (string | null (date-time), required): Records when `url` stops working; `null` until the job completes. - `error` (string, required): Says why the job failed; empty otherwise. ### Get export job `GET /v1/a/contact/-/export/{id}` Operation id: `GetContactExport` The job's current state. A job stays readable for 7 days after it finishes. Parameters: - `id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `500`: Internal server error Response body (`200`): Content type `application/json`: - `id` (string, required) - `status` (enum(queued, running, completed, failed), required): Records the state of the job. Values: - `queued`: waits to run. - `running`: writes the file. - `completed`: carries `url`. - `failed`: carries `error`. - `created_at` (string (date-time), required) - `finished_at` (string | null (date-time), required): Records when the job completed or failed; `null` before that. - `url` (string, required): Points at the csv file with a signed download link, valid for 7 days; empty until the job completes. - `expires_at` (string | null (date-time), required): Records when `url` stops working; `null` until the job completes. - `error` (string, required): Says why the job failed; empty otherwise. ### Get contact `GET /v1/a/contact/{id}` Operation id: `GetContact` Returns the whole contact, its call log included. The `include` values: - `segment`: resolves the segments in its `segment_sids` into `included`. - `segment_membership`: resolves into `included` every segment it is or has been in, with when it joined, which source put it there and when it left. - `source`: resolves the sources those memberships name into `included`. These are the same maps the list answers with. Parameters: - `id` (path, string, required) - `include` (query, string): Comma-separated related resources to resolve into `included`. Accepted: segment, segment_membership, source. - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `500`: Internal server error Response body (`200`): Content type `application/json`: - `id` (string, required) - `account_sid` (string, required): Names the account that owns the contact. - `number` (string, required): Identifies the contact within the account, in the stored form. By type: - A phone number is stored as its country calling code followed by the national number, digits only (`37123112233`). - A SIP identifier is stored as it was sent. - `type` (IdentifierType | null, required): The identifier type the stored value was read as; `null` where the platform holds none. - `country_code` (string | null, required): Records the country the stored number belongs to, ISO 3166-1 alpha-2, lowercase. Null when: - The identifier is alphanumeric. - The number is outside any country's range. - The platform holds no country for the number. - `data` (object, required): Holds everything the account has on the person; `{}` when nothing is held. - `data_usage` (object, required): Reports how much of the account's limits the contact's data takes, counted the way the limits count it. - `fields` (object, required) - `current` (integer, required): Counts the fields of the data, at any depth, an array as one field. - `limit` (integer, required): Reports the account's field limit. - `value_bytes` (integer, required): Reports the account's byte limit for one value and for each item of an array. - `array_items` (integer, required): Reports the account's limit for the items of one array. - `values` (array of object, required): Lists every field of the data by its dotted path, in path order. - `field` (string, required): Names the field by its dotted path. - `bytes` (integer, required): Counts the bytes of the value's text; for an array, those of its longest item. - `items` (integer): Counts the items of an array; absent for any other value. - `revision` (string, required): Hash of the contact's current `number`, `type`, `country_code` and `data`. An edit sends it back to prevent a lost update under concurrent writes. - `communication_history` (array of object, required): Lists the last 50 finished calls with the person. Rules: - The newest call comes first. - A deleted communication is not listed. - The list is `[]` when there is none. A call receives the same list at its start as the read-only `communication_history` system variable. - `communication_sid` (string, required): Names the communication that holds the full record of the call. - `direction` (enum(inbound, outbound), required) - `communication_status` (enum(new, ready, dialing, in_progress, in_progress_offline, bounced, done, failed, drifted, stopped), required): Where the call stands. `stopped` is the one that is not an outcome: the call was asked for and never placed, because the work that asked for it was switched off first, so the person is still to reach. `in_progress_offline` is a call that has ended while its scenario still runs the bricks that need no call; the line is free, and the outcome follows when the scenario ends. - `call_status` (CallStatus | null, required): `null` for a call that recorded no telephony state. - `reason` (string, required): Explains why the call ended in its status; empty when no reason was recorded. - `duration` (integer, required): Reports the call duration between answer and hangup, in seconds; 0 for a call that was not answered or never placed. - `scenario_sid` (string, required): Names the scenario the call ran; empty for a call that records no scenario. - `agent_sid` (string, required): Names the agent the call ran through; empty for a call with no agent. - `automation_sid` (string | null, required): Names the automation that placed the call; `null` for a call no automation placed. - `occurred_at` (string (date-time), required): Records when the call reached its final status. - `segment_sids` (array of string, required): Lists the account's segments this contact is currently in, its default segment included. - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) - `included` (object, required): Carries the related resources resolved for this response, one map per relation under the relation's name. The relations: - `segment`: is keyed by the segment's own id (`included.segment[id]`), one entry for every id in a contact's `segment_sids`. - `segment_membership`: has no id of its own and is keyed by the contact's id (`included.segment_membership[contact_id]`), holding every membership the contact has had, newest first. - `source`: is keyed by the source's own id, one entry for each `source_sid` those memberships name; a membership with no `source_sid` resolves nothing. A relation's map is present whenever it was requested, empty if nothing resolved. - `segment` (object) - `segment_membership` (object) - `source` (object) ### Delete contact `DELETE /v1/a/contact/{id}` Operation id: `DeleteContact` Soft-deletes the contact: it reads as absent afterwards, and a re-delete finds nothing. Refused while a live automation holds a segment the contact is in, the account's default segment included; the conflict names the automations, and archiving them releases the contact. Parameters: - `id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `204`: No content - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `409`: Conflict - `500`: Internal server error ### Update contact `PATCH /v1/a/contact/{id}` Operation id: `PatchContact` Updates the contact: an omitted `number`, `type`, `country_code` or `data` preserves the current value. The fields: - `number`: a submitted one is brought to the stored form by `type` and `country_code`, as on create. - `data`: a submitted object replaces the stored one wholesale, and `{}` clears it. - `communication_history`: is not writable. Refused when: - The `revision` is not the contact's current one. - A `data` value has another type than its field holds across the account's contacts. - The contact's data would be past a data limit of the account after the write, data stored before a limit was lowered included. Parameters: - `id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Request body: Content type `application/json`: - `number` (string): As on create; the `type` and `country_code` of this request apply to it. - `type` (enum(number, alphanumeric)): Declares what an identifier is. Values: - `number`: is a phone number, brought to the stored form before it is kept or compared. - `alphanumeric`: is a SIP identifier, kept as sent and checked only to start with a letter or a digit. A request that omits it means `number`, and a value outside the two is refused. - `country_code` (string): Supplies the country for a phone number that arrives without an international mark (`+` or `00`): `0501111222` with `pl` stores as `48501111222`. Rules: - It is an ISO 3166-1 alpha-2 code, in upper or lower case, from `GET /v1/a/info/countries`. - A number already in the international form ignores it. Refused when: - The code is unknown. - The code is sent with type `alphanumeric`. - `data` (object) - `revision` (string, required): Carries the `revision` the caller read, exactly as it was returned. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `409`: Conflict - `422`: Unprocessable - `500`: Internal server error Response body (`200`): Content type `application/json`: - `id` (string, required) - `account_sid` (string, required): Names the account that owns the contact. - `number` (string, required): Identifies the contact within the account, in the stored form. By type: - A phone number is stored as its country calling code followed by the national number, digits only (`37123112233`). - A SIP identifier is stored as it was sent. - `type` (IdentifierType | null, required): The identifier type the stored value was read as; `null` where the platform holds none. - `country_code` (string | null, required): Records the country the stored number belongs to, ISO 3166-1 alpha-2, lowercase. Null when: - The identifier is alphanumeric. - The number is outside any country's range. - The platform holds no country for the number. - `data` (object, required): Holds everything the account has on the person; `{}` when nothing is held. - `data_usage` (object, required): Reports how much of the account's limits the contact's data takes, counted the way the limits count it. - `fields` (object, required) - `current` (integer, required): Counts the fields of the data, at any depth, an array as one field. - `limit` (integer, required): Reports the account's field limit. - `value_bytes` (integer, required): Reports the account's byte limit for one value and for each item of an array. - `array_items` (integer, required): Reports the account's limit for the items of one array. - `values` (array of object, required): Lists every field of the data by its dotted path, in path order. - `field` (string, required): Names the field by its dotted path. - `bytes` (integer, required): Counts the bytes of the value's text; for an array, those of its longest item. - `items` (integer): Counts the items of an array; absent for any other value. - `revision` (string, required): Hash of the contact's current `number`, `type`, `country_code` and `data`. An edit sends it back to prevent a lost update under concurrent writes. - `communication_history` (array of object, required): Lists the last 50 finished calls with the person. Rules: - The newest call comes first. - A deleted communication is not listed. - The list is `[]` when there is none. A call receives the same list at its start as the read-only `communication_history` system variable. - `communication_sid` (string, required): Names the communication that holds the full record of the call. - `direction` (enum(inbound, outbound), required) - `communication_status` (enum(new, ready, dialing, in_progress, in_progress_offline, bounced, done, failed, drifted, stopped), required): Where the call stands. `stopped` is the one that is not an outcome: the call was asked for and never placed, because the work that asked for it was switched off first, so the person is still to reach. `in_progress_offline` is a call that has ended while its scenario still runs the bricks that need no call; the line is free, and the outcome follows when the scenario ends. - `call_status` (CallStatus | null, required): `null` for a call that recorded no telephony state. - `reason` (string, required): Explains why the call ended in its status; empty when no reason was recorded. - `duration` (integer, required): Reports the call duration between answer and hangup, in seconds; 0 for a call that was not answered or never placed. - `scenario_sid` (string, required): Names the scenario the call ran; empty for a call that records no scenario. - `agent_sid` (string, required): Names the agent the call ran through; empty for a call with no agent. - `automation_sid` (string | null, required): Names the automation that placed the call; `null` for a call no automation placed. - `occurred_at` (string (date-time), required): Records when the call reached its final status. - `segment_sids` (array of string, required): Lists the account's segments this contact is currently in, its default segment included. - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) ### List segments `GET /v1/a/segment` Operation id: `ListSegments` Lists the segments, the account's default segment included; the first read that finds no default segment creates it. Segments a live automation holds are listed alongside the rest. The parameters: - `is_used=false`: narrows the list to the segments an automation can take; the flag is returned on every segment, so a caller narrows here or decides from the rows. - `show_deleted=true`: adds the deleted segments, each with its `deleted_at`. - `include=source`: resolves each row's sources into `included`. - `include=automation`: resolves the automation that holds a row into `included`, under its `automation_sid`. Parameters: - `is_used` (query, boolean): Narrows the list by whether a live automation already holds the segment. Values: - `false`: returns the segments free to be taken. - Omitted: both are returned. - `show_deleted` (query, boolean): Sets whether deleted segments are returned. Values: - `true`: deleted segments are included, each carrying its `deleted_at`. - Omitted: only live segments are returned. - `limit` (query, integer): Page size, max 500 (default 100). - `offset` (query, integer) - `filter_or` (query, string): Comma-separated field names to OR-search via filter_query. Accepted: name (substring, case-insensitive). - `filter_query` (query, string): Search term matched across the fields named in filter_or. - `order_by` (query, string): Sort field. Accepted: created_at, name (default created_at). - `order` (query, string): Sort direction: asc | desc (default desc). - `include` (query, string): Comma-separated related resources to resolve into `included`. Accepted: source, automation. - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `500`: Internal server error Response body (`200`): Content type `application/json`: - `items` (array of object, required) - `id` (string, required) - `account_sid` (string, required): Names the account that owns the segment. - `name` (string, required) - `is_default` (boolean, required): Marks the account's default segment: every live contact, computed rather than recorded. Refused when: - The default segment is edited. - The default segment is deleted. - `is_used` (boolean, required): Says whether a live automation already holds this segment. Archiving that automation releases it. - `automation_sid` (string | null, required): Identifies the live automation that holds this segment; null while none does. - `contact_count` (integer (int64), required): Counts the current members. For the default segment this is the account's live contact count. - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) - `deleted_at` (string | null (date-time), required): Records when the segment was deleted; `null` while it is live. Rules: - The segment list returns a deleted segment with `show_deleted=true`. - The contact list returns a deleted segment with `include=segment`. - No other read returns a deleted segment. - `total` (integer (int64), required): Counts the segments matching the query, ignoring paging. - `limit` (integer, required): Reports the page size applied to this request. - `offset` (integer, required): Reports the offset applied to this request. - `has_more` (boolean, required): Says whether records beyond this page match the query. - `included` (object, required): Carries the related resources resolved for this response, one map per relation under the relation's name. Rules: - Each map is keyed by the related resource's own id. - A to-many relation is keyed the same way. - A relation's map is present whenever it was requested, and empty if nothing resolved. The maps: - `source`: keyed as `included.source[id]`. Each source carries its `segment_sid` and its row counts, newest first, capped the way every to-many include is. - `automation`: keyed as `included.automation[automation_sid]`. - `source` (object) - `automation` (object) ### Create segment `POST /v1/a/segment` Operation id: `CreateSegment` Creates the segment, holding nobody and usable at once. Sources are added to it afterwards, and its contacts appear as each source is published. Parameters: - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Request body: Content type `application/json`: - `name` (string, required): Names the segment; unique among the live segments of the account, the default one aside. Responses: - `201`: Created - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `422`: Unprocessable - `500`: Internal server error Response body (`201`): Content type `application/json`: - `id` (string, required) - `account_sid` (string, required): Names the account that owns the segment. - `name` (string, required) - `is_default` (boolean, required): Marks the account's default segment: every live contact, computed rather than recorded. Refused when: - The default segment is edited. - The default segment is deleted. - `is_used` (boolean, required): Says whether a live automation already holds this segment. Archiving that automation releases it. - `automation_sid` (string | null, required): Identifies the live automation that holds this segment; null while none does. - `contact_count` (integer (int64), required): Counts the current members. For the default segment this is the account's live contact count. - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) - `deleted_at` (string | null (date-time), required): Records when the segment was deleted; `null` while it is live. Rules: - The segment list returns a deleted segment with `show_deleted=true`. - The contact list returns a deleted segment with `include=segment`. - No other read returns a deleted segment. ### Get segment `GET /v1/a/segment/{id}` Operation id: `GetSegment` Returns the segment row. The parameters: - `include=source`: resolves its sources into `included`. - `include=automation`: resolves the automation that holds it into `included`. Each is the same map the list answers with, capped the way every to-many include is. The members are read with `GET /v1/a/contact?segment_ids=…`. Parameters: - `id` (path, string, required) - `include` (query, string): Comma-separated related resources to resolve into `included`. Accepted: source, automation. - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `500`: Internal server error Response body (`200`): Content type `application/json`: - `id` (string, required) - `account_sid` (string, required): Names the account that owns the segment. - `name` (string, required) - `is_default` (boolean, required): Marks the account's default segment: every live contact, computed rather than recorded. Refused when: - The default segment is edited. - The default segment is deleted. - `is_used` (boolean, required): Says whether a live automation already holds this segment. Archiving that automation releases it. - `automation_sid` (string | null, required): Identifies the live automation that holds this segment; null while none does. - `contact_count` (integer (int64), required): Counts the current members. For the default segment this is the account's live contact count. - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) - `deleted_at` (string | null (date-time), required): Records when the segment was deleted; `null` while it is live. Rules: - The segment list returns a deleted segment with `show_deleted=true`. - The contact list returns a deleted segment with `include=segment`. - No other read returns a deleted segment. - `included` (object, required): Carries the related resources resolved for this response, one map per relation under the relation's name. Rules: - Each map is keyed by the related resource's own id. - A to-many relation is keyed the same way. - A relation's map is present whenever it was requested, and empty if nothing resolved. The maps: - `source`: keyed as `included.source[id]`. Each source carries its `segment_sid` and its row counts, newest first, capped the way every to-many include is. - `automation`: keyed as `included.automation[automation_sid]`. - `source` (object) - `automation` (object) ### Delete segment `DELETE /v1/a/segment/{id}` Operation id: `DeleteSegment` The segment is soft-deleted; its sources, their rows and the contacts it drew in stay. Refused while a live automation holds it or the condition of a routing names it; archiving that automation, changing or deleting that routing, or archiving its agent releases the segment. Parameters: - `id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `204`: No content - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `409`: Conflict - `500`: Internal server error ### Update segment `PATCH /v1/a/segment/{id}` Operation id: `PatchSegment` Renames the segment. The default segment is not editable at all. Parameters: - `id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Request body: Content type `application/json`: - `name` (string): Names the segment; unique among the live segments of the account, the default one aside. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `409`: Conflict - `422`: Unprocessable - `500`: Internal server error Response body (`200`): Content type `application/json`: - `id` (string, required) - `account_sid` (string, required): Names the account that owns the segment. - `name` (string, required) - `is_default` (boolean, required): Marks the account's default segment: every live contact, computed rather than recorded. Refused when: - The default segment is edited. - The default segment is deleted. - `is_used` (boolean, required): Says whether a live automation already holds this segment. Archiving that automation releases it. - `automation_sid` (string | null, required): Identifies the live automation that holds this segment; null while none does. - `contact_count` (integer (int64), required): Counts the current members. For the default segment this is the account's live contact count. - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) - `deleted_at` (string | null (date-time), required): Records when the segment was deleted; `null` while it is live. Rules: - The segment list returns a deleted segment with `show_deleted=true`. - The contact list returns a deleted segment with `include=segment`. - No other read returns a deleted segment. ### List segment sources `GET /v1/a/segment/{id}/source` Operation id: `ListSegmentSources` Lists the sources of this segment. Rules: - The list is newest first, removed sources included. - `status`: narrows the list to `draft`, `published` or `removed`. - The counts are the source's rows by row status, computed as they are read. Parameters: - `id` (path, string, required) - `status` (query, string): Narrows the list to the sources in one status: draft, published or removed. Omitted, every source is returned, removed ones included. A value that is not a status is refused. - `limit` (query, integer): Page size, max 500 (default 100). - `offset` (query, integer) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `500`: Internal server error Response body (`200`): Content type `application/json`: - `items` (array of object, required) - `id` (string, required) - `account_sid` (string, required): Names the account that owns the source. - `segment_sid` (string, required): Names the segment this source belongs to. A source never exists without one. - `kind` (enum(file, manual), required): Says where this source's contacts come from. Values: - `file`: the contacts come from a supplied file. - `manual`: the contacts are named one at a time. - `status` (enum(draft, published, removed), required): Records the state of the source. Values: - `draft`: its content is editable. - `published`: is set after publish. - `removed`: is set after a delete. A published or removed source is frozen and stays in the list. - `auto_update` (boolean, required): Says whether the segment follows later changes to this source. Always false for the kinds served today, whose content cannot change once supplied. - `reset_reach` (boolean, required): Puts the contacts this source supplies back on the list of the automation that holds the segment when the source is published. Changeable while the source is a draft. - `filename` (string | null): Names the uploaded file, as supplied. - `counts` (object, required): Counts the rows a source holds. - `total` (integer (int64), required): Counts the rows the source holds. - `success` (integer (int64), required): Counts the rows that are published, each a contact. - `rejected` (integer (int64), required): Counts the rows that could not be used. Retrievable as a file. - `total_count` (integer (int64), required): Rows the source holds. Replaced by `counts.total`. - `success_count` (integer (int64), required): Rows that are published, each a contact. Replaced by `counts.success`. - `error_count` (integer (int64), required): Rows that could not be used. Replaced by `counts.rejected`. - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) - `total` (integer (int64), required) - `limit` (integer, required) - `offset` (integer, required) - `has_more` (boolean, required) ### Create source `POST /v1/a/segment/{id}/source` Operation id: `CreateSegmentSource` Creates an empty source of the given kind. Rules: - A file source takes its rows afterwards, on /v1/a/segment/{id}/source/{source_id}/file. - Each supply states its own `type` and `country_code`; the source keeps neither. - `reset_reach`: marks the source as one whose publish puts the contacts it supplies back on the list of the automation that holds the segment. Refused when: - The segment is the account's default segment, which takes no sources at all. - A publish of the segment's sources runs. Parameters: - `id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Request body: Content type `application/json`: - `kind` (enum(file, manual), required): Says where this source's contacts come from. Values: - `file`: the contacts come from a supplied file. - `manual`: the contacts are named one at a time. - `reset_reach` (boolean): Puts the contacts this source supplies back on the automation's list when the source is published. Default false. Responses: - `201`: Created - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `409`: Conflict - `422`: Unprocessable - `500`: Internal server error Response body (`201`): Content type `application/json`: - `id` (string, required) - `account_sid` (string, required): Names the account that owns the source. - `segment_sid` (string, required): Names the segment this source belongs to. A source never exists without one. - `kind` (enum(file, manual), required): Says where this source's contacts come from. Values: - `file`: the contacts come from a supplied file. - `manual`: the contacts are named one at a time. - `status` (enum(draft, published, removed), required): Records the state of the source. Values: - `draft`: its content is editable. - `published`: is set after publish. - `removed`: is set after a delete. A published or removed source is frozen and stays in the list. - `auto_update` (boolean, required): Says whether the segment follows later changes to this source. Always false for the kinds served today, whose content cannot change once supplied. - `reset_reach` (boolean, required): Puts the contacts this source supplies back on the list of the automation that holds the segment when the source is published. Changeable while the source is a draft. - `filename` (string | null): Names the uploaded file, as supplied. - `counts` (object, required): Counts the rows a source holds. - `total` (integer (int64), required): Counts the rows the source holds. - `success` (integer (int64), required): Counts the rows that are published, each a contact. - `rejected` (integer (int64), required): Counts the rows that could not be used. Retrievable as a file. - `total_count` (integer (int64), required): Rows the source holds. Replaced by `counts.total`. - `success_count` (integer (int64), required): Rows that are published, each a contact. Replaced by `counts.success`. - `error_count` (integer (int64), required): Rows that could not be used. Replaced by `counts.rejected`. - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) ### Publish the segment's draft sources `POST /v1/a/segment/{id}/source/-/publish` Operation id: `PublishSegmentSources` Publishes every draft source of the segment as one batch. Effects: - The usable rows of all draft sources are merged by number into one contact per number, its data taken from the rows that supplied it. - A number the account does not hold becomes a new contact. - A number the account holds gets the row's data written over its own, leaf by leaf: a nested object changes only the leaves it names. - A data value of `null` removes that field from the contact the number already names, and adds nothing to a new contact. - Every contact becomes a member of the segment once, recorded against the earliest created source that supplied it. - Rejected rows are skipped and stay downloadable until the contact retention period has passed since they were supplied. - Every source in the batch becomes `published`, and its usable rows with it. When a source in the batch carries `reset_reach` and a live automation holds the segment: - Every contact that source supplies that the automation records as reached, attempted or stopped is put back to waiting, in the same transaction that publishes the sources. - `reset_reach_processed` counts them. - A contact on a running call, and a contact no such source supplies, stays where it is. Refused when: - Another publish of the segment's sources runs. - A merged contact is conflicting. - A merged contact would break a data limit of the account once merged into its contact. - The batch would create more contacts than the account can still take. The last three refuse the whole batch, with nothing written, and `GET …/source/-/validate` shows each of them first. A contact whose data stops fitting while the publish runs stops it with the same refusal; the contacts written before it stay, and a retry continues from that contact. A retry is safe: what already became a contact or a member is not repeated. Parameters: - `id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `409`: Conflict - `422`: Unprocessable - `500`: Internal server error Response body (`200`): Content type `application/json`: - `sources` (array of object, required) - `id` (string, required) - `account_sid` (string, required): Names the account that owns the source. - `segment_sid` (string, required): Names the segment this source belongs to. A source never exists without one. - `kind` (enum(file, manual), required): Says where this source's contacts come from. Values: - `file`: the contacts come from a supplied file. - `manual`: the contacts are named one at a time. - `status` (enum(draft, published, removed), required): Records the state of the source. Values: - `draft`: its content is editable. - `published`: is set after publish. - `removed`: is set after a delete. A published or removed source is frozen and stays in the list. - `auto_update` (boolean, required): Says whether the segment follows later changes to this source. Always false for the kinds served today, whose content cannot change once supplied. - `reset_reach` (boolean, required): Puts the contacts this source supplies back on the list of the automation that holds the segment when the source is published. Changeable while the source is a draft. - `filename` (string | null): Names the uploaded file, as supplied. - `counts` (object, required): Counts the rows a source holds. - `total` (integer (int64), required): Counts the rows the source holds. - `success` (integer (int64), required): Counts the rows that are published, each a contact. - `rejected` (integer (int64), required): Counts the rows that could not be used. Retrievable as a file. - `total_count` (integer (int64), required): Rows the source holds. Replaced by `counts.total`. - `success_count` (integer (int64), required): Rows that are published, each a contact. Replaced by `counts.success`. - `error_count` (integer (int64), required): Rows that could not be used. Replaced by `counts.rejected`. - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) - `counts` (object, required): Counts the contacts a publish call wrote. - `created` (integer (int64), required): Counts the contacts the call created. - `updated` (integer (int64), required): Counts the contacts the account already held that the call wrote data to. - `reset_reach_processed` (integer (int64), required): Counts the contacts put back to waiting on the automation that holds the segment. Rules: - It is 0 when no published source carries `reset_reach`. - It is 0 when no live automation holds the segment. - It is 0 when none of the supplied contacts had been called. ### Preview what publishing the draft sources would do `GET /v1/a/segment/{id}/source/-/validate` Operation id: `ValidateSegmentSources` Answers what `POST …/source/-/publish` would do with the segment's draft sources, and changes nothing. The response: - `batch`: counts the merged contacts: how many would be created, how many would update a contact the account holds, how many rows are rejected, how many merged contacts are conflicting, and how many would break a data limit of the account. - `sources`: gives the same five for each draft source over its own rows. - `items`: is the paged list of merged contacts, one per number, each with the rows that supplied it. - A conflicting item shows which rows disagree. - An item's `over_limit` names the limit the merged contact would break. The filters: - `is_conflicting=true`: narrows `items` and `total` to the conflicting ones. - `is_over_limit=true`: narrows `items` and `total` to the ones past a limit. With these filters, a paged call lists what has to be corrected before publish. After a publish, the batch is empty and every count in `batch` and `sources` is zero. Parameters: - `id` (path, string, required) - `limit` (query, integer): Page size, max 500 (default 100). - `offset` (query, integer) - `is_conflicting` (query, boolean): Narrows the merged contacts by whether they are conflicting. Values: - `true`: returns only the ones whose rows disagree. - `false`: returns only the ones that agree. - Omitted: both are returned. The batch and source counts still cover the whole batch. - `is_over_limit` (query, boolean): Narrows the merged contacts by whether they would break a data limit of the account. Values: - `true`: returns only the contacts that would break a data limit. - `false`: returns only the others. - Omitted: both are returned. The batch and source counts still cover the whole batch. - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `500`: Internal server error Response body (`200`): Content type `application/json`: - `batch` (object, required): Rows or merged contacts by what publish would do with them. - `create` (integer (int64), required): Counts the contacts that would be new. - `update` (integer (int64), required): Counts the contacts the account already holds that would change. - `rejected` (integer (int64), required): Counts the rows that cannot be used; publish skips them. - `conflicts` (integer (int64), required): Counts the contacts another draft source supplies with different data, type or country; publish refuses while any remain. - `over_limit` (integer (int64), required): Counts the contacts whose data, merged into what the contact holds, would break a data limit of the account; publish refuses while any remain. - `contacts` (object, required): Reports the account's contacts against its contact limit; publish refuses while `batch.create` is above `limit` less `current`. - `current` (integer (int64), required): Counts the account's contacts. - `limit` (integer (int64), required): Reports the account's contact limit. - `sources` (array of object, required): Lists one entry per draft source, newest first. - `source_sid` (string, required) - `counts` (object, required): Rows or merged contacts by what publish would do with them. - `create` (integer (int64), required): Counts the contacts that would be new. - `update` (integer (int64), required): Counts the contacts the account already holds that would change. - `rejected` (integer (int64), required): Counts the rows that cannot be used; publish skips them. - `conflicts` (integer (int64), required): Counts the contacts another draft source supplies with different data, type or country; publish refuses while any remain. - `over_limit` (integer (int64), required): Counts the contacts whose data, merged into what the contact holds, would break a data limit of the account; publish refuses while any remain. - `items` (array of object, required): Lists the merged contacts, one per number, in number order. - `number` (string, required) - `action` (enum(create, update), required): Says what publish would do with this number. Values: - `create`: the account holds no contact with this number. - `update`: the account already holds a contact with this number. - `contact_sid` (string | null, required): Names the contact an update would write into; null on a create. - `is_conflicting` (boolean, required): Says whether two of the rows disagree on data, type or country. Publish refuses the batch while any merged contact is conflicting. - `over_limit` (ContactDataLimitBreach | null, required): Names the first data limit the merged contact breaks, counted together with the data the contact already holds; null when it breaks none. - `rows` (array of object, required) - `id` (string, required) - `source_sid` (string, required) - `type` (IdentifierType | null, required): The identifier type the stored value was read as; `null` where the platform holds none. - `country_code` (string | null, required): Records the country the stored number belongs to, ISO 3166-1 alpha-2, lowercase. Null when: - The identifier is alphanumeric. - The number is outside any country's range. - The platform holds no country for the number. - `data` (object | null, required) - `total` (integer (int64), required): Counts the merged contacts in the batch, ignoring paging. - `limit` (integer, required): Reports the page size applied to this request. - `offset` (integer, required): Reports the offset applied to this request. - `has_more` (boolean, required): Says whether merged contacts beyond this page exist. ### Get source `GET /v1/a/segment/{id}/source/{source_id}` Operation id: `GetSegmentSource` One source of the segment, with its counts. Parameters: - `id` (path, string, required) - `source_id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `500`: Internal server error Response body (`200`): Content type `application/json`: - `id` (string, required) - `account_sid` (string, required): Names the account that owns the source. - `segment_sid` (string, required): Names the segment this source belongs to. A source never exists without one. - `kind` (enum(file, manual), required): Says where this source's contacts come from. Values: - `file`: the contacts come from a supplied file. - `manual`: the contacts are named one at a time. - `status` (enum(draft, published, removed), required): Records the state of the source. Values: - `draft`: its content is editable. - `published`: is set after publish. - `removed`: is set after a delete. A published or removed source is frozen and stays in the list. - `auto_update` (boolean, required): Says whether the segment follows later changes to this source. Always false for the kinds served today, whose content cannot change once supplied. - `reset_reach` (boolean, required): Puts the contacts this source supplies back on the list of the automation that holds the segment when the source is published. Changeable while the source is a draft. - `filename` (string | null): Names the uploaded file, as supplied. - `counts` (object, required): Counts the rows a source holds. - `total` (integer (int64), required): Counts the rows the source holds. - `success` (integer (int64), required): Counts the rows that are published, each a contact. - `rejected` (integer (int64), required): Counts the rows that could not be used. Retrievable as a file. - `total_count` (integer (int64), required): Rows the source holds. Replaced by `counts.total`. - `success_count` (integer (int64), required): Rows that are published, each a contact. Replaced by `counts.success`. - `error_count` (integer (int64), required): Rows that could not be used. Replaced by `counts.rejected`. - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) ### Delete a draft source or remove a published one `DELETE /v1/a/segment/{id}/source/{source_id}` Operation id: `DeleteSegmentSource` Deletes the source. For a draft source: - The source is deleted with its rows. - Afterwards it reads as absent. For a published source: - The source is marked `removed` and kept. - It stays in the segment's list, and the members it produced stay. - Its rows stay readable until they are erased: a row whose number no contact holds is erased once the contact retention period has passed since the row was supplied. Refused while a publish of the segment's sources runs. Parameters: - `id` (path, string, required) - `source_id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `204`: No content - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `409`: Conflict - `422`: Unprocessable - `500`: Internal server error ### Update source configuration `PATCH /v1/a/segment/{id}/source/{source_id}` Operation id: `PatchSegmentSource` Takes `auto_update` and `reset_reach`. Rules: - `reset_reach` changes only while the source is a draft. - A file source's content is not here: it is the `file` sub-resource, and each supply carries its own `type` and `country_code`. Refused while a publish of the segment's sources runs. Parameters: - `id` (path, string, required) - `source_id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Request body: Content type `application/json`: - `auto_update` (boolean | null): Keeps the segment in step with this source. Refused for a kind whose content cannot change. - `reset_reach` (boolean | null): Puts the contacts this source supplies back on the automation's list when the source is published. Changeable while the source is a draft; refused afterwards. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `409`: Conflict - `422`: Unprocessable - `500`: Internal server error Response body (`200`): Content type `application/json`: - `id` (string, required) - `account_sid` (string, required): Names the account that owns the source. - `segment_sid` (string, required): Names the segment this source belongs to. A source never exists without one. - `kind` (enum(file, manual), required): Says where this source's contacts come from. Values: - `file`: the contacts come from a supplied file. - `manual`: the contacts are named one at a time. - `status` (enum(draft, published, removed), required): Records the state of the source. Values: - `draft`: its content is editable. - `published`: is set after publish. - `removed`: is set after a delete. A published or removed source is frozen and stays in the list. - `auto_update` (boolean, required): Says whether the segment follows later changes to this source. Always false for the kinds served today, whose content cannot change once supplied. - `reset_reach` (boolean, required): Puts the contacts this source supplies back on the list of the automation that holds the segment when the source is published. Changeable while the source is a draft. - `filename` (string | null): Names the uploaded file, as supplied. - `counts` (object, required): Counts the rows a source holds. - `total` (integer (int64), required): Counts the rows the source holds. - `success` (integer (int64), required): Counts the rows that are published, each a contact. - `rejected` (integer (int64), required): Counts the rows that could not be used. Retrievable as a file. - `total_count` (integer (int64), required): Rows the source holds. Replaced by `counts.total`. - `success_count` (integer (int64), required): Rows that are published, each a contact. Replaced by `counts.success`. - `error_count` (integer (int64), required): Rows that could not be used. Replaced by `counts.rejected`. - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) ### Create or replace rows from a file `PUT /v1/a/segment/{id}/source/{source_id}/file` Operation id: `ReplaceSegmentSourceFile` Replaces the source's rows with the rows of a csv or xlsx file: everything the source held is discarded and the new rows take its place. The file: - It is csv or xlsx, declared by the `Content-Type` of the `file` part: `text/csv` or `application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`. - Of an xlsx, the first sheet is read. - A csv is UTF-8, with or without a byte order mark. - A csv separates its values by commas or by semicolons: the semicolon is taken when the heading row holds more semicolons than commas outside quotes. - The bounds are 100 000 rows, 30 columns, 64 characters in a column's key and a 128 MiB body. Rules: - The headings are normalised to snake_case keys of the contact's data. - A dot in a heading separates the parts of a nested key, and each part is normalised: `Address.City` is the key `city` inside `address`. - Every row's number is brought by the request's `type` and `country_code` parts to the stored form. - Rows already in the international form ignore `country_code`, so one file may carry several countries. - `+371 23-11-22-33`, `0037123112233` and `37123112233` are one row, and the last line is kept. - Each data value is trimmed, a line break or a tab inside it becomes a space, and other control characters are removed. - A data value is stored as the type its field holds across the account's contacts. - One apostrophe at the start of a number or of a data value is removed when `=`, `+`, `-`, `@`, a tab or a carriage return follows it, directly or after more apostrophes: a contact export and a rejected rows file write such a cell with that apostrophe. - A number that cannot be brought to the stored form makes the row a rejected row, carrying its reason. - A data value that does not read as the type its field holds makes the row a rejected row. - A data value longer than the account's value limit in bytes makes the row a rejected row. Refused when: - The file's type is unsupported; this is checked before the file is read. - A publish of the segment's sources runs. The rows are drafts until the segment's sources are published. Parameters: - `id` (path, string, required) - `source_id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Request body: Content type `multipart/form-data`: - `file` (string (binary), required): Carries the rows, as csv or xlsx; the part's `Content-Type` declares which. - `type` (enum(number, alphanumeric)): Declares what an identifier is. Values: - `number`: is a phone number, brought to the stored form before it is kept or compared. - `alphanumeric`: is a SIP identifier, kept as sent and checked only to start with a letter or a digit. A request that omits it means `number`, and a value outside the two is refused. - `country_code` (string): Supplies the country for a phone number that arrives without an international mark (`+` or `00`): `0501111222` with `pl` stores as `48501111222`. Rules: - It is an ISO 3166-1 alpha-2 code, in upper or lower case, from `GET /v1/a/info/countries`. - A number already in the international form ignores it. Refused when: - The code is unknown. - The code is sent with type `alphanumeric`. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `409`: Conflict - `413`: Request body exceeds the 128 MiB upload limit - `422`: Unprocessable - `500`: Internal server error Response body (`200`): Content type `application/json`: - `filename` (string | null): Names the file as supplied. - `counts` (object, required): Counts the rows of one upload. - `total` (integer (int64), required): Counts the rows the upload carried. - `success` (integer (int64), required): Counts the usable rows stored. - `rejected` (integer (int64), required): Counts the rows that could not be used. Retrievable as a file. - `duplicate` (integer (int64), required): Counts the rows merged into another row of the same number; the last of them is kept. - `total_count` (integer (int64), required): Rows the upload carried. Replaced by `counts.total`. - `success_count` (integer (int64), required): Counts the usable rows of the upload. Replaced by `counts.success`. - `error_count` (integer (int64), required): Rows that could not be used. Replaced by `counts.rejected`. - `errors` (array of object): Empty when nothing was rejected. - `code` (string, required): Carries the stable snake_case code the client switches on. - `message` (string, required): Carries English text. It never interpolates a variable value — those travel in parameters. - `parameters` (object, required): Carries everything variable about this error: counts, an example row, the offending value. ### Add rows from a file `PATCH /v1/a/segment/{id}/source/{source_id}/file` Operation id: `AppendSegmentSourceFile` Adds the rows of a csv or xlsx file to the source and keeps the rows the source already carried through. The file: - It is csv or xlsx, declared by the `Content-Type` of the `file` part. - The parsing, the `type` and `country_code` parts, the bounds (100 000 rows, 30 columns, 64 characters in a column's key, a 128 MiB body) and the refusals of an unusable file are those of a replace. Rules: - A number already there is not added twice, so supplying the same file again adds nothing. - What the previous file could not use is dropped: the rejected rows describe the last file supplied, not every attempt. - A rejected row of the file whose number the source already holds is not stored: `counts.rejected` counts it, and the rejected rows do not hold it. Refused when: - The file's type is unsupported; this is checked before the file is read. - A publish of the segment's sources runs. The rows are drafts until the segment's sources are published. Parameters: - `id` (path, string, required) - `source_id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Request body: Content type `multipart/form-data`: - `file` (string (binary), required): Carries the rows, as csv or xlsx; the part's `Content-Type` declares which. - `type` (enum(number, alphanumeric)): Declares what an identifier is. Values: - `number`: is a phone number, brought to the stored form before it is kept or compared. - `alphanumeric`: is a SIP identifier, kept as sent and checked only to start with a letter or a digit. A request that omits it means `number`, and a value outside the two is refused. - `country_code` (string): Supplies the country for a phone number that arrives without an international mark (`+` or `00`): `0501111222` with `pl` stores as `48501111222`. Rules: - It is an ISO 3166-1 alpha-2 code, in upper or lower case, from `GET /v1/a/info/countries`. - A number already in the international form ignores it. Refused when: - The code is unknown. - The code is sent with type `alphanumeric`. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `409`: Conflict - `413`: Request body exceeds the 128 MiB upload limit - `422`: Unprocessable - `500`: Internal server error Response body (`200`): Content type `application/json`: - `filename` (string | null): Names the file as supplied. - `counts` (object, required): Counts the rows of one upload. - `total` (integer (int64), required): Counts the rows the upload carried. - `success` (integer (int64), required): Counts the usable rows stored. - `rejected` (integer (int64), required): Counts the rows that could not be used. Retrievable as a file. - `duplicate` (integer (int64), required): Counts the rows merged into another row of the same number; the last of them is kept. - `total_count` (integer (int64), required): Rows the upload carried. Replaced by `counts.total`. - `success_count` (integer (int64), required): Counts the usable rows of the upload. Replaced by `counts.success`. - `error_count` (integer (int64), required): Rows that could not be used. Replaced by `counts.rejected`. - `errors` (array of object): Empty when nothing was rejected. - `code` (string, required): Carries the stable snake_case code the client switches on. - `message` (string, required): Carries English text. It never interpolates a variable value — those travel in parameters. - `parameters` (object, required): Carries everything variable about this error: counts, an example row, the offending value. ### Download rejected rows as a file `GET /v1/a/segment/{id}/source/{source_id}/file/rejected` Operation id: `GetSegmentSourceRejectedRows` Returns the unusable rows as a csv, each with its reason, so they can be corrected in the tool the file came from and supplied again. The columns: - `number`: holds the row's number. - The data paths follow, in name order: a nested value has one column per leaf, named by its dotted path. - `line`: holds the line of the supplied file a rejected row was read from, and is empty when the row records none. - `error`: holds the row's reason. - `row_index`: holds the place of a rejected row in `rows` of the supplied list, and is empty when the row records none. Rules: - The header row is always present; with nothing rejected it is the whole body. - A number, a data key or a data value that begins with `=`, `+`, `-`, `@`, a tab or a carriage return, or with apostrophes before one of them, is written with one more leading apostrophe, so a spreadsheet does not read it as a formula. - The apostrophe stays visible in the cell, and it is removed when the file is supplied again. - A value that is not text is written as text. - The `line`, `error` and `row_index` columns of a file supplied again are read as data columns and become keys of the contact's data. Parameters: - `id` (path, string, required) - `source_id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `500`: Internal server error Response body (`200`): Content type `text/csv`: ### Rename or remove a column of a draft source `POST /v1/a/segment/{id}/source/{source_id}/data` Operation id: `ChangeSourceColumn` Renames or removes one column on every row of a draft source, in one step. Rules: - The changed rows are checked again against the account's value limit. - The changed rows are checked again against the type each field holds across the account's contacts. - A row rejected for one of its values becomes usable once its values fit both. Refused when: - A rename targets a column that a row of the source already holds. - A publish of the segment's sources runs. Parameters: - `id` (path, string, required) - `source_id` (path, string, required) - `op` (query, enum(rename, delete), required): Selects whether the request renames or removes. - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Request body: Content type `application/json`: - `from` (string): Names the column to rename. - `to` (string): Names the column it becomes. Rules: - It holds at most 64 characters. - It holds no dot. - `field` (string): Names the column to remove. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `409`: Conflict - `422`: Unprocessable - `500`: Internal server error Response body (`200`): Content type `application/json`: - `updated` (integer, required): Counts the rows that held the column and changed. ### Create or replace rows in a batch `PUT /v1/a/segment/{id}/source/{source_id}/batch-contact` Operation id: `ReplaceSourceContacts` Replaces the source's rows with a list of rows: everything the source held is discarded and the new rows take its place. The list: - Each row carries a `number` and optionally `data`. - The bounds are 100 000 rows and a 128 MiB body. - A key of `data` is not empty and holds no dot: a nested field is sent as a nested object. - The bounds of a file's columns apply to the paths of `data` across all rows: 30 columns with `number` counted as one, and 64 characters in a path. Rules: - Every row's number is brought by the request's `type` and `country_code` to the stored form, as on a file upload. - Two rows that come to the same stored form are one row, and the later row is kept. - The keys of `data` are kept as sent, without the normalising a file's headings get. - A data value is stored as the type its field holds across the account's contacts. - A number that cannot be brought to the stored form makes the row a rejected row. - A data value that does not read as the type its field holds makes the row a rejected row. - A data value longer than the account's value limit in bytes makes the row a rejected row. Refused when: - A publish of the segment's sources runs. The rows are drafts until the segment's sources are published. Parameters: - `id` (path, string, required) - `source_id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Request body: Content type `application/json`: - `type` (enum(number, alphanumeric)): Declares what an identifier is. Values: - `number`: is a phone number, brought to the stored form before it is kept or compared. - `alphanumeric`: is a SIP identifier, kept as sent and checked only to start with a letter or a digit. A request that omits it means `number`, and a value outside the two is refused. - `country_code` (string): Supplies the country for a phone number that arrives without an international mark (`+` or `00`): `0501111222` with `pl` stores as `48501111222`. Rules: - It is an ISO 3166-1 alpha-2 code, in upper or lower case, from `GET /v1/a/info/countries`. - A number already in the international form ignores it. Refused when: - The code is unknown. - The code is sent with type `alphanumeric`. - `rows` (array of object, required): Holds up to 100 000 rows. - `number` (string, required): Carries the row's number, brought to the stored form by the request's `type` and `country_code`. - `data` (object | null): Carries the row's contact data; a nested object sets nested fields. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `409`: Conflict - `413`: Request body exceeds the 128 MiB upload limit - `422`: Unprocessable - `500`: Internal server error Response body (`200`): Content type `application/json`: - `counts` (object, required): Counts the rows of one upload. - `total` (integer (int64), required): Counts the rows the upload carried. - `success` (integer (int64), required): Counts the usable rows stored. - `rejected` (integer (int64), required): Counts the rows that could not be used. Retrievable as a file. - `duplicate` (integer (int64), required): Counts the rows merged into another row of the same number; the last of them is kept. - `errors` (array of object, required): Empty when nothing was rejected. - `code` (string, required): Carries the stable snake_case code the client switches on. - `message` (string, required): Carries English text. It never interpolates a variable value — those travel in parameters. - `parameters` (object, required): Carries everything variable about this error: counts, an example row, the offending value. ### Add rows in a batch `PATCH /v1/a/segment/{id}/source/{source_id}/batch-contact` Operation id: `AppendSourceContacts` Adds a list of rows to the source and keeps the rows the source already carried through. The list: - The list, its bounds and the reading of each row are those of a replace. Rules: - A number already there is not added twice, so supplying the same list again adds nothing. - What the previous upload could not use is dropped: the rejected rows describe the last upload, not every attempt. - A rejected row whose number the source already holds is not stored: `counts.rejected` counts it, and the rejected rows do not hold it. Refused when: - A publish of the segment's sources runs. The rows are drafts until the segment's sources are published. Parameters: - `id` (path, string, required) - `source_id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Request body: Content type `application/json`: - `type` (enum(number, alphanumeric)): Declares what an identifier is. Values: - `number`: is a phone number, brought to the stored form before it is kept or compared. - `alphanumeric`: is a SIP identifier, kept as sent and checked only to start with a letter or a digit. A request that omits it means `number`, and a value outside the two is refused. - `country_code` (string): Supplies the country for a phone number that arrives without an international mark (`+` or `00`): `0501111222` with `pl` stores as `48501111222`. Rules: - It is an ISO 3166-1 alpha-2 code, in upper or lower case, from `GET /v1/a/info/countries`. - A number already in the international form ignores it. Refused when: - The code is unknown. - The code is sent with type `alphanumeric`. - `rows` (array of object, required): Holds up to 100 000 rows. - `number` (string, required): Carries the row's number, brought to the stored form by the request's `type` and `country_code`. - `data` (object | null): Carries the row's contact data; a nested object sets nested fields. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `409`: Conflict - `413`: Request body exceeds the 128 MiB upload limit - `422`: Unprocessable - `500`: Internal server error Response body (`200`): Content type `application/json`: - `counts` (object, required): Counts the rows of one upload. - `total` (integer (int64), required): Counts the rows the upload carried. - `success` (integer (int64), required): Counts the usable rows stored. - `rejected` (integer (int64), required): Counts the rows that could not be used. Retrievable as a file. - `duplicate` (integer (int64), required): Counts the rows merged into another row of the same number; the last of them is kept. - `errors` (array of object, required): Empty when nothing was rejected. - `code` (string, required): Carries the stable snake_case code the client switches on. - `message` (string, required): Carries English text. It never interpolates a variable value — those travel in parameters. - `parameters` (object, required): Carries everything variable about this error: counts, an example row, the offending value. ### List rows `GET /v1/a/segment/{id}/source/{source_id}/contact` Operation id: `ListSourceContacts` Every row the source holds, oldest first: rejected rows and rows already carried through into contacts alike. No filter narrows it to the rejected ones; download those as a csv instead. Parameters: - `id` (path, string, required) - `source_id` (path, string, required) - `limit` (query, integer): Page size, max 500 (default 100). - `offset` (query, integer) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `500`: Internal server error Response body (`200`): Content type `application/json`: - `items` (array of object, required) - `id` (string, required) - `status` (enum(draft, published, rejected), required): Says where the row stands. Values: - `draft`: the row stays a draft until its source is published. - `published`: the row has become a contact. - `rejected`: the row cannot be used; the reason is in `error`. - `number` (string, required): Carries the number this row resolves to a contact by. By row: - A row rejected for its number holds the value as supplied. - Every other row holds the stored form that the `type` and `country_code` of the supplying request produced. - `type` (IdentifierType | null, required): The identifier type the stored value was read as; `null` where the platform holds none. - `country_code` (string | null, required): Records the country the stored number belongs to, ISO 3166-1 alpha-2, lowercase. Null when: - The identifier is alphanumeric. - The number is outside any country's range. - The platform holds no country for the number. - `data` (object | null, required): Holds everything else the row carried, keyed by its normalised column headings. - `line` (integer | null, required): Records, on a row a supplied file rejected, the line of that file the row starts on. Rules: - The heading row is counted, so the first row under a heading on line 1 is line 2. - For an xlsx file, the line is the row of the sheet. Null when: - The row is usable. - The row was rejected when it was added or corrected on its own. - The row was supplied in a list of rows. - The row was stored before lines were recorded. A correction that makes the row usable clears it. - `row_index` (integer | null, required): Records the place of a rejected row in `rows` of the supplied list, counted from 0. Null when: - The row is usable. - The row was supplied in a file, or added or corrected on its own. A correction that makes the row usable clears it. - `processed_at` (string | null (date-time), required): Records when the row became a contact. Null when: - The row is a draft. - The row is rejected. - `error` (string | null, required): Says why the row cannot be used, null when it can. It holds `the number is missing`, `the number is not valid: the number holds no digits`, `… is not a valid international number`, `… is not valid for the country_code`, `… is not a valid international number, so a country_code is needed`, or one of the values below. Values: - `… the identifier must start with a letter or a digit`: given for an `alphanumeric` row. - `the value of is longer than bytes`: names the key of `data` and the account's value limit. - `the value of is not of type `: names the type the field holds across the account's contacts. - `rejection` (SourceContactRejection | null, required): Names why the row cannot be used, as a code. Null when: - The row can be used. - The reason has no code; `error` still says why. - `created_at` (string (date-time), required) - `total` (integer (int64), required) - `limit` (integer, required) - `offset` (integer, required) - `has_more` (boolean, required) ### Add one row `POST /v1/a/segment/{id}/source/{source_id}/contact` Operation id: `CreateSourceContact` Adds a row to the source: the number that names the contact, and the data the contact should hold. Rules: - The row is read as on an upload, with one difference: a leading apostrophe in a value is kept. - A number that cannot be brought to the stored form by `type` and `country_code` makes the row a rejected row. - A data value longer than the account's value limit in bytes makes the row a rejected row. - A data value that does not read as the type its field holds across the account's contacts makes the row a rejected row. - A rejected row is stored with the reason in `error`. Refused when: - The source already holds the number. - A publish of the segment's sources runs. The row stays a draft until the segment's sources are published. Parameters: - `id` (path, string, required) - `source_id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Request body: Content type `application/json`: - `number` (string, required) - `type` (enum(number, alphanumeric)): Declares what an identifier is. Values: - `number`: is a phone number, brought to the stored form before it is kept or compared. - `alphanumeric`: is a SIP identifier, kept as sent and checked only to start with a letter or a digit. A request that omits it means `number`, and a value outside the two is refused. - `country_code` (string): Supplies the country for a phone number that arrives without an international mark (`+` or `00`): `0501111222` with `pl` stores as `48501111222`. Rules: - It is an ISO 3166-1 alpha-2 code, in upper or lower case, from `GET /v1/a/info/countries`. - A number already in the international form ignores it. Refused when: - The code is unknown. - The code is sent with type `alphanumeric`. - `data` (object | null) Responses: - `201`: Created - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `409`: Conflict - `422`: Unprocessable - `500`: Internal server error Response body (`201`): Content type `application/json`: - `id` (string, required) - `status` (enum(draft, published, rejected), required): Says where the row stands. Values: - `draft`: the row stays a draft until its source is published. - `published`: the row has become a contact. - `rejected`: the row cannot be used; the reason is in `error`. - `number` (string, required): Carries the number this row resolves to a contact by. By row: - A row rejected for its number holds the value as supplied. - Every other row holds the stored form that the `type` and `country_code` of the supplying request produced. - `type` (IdentifierType | null, required): The identifier type the stored value was read as; `null` where the platform holds none. - `country_code` (string | null, required): Records the country the stored number belongs to, ISO 3166-1 alpha-2, lowercase. Null when: - The identifier is alphanumeric. - The number is outside any country's range. - The platform holds no country for the number. - `data` (object | null, required): Holds everything else the row carried, keyed by its normalised column headings. - `line` (integer | null, required): Records, on a row a supplied file rejected, the line of that file the row starts on. Rules: - The heading row is counted, so the first row under a heading on line 1 is line 2. - For an xlsx file, the line is the row of the sheet. Null when: - The row is usable. - The row was rejected when it was added or corrected on its own. - The row was supplied in a list of rows. - The row was stored before lines were recorded. A correction that makes the row usable clears it. - `row_index` (integer | null, required): Records the place of a rejected row in `rows` of the supplied list, counted from 0. Null when: - The row is usable. - The row was supplied in a file, or added or corrected on its own. A correction that makes the row usable clears it. - `processed_at` (string | null (date-time), required): Records when the row became a contact. Null when: - The row is a draft. - The row is rejected. - `error` (string | null, required): Says why the row cannot be used, null when it can. It holds `the number is missing`, `the number is not valid: the number holds no digits`, `… is not a valid international number`, `… is not valid for the country_code`, `… is not a valid international number, so a country_code is needed`, or one of the values below. Values: - `… the identifier must start with a letter or a digit`: given for an `alphanumeric` row. - `the value of is longer than bytes`: names the key of `data` and the account's value limit. - `the value of is not of type `: names the type the field holds across the account's contacts. - `rejection` (SourceContactRejection | null, required): Names why the row cannot be used, as a code. Null when: - The row can be used. - The reason has no code; `error` still says why. - `created_at` (string (date-time), required) ### Get one row `GET /v1/a/segment/{id}/source/{source_id}/contact/{row_id}` Operation id: `GetSourceContact` `processed_at` says whether it has been carried through into a contact; whether it can still be corrected or removed depends on the source's `status`, and on no publish of the segment's sources running. Parameters: - `id` (path, string, required) - `source_id` (path, string, required) - `row_id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `500`: Internal server error Response body (`200`): Content type `application/json`: - `id` (string, required) - `status` (enum(draft, published, rejected), required): Says where the row stands. Values: - `draft`: the row stays a draft until its source is published. - `published`: the row has become a contact. - `rejected`: the row cannot be used; the reason is in `error`. - `number` (string, required): Carries the number this row resolves to a contact by. By row: - A row rejected for its number holds the value as supplied. - Every other row holds the stored form that the `type` and `country_code` of the supplying request produced. - `type` (IdentifierType | null, required): The identifier type the stored value was read as; `null` where the platform holds none. - `country_code` (string | null, required): Records the country the stored number belongs to, ISO 3166-1 alpha-2, lowercase. Null when: - The identifier is alphanumeric. - The number is outside any country's range. - The platform holds no country for the number. - `data` (object | null, required): Holds everything else the row carried, keyed by its normalised column headings. - `line` (integer | null, required): Records, on a row a supplied file rejected, the line of that file the row starts on. Rules: - The heading row is counted, so the first row under a heading on line 1 is line 2. - For an xlsx file, the line is the row of the sheet. Null when: - The row is usable. - The row was rejected when it was added or corrected on its own. - The row was supplied in a list of rows. - The row was stored before lines were recorded. A correction that makes the row usable clears it. - `row_index` (integer | null, required): Records the place of a rejected row in `rows` of the supplied list, counted from 0. Null when: - The row is usable. - The row was supplied in a file, or added or corrected on its own. A correction that makes the row usable clears it. - `processed_at` (string | null (date-time), required): Records when the row became a contact. Null when: - The row is a draft. - The row is rejected. - `error` (string | null, required): Says why the row cannot be used, null when it can. It holds `the number is missing`, `the number is not valid: the number holds no digits`, `… is not a valid international number`, `… is not valid for the country_code`, `… is not a valid international number, so a country_code is needed`, or one of the values below. Values: - `… the identifier must start with a letter or a digit`: given for an `alphanumeric` row. - `the value of is longer than bytes`: names the key of `data` and the account's value limit. - `the value of is not of type `: names the type the field holds across the account's contacts. - `rejection` (SourceContactRejection | null, required): Names why the row cannot be used, as a code. Null when: - The row can be used. - The reason has no code; `error` still says why. - `created_at` (string (date-time), required) ### Remove one row `DELETE /v1/a/segment/{id}/source/{source_id}/contact/{row_id}` Operation id: `DeleteSourceContact` Removes a draft row. Refused when: - The row is published: published rows are members, and membership is not ended from here. - A publish of the segment's sources runs. Parameters: - `id` (path, string, required) - `source_id` (path, string, required) - `row_id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `204`: No content - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `409`: Conflict - `422`: Unprocessable - `500`: Internal server error ### Correct one row `PATCH /v1/a/segment/{id}/source/{source_id}/contact/{row_id}` Operation id: `PatchSourceContact` Fixes a rejected number in place, rather than re-supplying the whole file. Rules: - The request's `type` and `country_code` apply to the `number` it carries. - The top-level text values of `data` are trimmed and their control characters treated as on an upload. - A leading apostrophe is kept. - A row holding a top-level text value of `data` longer than the account's value limit in bytes is a rejected row. - A row holding a data value that does not read as the type its field holds across the account's contacts is a rejected row. - A rejected row becomes usable again when a correction leaves neither. Refused while a publish of the segment's sources runs. Parameters: - `id` (path, string, required) - `source_id` (path, string, required) - `row_id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Request body: Content type `application/json`: - `number` (string) - `type` (enum(number, alphanumeric)): Declares what an identifier is. Values: - `number`: is a phone number, brought to the stored form before it is kept or compared. - `alphanumeric`: is a SIP identifier, kept as sent and checked only to start with a letter or a digit. A request that omits it means `number`, and a value outside the two is refused. - `country_code` (CountryCode | null) - `data` (object | null) Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `409`: Conflict - `422`: Unprocessable - `500`: Internal server error Response body (`200`): Content type `application/json`: - `id` (string, required) - `status` (enum(draft, published, rejected), required): Says where the row stands. Values: - `draft`: the row stays a draft until its source is published. - `published`: the row has become a contact. - `rejected`: the row cannot be used; the reason is in `error`. - `number` (string, required): Carries the number this row resolves to a contact by. By row: - A row rejected for its number holds the value as supplied. - Every other row holds the stored form that the `type` and `country_code` of the supplying request produced. - `type` (IdentifierType | null, required): The identifier type the stored value was read as; `null` where the platform holds none. - `country_code` (string | null, required): Records the country the stored number belongs to, ISO 3166-1 alpha-2, lowercase. Null when: - The identifier is alphanumeric. - The number is outside any country's range. - The platform holds no country for the number. - `data` (object | null, required): Holds everything else the row carried, keyed by its normalised column headings. - `line` (integer | null, required): Records, on a row a supplied file rejected, the line of that file the row starts on. Rules: - The heading row is counted, so the first row under a heading on line 1 is line 2. - For an xlsx file, the line is the row of the sheet. Null when: - The row is usable. - The row was rejected when it was added or corrected on its own. - The row was supplied in a list of rows. - The row was stored before lines were recorded. A correction that makes the row usable clears it. - `row_index` (integer | null, required): Records the place of a rejected row in `rows` of the supplied list, counted from 0. Null when: - The row is usable. - The row was supplied in a file, or added or corrected on its own. A correction that makes the row usable clears it. - `processed_at` (string | null (date-time), required): Records when the row became a contact. Null when: - The row is a draft. - The row is rejected. - `error` (string | null, required): Says why the row cannot be used, null when it can. It holds `the number is missing`, `the number is not valid: the number holds no digits`, `… is not a valid international number`, `… is not valid for the country_code`, `… is not a valid international number, so a country_code is needed`, or one of the values below. Values: - `… the identifier must start with a letter or a digit`: given for an `alphanumeric` row. - `the value of is longer than bytes`: names the key of `data` and the account's value limit. - `the value of is not of type `: names the type the field holds across the account's contacts. - `rejection` (SourceContactRejection | null, required): Names why the row cannot be used, as a code. Null when: - The row can be used. - The reason has no code; `error` still says why. - `created_at` (string (date-time), required) ### List automations `GET /v1/a/automation` Operation id: `ListAutomations` Lists the automations of the caller's account, newest first, the archived ones left out. The parameters: - `agent_sid`: narrows the list to one agent. - `status`: narrows the list to one or more statuses; `archived` comes back only when `status` names it. - `include`: resolves a row's agent, segment and limit policy into `included`. Parameters: - `limit` (query, integer): Page size, max 500 (default 100). - `offset` (query, integer) - `agent_sid` (query, string): Narrows the list to one agent's automations. - `status` (query, string): Narrows the list to the automations in any of the given statuses. Rules: - The statuses are comma-separated. - Omitted, the list leaves out `archived`. - A value that is not a status is refused. - `filter_or` (query, string): Comma-separated field names to OR-search via filter_query. Accepted: name (substring, case-insensitive). - `filter_query` (query, string): Search term matched across the fields named in filter_or. - `include` (query, string): Comma-separated related resources to resolve into `included`. Accepted: agent, segment, limit_policy. - `order_by` (query, string): Sort field. Accepted: created_at, name (default created_at). - `order` (query, string): Sort direction: asc | desc (default desc). - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `500`: Internal server error Response body (`200`): Content type `application/json`: - `items` (array of object, required) - `id` (string, required) - `account_sid` (string, required) - `agent_sid` (string, required) - `segment_sid` (string, required) - `limit_policy_sid` (string | null, required): Names the slice of the agent's capacity this automation competes inside. Empty means it competes for whatever the agent's policies did not reserve. - `name` (string, required): Unique among the live automations of the same agent; archiving frees it. - `mode` (enum(manual, scheduled), required): Declares how the automation decides when to run. Values: - `manual`: places its calls when a person starts it. - `scheduled`: opens each of its attempts at the moment that attempt names. - `status` (enum(new, idle, in_progress, done, stopped, archived), required): Records where the automation stands. Values: - `new`: has never run. - `idle`: is switched on with nothing due. - `in_progress`: is placing calls. - `done`: has nothing left to call. - `stopped`: was switched off by a person. - `archived`: never runs again. The status is the system's to write: a person moves it through stop, start and archive. - `status_changed_at` (string (date-time), required): Records when `status` last changed. - `status_history` (array of object, required): Records every change of `status`, oldest first. - `from` (enum(new, idle, in_progress, done, stopped, archived), required): Records where the automation stands. Values: - `new`: has never run. - `idle`: is switched on with nothing due. - `in_progress`: is placing calls. - `done`: has nothing left to call. - `stopped`: was switched off by a person. - `archived`: never runs again. The status is the system's to write: a person moves it through stop, start and archive. - `to` (enum(new, idle, in_progress, done, stopped, archived), required): Records where the automation stands. Values: - `new`: has never run. - `idle`: is switched on with nothing due. - `in_progress`: is placing calls. - `done`: has nothing left to call. - `stopped`: was switched off by a person. - `archived`: never runs again. The status is the system's to write: a person moves it through stop, start and archive. - `at` (string (date-time), required) - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) - `total` (integer (int64), required): Counts the automations matching the query, ignoring paging. - `limit` (integer, required): Reports the page size applied to this request. - `offset` (integer, required): Reports the offset applied to this request. - `has_more` (boolean, required): Says whether records beyond this page match the query. - `included` (object, required): Carries the related resources resolved for this response. Rules: - Related resources are deduplicated and keyed by the related resource's own id, so an automation resolves one as `included.agent[agent_sid]`. - A relation's map is present whenever it was requested. - A relation's map is empty if nothing resolved. - A reference the caller may not read is absent from the map, and the automation keeps its sid. - `agent` (object) - `segment` (object) - `limit_policy` (object): Resolves the policy each `limit_policy_sid` names; an automation without one resolves nothing here. ### Create automation `POST /v1/a/automation` Operation id: `CreateAutomation` Binds a segment to an agent; the automation starts `new` and places no call until it is started. Refused when the agent's scenario has no published version. Parameters: - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Request body: Content type `application/json`: - `agent_sid` (string, required): Names the agent the calls go out through. Refused when: - The agent belongs to another account. - The agent is archived. - `segment_sid` (string, required): Names the contacts to reach. A segment another live automation already holds is refused. - `limit_policy_sid` (string): Names a policy of the same agent. One belonging to another agent is refused. - `name` (string, required): Unique among the live automations of the same agent. - `mode` (enum(manual, scheduled)): Declares how the automation decides when to run. Values: - `manual`: places its calls when a person starts it. - `scheduled`: opens each of its attempts at the moment that attempt names. Responses: - `201`: Created - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `422`: Unprocessable - `500`: Internal server error Response body (`201`): Content type `application/json`: - `id` (string, required) - `account_sid` (string, required) - `agent_sid` (string, required) - `segment_sid` (string, required) - `limit_policy_sid` (string | null, required): Names the slice of the agent's capacity this automation competes inside. Empty means it competes for whatever the agent's policies did not reserve. - `name` (string, required): Unique among the live automations of the same agent; archiving frees it. - `mode` (enum(manual, scheduled), required): Declares how the automation decides when to run. Values: - `manual`: places its calls when a person starts it. - `scheduled`: opens each of its attempts at the moment that attempt names. - `status` (enum(new, idle, in_progress, done, stopped, archived), required): Records where the automation stands. Values: - `new`: has never run. - `idle`: is switched on with nothing due. - `in_progress`: is placing calls. - `done`: has nothing left to call. - `stopped`: was switched off by a person. - `archived`: never runs again. The status is the system's to write: a person moves it through stop, start and archive. - `status_changed_at` (string (date-time), required): Records when `status` last changed. - `status_history` (array of object, required): Records every change of `status`, oldest first. - `from` (enum(new, idle, in_progress, done, stopped, archived), required): Records where the automation stands. Values: - `new`: has never run. - `idle`: is switched on with nothing due. - `in_progress`: is placing calls. - `done`: has nothing left to call. - `stopped`: was switched off by a person. - `archived`: never runs again. The status is the system's to write: a person moves it through stop, start and archive. - `to` (enum(new, idle, in_progress, done, stopped, archived), required): Records where the automation stands. Values: - `new`: has never run. - `idle`: is switched on with nothing due. - `in_progress`: is placing calls. - `done`: has nothing left to call. - `stopped`: was switched off by a person. - `archived`: never runs again. The status is the system's to write: a person moves it through stop, start and archive. - `at` (string (date-time), required) - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) ### Get automation `GET /v1/a/automation/{id}` Operation id: `GetAutomation` `include` resolves the agent, segment and limit policy into `included`, the same maps the list answers with. Parameters: - `id` (path, string, required) - `include` (query, string): Comma-separated related resources to resolve into `included`. Accepted: agent, segment, limit_policy. - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `500`: Internal server error Response body (`200`): Content type `application/json`: - `id` (string, required) - `account_sid` (string, required) - `agent_sid` (string, required) - `segment_sid` (string, required) - `limit_policy_sid` (string | null, required): Names the slice of the agent's capacity this automation competes inside. Empty means it competes for whatever the agent's policies did not reserve. - `name` (string, required): Unique among the live automations of the same agent; archiving frees it. - `mode` (enum(manual, scheduled), required): Declares how the automation decides when to run. Values: - `manual`: places its calls when a person starts it. - `scheduled`: opens each of its attempts at the moment that attempt names. - `status` (enum(new, idle, in_progress, done, stopped, archived), required): Records where the automation stands. Values: - `new`: has never run. - `idle`: is switched on with nothing due. - `in_progress`: is placing calls. - `done`: has nothing left to call. - `stopped`: was switched off by a person. - `archived`: never runs again. The status is the system's to write: a person moves it through stop, start and archive. - `status_changed_at` (string (date-time), required): Records when `status` last changed. - `status_history` (array of object, required): Records every change of `status`, oldest first. - `from` (enum(new, idle, in_progress, done, stopped, archived), required): Records where the automation stands. Values: - `new`: has never run. - `idle`: is switched on with nothing due. - `in_progress`: is placing calls. - `done`: has nothing left to call. - `stopped`: was switched off by a person. - `archived`: never runs again. The status is the system's to write: a person moves it through stop, start and archive. - `to` (enum(new, idle, in_progress, done, stopped, archived), required): Records where the automation stands. Values: - `new`: has never run. - `idle`: is switched on with nothing due. - `in_progress`: is placing calls. - `done`: has nothing left to call. - `stopped`: was switched off by a person. - `archived`: never runs again. The status is the system's to write: a person moves it through stop, start and archive. - `at` (string (date-time), required) - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) - `included` (object, required): Carries the related resources resolved for this response. Rules: - Related resources are deduplicated and keyed by the related resource's own id, so an automation resolves one as `included.agent[agent_sid]`. - A relation's map is present whenever it was requested. - A relation's map is empty if nothing resolved. - A reference the caller may not read is absent from the map, and the automation keeps its sid. - `agent` (object) - `segment` (object) - `limit_policy` (object): Resolves the policy each `limit_policy_sid` names; an automation without one resolves nothing here. ### Delete automation `DELETE /v1/a/automation/{id}` Operation id: `DeleteAutomation` Deletes the automation. Effects: - A run in progress is stopped first. - The segment and the name it held are freed. - Its calls and their communication results are deleted with it and leave every list and read, except the communication list with `show_deleted=true`. - A call being dialled or in progress is not deleted and stays listed after it ends. Parameters: - `id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `204`: No Content - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `500`: Internal server error ### Update automation `PATCH /v1/a/automation/{id}` Operation id: `PatchAutomation` Updates the automation partially. Rules: - The agent, the segment and the mode change until an attempt of the automation opens; after that only the current value is accepted. - The name and the limit policy are checked against the agent the automation has after the update. Refused when: - The automation is archived: every change is refused. - The request changes the mode while an attempt waits to open. - The agent belongs to another account, or is archived. - The segment belongs to another account, or another live automation holds it. - Another live automation of the agent the automation has after the update holds the name. - The policy belongs to an agent other than the one the automation has after the update, the current policy included when the agent changes. - The request moves the automation to an agent whose scenario has no published version. Parameters: - `id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Request body: Content type `application/json`: - `agent_sid` (string): Names the agent the calls go out through, fixed once an attempt of the automation opens. Refused when: - The agent belongs to another account. - The agent is archived. - `segment_sid` (string): Names the contacts to reach, fixed once an attempt of the automation opens. Refused when: - The segment belongs to another account. - Another live automation already holds the segment. - `mode` (enum(manual, scheduled)): Declares how the automation decides when to run. Values: - `manual`: places its calls when a person starts it. - `scheduled`: opens each of its attempts at the moment that attempt names. - `name` (string): Refused when another live automation holds it under the agent the automation has after this update. - `limit_policy_sid` (string | null): Names a policy of the agent the automation has after this update, or null to compete for what no policy of that agent reserved. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `422`: Unprocessable - `500`: Internal server error Response body (`200`): Content type `application/json`: - `id` (string, required) - `account_sid` (string, required) - `agent_sid` (string, required) - `segment_sid` (string, required) - `limit_policy_sid` (string | null, required): Names the slice of the agent's capacity this automation competes inside. Empty means it competes for whatever the agent's policies did not reserve. - `name` (string, required): Unique among the live automations of the same agent; archiving frees it. - `mode` (enum(manual, scheduled), required): Declares how the automation decides when to run. Values: - `manual`: places its calls when a person starts it. - `scheduled`: opens each of its attempts at the moment that attempt names. - `status` (enum(new, idle, in_progress, done, stopped, archived), required): Records where the automation stands. Values: - `new`: has never run. - `idle`: is switched on with nothing due. - `in_progress`: is placing calls. - `done`: has nothing left to call. - `stopped`: was switched off by a person. - `archived`: never runs again. The status is the system's to write: a person moves it through stop, start and archive. - `status_changed_at` (string (date-time), required): Records when `status` last changed. - `status_history` (array of object, required): Records every change of `status`, oldest first. - `from` (enum(new, idle, in_progress, done, stopped, archived), required): Records where the automation stands. Values: - `new`: has never run. - `idle`: is switched on with nothing due. - `in_progress`: is placing calls. - `done`: has nothing left to call. - `stopped`: was switched off by a person. - `archived`: never runs again. The status is the system's to write: a person moves it through stop, start and archive. - `to` (enum(new, idle, in_progress, done, stopped, archived), required): Records where the automation stands. Values: - `new`: has never run. - `idle`: is switched on with nothing due. - `in_progress`: is placing calls. - `done`: has nothing left to call. - `stopped`: was switched off by a person. - `archived`: never runs again. The status is the system's to write: a person moves it through stop, start and archive. - `at` (string (date-time), required) - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) ### List automation runs `GET /v1/a/automation/{id}/attempt` Operation id: `ListAutomationAttempts` Lists the runs of this automation by `starts_at`, earliest first; runs with no `starts_at` come last. Runs that start at the same moment keep a stable order between pages. `include=automation` resolves the automation the runs belong to into `included`. Parameters: - `id` (path, string, required) - `limit` (query, integer): Page size, max 500 (default 100). - `offset` (query, integer) - `include` (query, string): Comma-separated related resources to resolve into `included`. Accepted: automation. - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `500`: Internal server error Response body (`200`): Content type `application/json`: - `items` (array of object, required) - `id` (string, required) - `account_sid` (string, required) - `automation_sid` (string, required) - `status` (enum(new, in_progress, done, stopped, skipped), required): Records where one run stands. Values: - `new`: has not opened yet. - `in_progress`: is placing calls. - `done`: finished its calls. - `stopped`: was cut short by its window or by a person. - `skipped`: never opened. - `status_changed_at` (string (date-time), required): Records when `status` last changed. - `status_history` (array of object, required): Records every change of `status`, oldest first, so it carries the moment the run opened and the moment it ended. - `from` (enum(new, in_progress, done, stopped, skipped), required): Records where one run stands. Values: - `new`: has not opened yet. - `in_progress`: is placing calls. - `done`: finished its calls. - `stopped`: was cut short by its window or by a person. - `skipped`: never opened. - `to` (enum(new, in_progress, done, stopped, skipped), required): Records where one run stands. Values: - `new`: has not opened yet. - `in_progress`: is placing calls. - `done`: finished its calls. - `stopped`: was cut short by its window or by a person. - `skipped`: never opened. - `reason` (AutomationAttemptStatusReason | null, required): Records why the run stopped or was skipped. Null when: - The change is to any other status. - The change was recorded before the reason was kept. - `at` (string (date-time), required) - `starts_at` (string | null (date-time), required) - `ends_at` (string | null (date-time), required): Records when calling stops. Empty on an attempt that runs until its calls are all over. - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) - `total` (integer (int64), required): Counts the runs matching the query, ignoring paging. - `limit` (integer, required): Reports the page size applied to this request. - `offset` (integer, required): Reports the offset applied to this request. - `has_more` (boolean, required): Says whether records beyond this page match the query. - `included` (object, required): Carries the related resources resolved for this response. Rules: - Related resources are deduplicated and keyed by the related resource's own id, so a run resolves its automation as `included.automation[automation_sid]`. - A relation's map is present whenever it was requested. - A relation's map is empty if nothing resolved. - `automation` (object) ### Add a scheduled attempt `POST /v1/a/automation/{id}/attempt` Operation id: `AddAutomationAttempt` Appends an attempt to a scheduled automation, to open at the moment given. Rules: - Attempts do not overlap. - An attempt before this one that had no end now ends where this one starts. - Removing this one gives that attempt its open end back. Parameters: - `id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Request body: Content type `application/json`: - `starts_at` (string (date-time), required): Sets when calling starts. Refused when: - The moment is in the past. - The window overlaps another attempt of this automation. - `ends_at` (string | null (date-time)): Sets when calling stops, finished or not — whoever is left waits for the next attempt. Omitted, the attempt runs until its calls are over or the next attempt starts; a moment at or before `starts_at` is refused. Responses: - `201`: Created - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `422`: Unprocessable - `500`: Internal server error Response body (`201`): Content type `application/json`: - `id` (string, required) - `account_sid` (string, required) - `automation_sid` (string, required) - `status` (enum(new, in_progress, done, stopped, skipped), required): Records where one run stands. Values: - `new`: has not opened yet. - `in_progress`: is placing calls. - `done`: finished its calls. - `stopped`: was cut short by its window or by a person. - `skipped`: never opened. - `status_changed_at` (string (date-time), required): Records when `status` last changed. - `status_history` (array of object, required): Records every change of `status`, oldest first, so it carries the moment the run opened and the moment it ended. - `from` (enum(new, in_progress, done, stopped, skipped), required): Records where one run stands. Values: - `new`: has not opened yet. - `in_progress`: is placing calls. - `done`: finished its calls. - `stopped`: was cut short by its window or by a person. - `skipped`: never opened. - `to` (enum(new, in_progress, done, stopped, skipped), required): Records where one run stands. Values: - `new`: has not opened yet. - `in_progress`: is placing calls. - `done`: finished its calls. - `stopped`: was cut short by its window or by a person. - `skipped`: never opened. - `reason` (AutomationAttemptStatusReason | null, required): Records why the run stopped or was skipped. Null when: - The change is to any other status. - The change was recorded before the reason was kept. - `at` (string (date-time), required) - `starts_at` (string | null (date-time), required) - `ends_at` (string | null (date-time), required): Records when calling stops. Empty on an attempt that runs until its calls are all over. - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) ### Get automation run `GET /v1/a/automation/{id}/attempt/{attempt_id}` Operation id: `GetAutomationAttempt` One run of the automation. `include=automation` resolves the automation into `included`, the same map the list answers with. Parameters: - `id` (path, string, required) - `attempt_id` (path, string, required) - `include` (query, string): Comma-separated related resources to resolve into `included`. Accepted: automation. - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `500`: Internal server error Response body (`200`): Content type `application/json`: - `id` (string, required) - `account_sid` (string, required) - `automation_sid` (string, required) - `status` (enum(new, in_progress, done, stopped, skipped), required): Records where one run stands. Values: - `new`: has not opened yet. - `in_progress`: is placing calls. - `done`: finished its calls. - `stopped`: was cut short by its window or by a person. - `skipped`: never opened. - `status_changed_at` (string (date-time), required): Records when `status` last changed. - `status_history` (array of object, required): Records every change of `status`, oldest first, so it carries the moment the run opened and the moment it ended. - `from` (enum(new, in_progress, done, stopped, skipped), required): Records where one run stands. Values: - `new`: has not opened yet. - `in_progress`: is placing calls. - `done`: finished its calls. - `stopped`: was cut short by its window or by a person. - `skipped`: never opened. - `to` (enum(new, in_progress, done, stopped, skipped), required): Records where one run stands. Values: - `new`: has not opened yet. - `in_progress`: is placing calls. - `done`: finished its calls. - `stopped`: was cut short by its window or by a person. - `skipped`: never opened. - `reason` (AutomationAttemptStatusReason | null, required): Records why the run stopped or was skipped. Null when: - The change is to any other status. - The change was recorded before the reason was kept. - `at` (string (date-time), required) - `starts_at` (string | null (date-time), required) - `ends_at` (string | null (date-time), required): Records when calling stops. Empty on an attempt that runs until its calls are all over. - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) - `included` (object, required): Carries the related resources resolved for this response. Rules: - Related resources are deduplicated and keyed by the related resource's own id, so a run resolves its automation as `included.automation[automation_sid]`. - A relation's map is present whenever it was requested. - A relation's map is empty if nothing resolved. - `automation` (object) ### Remove a scheduled attempt `DELETE /v1/a/automation/{id}/attempt/{attempt_id}` Operation id: `RemoveAutomationAttempt` Drops an attempt that has not opened yet. Refused on an archived automation. Parameters: - `id` (path, string, required) - `attempt_id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `204`: No Content - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `422`: Unprocessable - `500`: Internal server error ### Move a scheduled attempt `PATCH /v1/a/automation/{id}/attempt/{attempt_id}` Operation id: `UpdateAutomationAttempt` Moves the window of an attempt that has not opened. Rules: - The move changes that attempt alone. - The windows around it are left as they are. - The schedule that results has to hold. Refused on an archived automation. Parameters: - `id` (path, string, required) - `attempt_id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Request body: Content type `application/json`: - `starts_at` (string (date-time)): Sets when calling starts. Refused when: - The moment is in the past. - The window overlaps another attempt of this automation. - `ends_at` (string | null (date-time)): Sets when calling stops. `null` leaves the attempt without an end, so it runs until its calls are over; on any attempt but the one that runs last that is refused. A moment at or before `starts_at` is refused. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `422`: Unprocessable - `500`: Internal server error Response body (`200`): Content type `application/json`: - `id` (string, required) - `account_sid` (string, required) - `automation_sid` (string, required) - `status` (enum(new, in_progress, done, stopped, skipped), required): Records where one run stands. Values: - `new`: has not opened yet. - `in_progress`: is placing calls. - `done`: finished its calls. - `stopped`: was cut short by its window or by a person. - `skipped`: never opened. - `status_changed_at` (string (date-time), required): Records when `status` last changed. - `status_history` (array of object, required): Records every change of `status`, oldest first, so it carries the moment the run opened and the moment it ended. - `from` (enum(new, in_progress, done, stopped, skipped), required): Records where one run stands. Values: - `new`: has not opened yet. - `in_progress`: is placing calls. - `done`: finished its calls. - `stopped`: was cut short by its window or by a person. - `skipped`: never opened. - `to` (enum(new, in_progress, done, stopped, skipped), required): Records where one run stands. Values: - `new`: has not opened yet. - `in_progress`: is placing calls. - `done`: finished its calls. - `stopped`: was cut short by its window or by a person. - `skipped`: never opened. - `reason` (AutomationAttemptStatusReason | null, required): Records why the run stopped or was skipped. Null when: - The change is to any other status. - The change was recorded before the reason was kept. - `at` (string (date-time), required) - `starts_at` (string | null (date-time), required) - `ends_at` (string | null (date-time), required): Records when calling stops. Empty on an attempt that runs until its calls are all over. - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) ### Read an automation's progress `GET /v1/a/automation/{id}/progress` Operation id: `GetAutomationProgress` Reads how far the outreach has progressed over the contacts it has taken. Rules: - Each contact falls in exactly one figure, so the total is the number of contacts the automation has taken across its runs. - Before the first run takes anyone, and while the automation is not archived, the total and the waiting figure are the live members of the segment, and the other figures are zero. - A contact put back on the list through `POST /v1/a/automation/{id}/reset-reach` reads as waiting at once. Parameters: - `id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `500`: Internal server error Response body (`200`): Content type `application/json`: - `total` (integer (int64), required): Contacts the automation has taken across its runs, or contacts the run took. Before the first run takes anyone, the live members of the segment. - `reached` (integer (int64), required): Contacts who picked up. - `in_progress` (integer (int64), required): Contacts whose call is being placed or under way right now. - `attempted` (integer (int64), required): Contacts whose latest call ended without them picking up. - `waiting` (integer (int64), required): Contacts with no call placed yet, or whose call is created and not yet dialled. Before the first run takes anyone, every live member of the segment. - `stopped` (integer (int64), required): Contacts whose call was stopped before dialling, or deleted. The next run takes them. ### Read one run's progress `GET /v1/a/automation/{id}/attempt/{attempt_id}/progress` Operation id: `GetAutomationAttemptProgress` Reads what this run did over the contacts it took when it opened. Rules: - The total is that audience: the contacts the run took when it opened. - The figures do not change when contacts are put back on the list afterwards. Parameters: - `id` (path, string, required) - `attempt_id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `500`: Internal server error Response body (`200`): Content type `application/json`: - `total` (integer (int64), required): Contacts the automation has taken across its runs, or contacts the run took. Before the first run takes anyone, the live members of the segment. - `reached` (integer (int64), required): Contacts who picked up. - `in_progress` (integer (int64), required): Contacts whose call is being placed or under way right now. - `attempted` (integer (int64), required): Contacts whose latest call ended without them picking up. - `waiting` (integer (int64), required): Contacts with no call placed yet, or whose call is created and not yet dialled. Before the first run takes anyone, every live member of the segment. - `stopped` (integer (int64), required): Contacts whose call was stopped before dialling, or deleted. The next run takes them. ### Put contacts back on the list `POST /v1/a/automation/{id}/reset-reach` Operation id: `ResetAutomationReach` Moves every contact the automation has reached, called without reaching, or stopped back to waiting, and answers how many were moved. Rules: - A contact whose call is running is not moved. - A run's own figures do not change. Parameters: - `id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `422`: Unprocessable - `500`: Internal server error Response body (`200`): Content type `application/json`: - `reset` (integer (int64), required): Contacts moved back to waiting. ### Put one contact back on the list `POST /v1/a/automation/{id}/contact/{contact_id}/reset-reach` Operation id: `ResetAutomationContactReach` Moves one contact the automation has reached, called without reaching, or stopped back to waiting. Rules: - When the contact is moved, the answer is `1`. - A contact whose call is running is not moved, and the answer is `0`. - A contact who is already waiting is not moved, and the answer is `0`. Parameters: - `id` (path, string, required) - `contact_id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `422`: Unprocessable - `500`: Internal server error Response body (`200`): Content type `application/json`: - `reset` (integer (int64), required): Contacts moved back to waiting. ### Start automation `POST /v1/a/automation/{id}/start` Operation id: `StartAutomation` Switches the automation on. By mode: - `manual`: adds one attempt starting now, and the automation reads `idle` until that attempt opens. - `scheduled`: clears the stop; the attempt that is due opens on its own, and the ones whose moment went by are marked `skipped`. Parameters: - `id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `422`: Unprocessable - `500`: Internal server error Response body (`200`): Content type `application/json`: - `id` (string, required) - `account_sid` (string, required) - `agent_sid` (string, required) - `segment_sid` (string, required) - `limit_policy_sid` (string | null, required): Names the slice of the agent's capacity this automation competes inside. Empty means it competes for whatever the agent's policies did not reserve. - `name` (string, required): Unique among the live automations of the same agent; archiving frees it. - `mode` (enum(manual, scheduled), required): Declares how the automation decides when to run. Values: - `manual`: places its calls when a person starts it. - `scheduled`: opens each of its attempts at the moment that attempt names. - `status` (enum(new, idle, in_progress, done, stopped, archived), required): Records where the automation stands. Values: - `new`: has never run. - `idle`: is switched on with nothing due. - `in_progress`: is placing calls. - `done`: has nothing left to call. - `stopped`: was switched off by a person. - `archived`: never runs again. The status is the system's to write: a person moves it through stop, start and archive. - `status_changed_at` (string (date-time), required): Records when `status` last changed. - `status_history` (array of object, required): Records every change of `status`, oldest first. - `from` (enum(new, idle, in_progress, done, stopped, archived), required): Records where the automation stands. Values: - `new`: has never run. - `idle`: is switched on with nothing due. - `in_progress`: is placing calls. - `done`: has nothing left to call. - `stopped`: was switched off by a person. - `archived`: never runs again. The status is the system's to write: a person moves it through stop, start and archive. - `to` (enum(new, idle, in_progress, done, stopped, archived), required): Records where the automation stands. Values: - `new`: has never run. - `idle`: is switched on with nothing due. - `in_progress`: is placing calls. - `done`: has nothing left to call. - `stopped`: was switched off by a person. - `archived`: never runs again. The status is the system's to write: a person moves it through stop, start and archive. - `at` (string (date-time), required) - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) ### Stop automation `POST /v1/a/automation/{id}/stop` Operation id: `StopAutomation` Switches the automation off and ends the run in progress. Effects: - The calls it asked for and never placed read `stopped`, and the contacts they were for are still to reach. - A call already dialling or in conversation finishes. Nothing starts again until a person starts it. Parameters: - `id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `422`: Unprocessable - `500`: Internal server error Response body (`200`): Content type `application/json`: - `id` (string, required) - `account_sid` (string, required) - `agent_sid` (string, required) - `segment_sid` (string, required) - `limit_policy_sid` (string | null, required): Names the slice of the agent's capacity this automation competes inside. Empty means it competes for whatever the agent's policies did not reserve. - `name` (string, required): Unique among the live automations of the same agent; archiving frees it. - `mode` (enum(manual, scheduled), required): Declares how the automation decides when to run. Values: - `manual`: places its calls when a person starts it. - `scheduled`: opens each of its attempts at the moment that attempt names. - `status` (enum(new, idle, in_progress, done, stopped, archived), required): Records where the automation stands. Values: - `new`: has never run. - `idle`: is switched on with nothing due. - `in_progress`: is placing calls. - `done`: has nothing left to call. - `stopped`: was switched off by a person. - `archived`: never runs again. The status is the system's to write: a person moves it through stop, start and archive. - `status_changed_at` (string (date-time), required): Records when `status` last changed. - `status_history` (array of object, required): Records every change of `status`, oldest first. - `from` (enum(new, idle, in_progress, done, stopped, archived), required): Records where the automation stands. Values: - `new`: has never run. - `idle`: is switched on with nothing due. - `in_progress`: is placing calls. - `done`: has nothing left to call. - `stopped`: was switched off by a person. - `archived`: never runs again. The status is the system's to write: a person moves it through stop, start and archive. - `to` (enum(new, idle, in_progress, done, stopped, archived), required): Records where the automation stands. Values: - `new`: has never run. - `idle`: is switched on with nothing due. - `in_progress`: is placing calls. - `done`: has nothing left to call. - `stopped`: was switched off by a person. - `archived`: never runs again. The status is the system's to write: a person moves it through stop, start and archive. - `at` (string (date-time), required) - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) ### Archive automation `POST /v1/a/automation/{id}/archive` Operation id: `ArchiveAutomation` Archives the automation permanently and frees its segment and its name for the next one. The attempts still waiting are marked as never run. Only an automation that is `new`, `stopped` or `done` is accepted. After the archive, the automation never runs again, and every later change is refused. Parameters: - `id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `422`: Unprocessable - `500`: Internal server error Response body (`200`): Content type `application/json`: - `id` (string, required) - `account_sid` (string, required) - `agent_sid` (string, required) - `segment_sid` (string, required) - `limit_policy_sid` (string | null, required): Names the slice of the agent's capacity this automation competes inside. Empty means it competes for whatever the agent's policies did not reserve. - `name` (string, required): Unique among the live automations of the same agent; archiving frees it. - `mode` (enum(manual, scheduled), required): Declares how the automation decides when to run. Values: - `manual`: places its calls when a person starts it. - `scheduled`: opens each of its attempts at the moment that attempt names. - `status` (enum(new, idle, in_progress, done, stopped, archived), required): Records where the automation stands. Values: - `new`: has never run. - `idle`: is switched on with nothing due. - `in_progress`: is placing calls. - `done`: has nothing left to call. - `stopped`: was switched off by a person. - `archived`: never runs again. The status is the system's to write: a person moves it through stop, start and archive. - `status_changed_at` (string (date-time), required): Records when `status` last changed. - `status_history` (array of object, required): Records every change of `status`, oldest first. - `from` (enum(new, idle, in_progress, done, stopped, archived), required): Records where the automation stands. Values: - `new`: has never run. - `idle`: is switched on with nothing due. - `in_progress`: is placing calls. - `done`: has nothing left to call. - `stopped`: was switched off by a person. - `archived`: never runs again. The status is the system's to write: a person moves it through stop, start and archive. - `to` (enum(new, idle, in_progress, done, stopped, archived), required): Records where the automation stands. Values: - `new`: has never run. - `idle`: is switched on with nothing due. - `in_progress`: is placing calls. - `done`: has nothing left to call. - `stopped`: was switched off by a person. - `archived`: never runs again. The status is the system's to write: a person moves it through stop, start and archive. - `at` (string (date-time), required) - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) ### List limit policies `GET /v1/a/limit-policy` Operation id: `ListLimitPolicies` Lists every live policy of the caller's account, newest first. The parameters: - `agent_sid`: narrows the list to one agent. - `include=agent`: resolves each row's agent into `included`. Parameters: - `limit` (query, integer): Page size, max 500 (default 100). - `offset` (query, integer) - `agent_sid` (query, string): Narrows the list to one agent's policies. - `filter_or` (query, string): Comma-separated field names to OR-search via filter_query. Accepted: name (substring, case-insensitive). - `filter_query` (query, string): Search term matched across the fields named in filter_or. - `order_by` (query, string): Sort field. Accepted: created_at, name (default created_at). - `order` (query, string): Sort direction: asc | desc (default desc). - `include` (query, string): Comma-separated related resources to resolve into `included`. Accepted: agent. - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `500`: Internal server error Response body (`200`): Content type `application/json`: - `items` (array of object, required) - `id` (string, required) - `account_sid` (string, required) - `agent_sid` (string, required) - `name` (string, required): Unique among the live policies of the same agent. - `lines` (integer, required): Calls held for the automations that name this policy. - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) - `total` (integer (int64), required): Counts the policies matching the query, ignoring paging. - `limit` (integer, required): Reports the page size applied to this request. - `offset` (integer, required): Reports the offset applied to this request. - `has_more` (boolean, required): Says whether records beyond this page match the query. - `included` (object, required): Carries the related resources resolved for this response, deduplicated and keyed by the related resource's own id, so a policy resolves its agent as `included.agent[agent_sid]`. Rules: - A relation's map is present whenever it was requested. - A requested relation's map is empty when nothing resolved. - A reference the caller may not read is absent from the map, and the policy keeps its sid. - `agent` (object) ### Create limit policy `POST /v1/a/limit-policy` Operation id: `CreateLimitPolicy` Reserves part of one agent's capacity. Parameters: - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Request body: Content type `application/json`: - `agent_sid` (string, required): Names the agent whose capacity is sliced. Refused when: - The agent belongs to another account. - The agent is archived. - `name` (string, required): Unique among the live policies of the same agent. - `lines` (integer, required): A figure that no longer fits inside the agent's capacity is refused. Responses: - `201`: Created - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `422`: Unprocessable - `500`: Internal server error Response body (`201`): Content type `application/json`: - `id` (string, required) - `account_sid` (string, required) - `agent_sid` (string, required) - `name` (string, required): Unique among the live policies of the same agent. - `lines` (integer, required): Calls held for the automations that name this policy. - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) ### Get limit policy `GET /v1/a/limit-policy/{id}` Operation id: `GetLimitPolicy` `include=agent` resolves the agent into `included`, the same map the list answers with. Parameters: - `id` (path, string, required) - `include` (query, string): Comma-separated related resources to resolve into `included`. Accepted: agent. - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `500`: Internal server error Response body (`200`): Content type `application/json`: - `id` (string, required) - `account_sid` (string, required) - `agent_sid` (string, required) - `name` (string, required): Unique among the live policies of the same agent. - `lines` (integer, required): Calls held for the automations that name this policy. - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) - `included` (object, required): Carries the related resources resolved for this response, deduplicated and keyed by the related resource's own id, so a policy resolves its agent as `included.agent[agent_sid]`. Rules: - A relation's map is present whenever it was requested. - A requested relation's map is empty when nothing resolved. - A reference the caller may not read is absent from the map, and the policy keeps its sid. - `agent` (object) ### Delete limit policy `DELETE /v1/a/limit-policy/{id}` Operation id: `DeleteLimitPolicy` The capacity it reserved returns to what everything else on the agent draws on. Refused while a live automation names it; archiving that automation, or pointing it at another policy, releases this one. Parameters: - `id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `204`: No Content - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `409`: Conflict - `500`: Internal server error ### Update limit policy `PATCH /v1/a/limit-policy/{id}` Operation id: `PatchLimitPolicy` Partial update. Refused while the policy's agent is archived. Parameters: - `id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Request body: Content type `application/json`: - `name` (string): Unique among the live policies of the same agent. - `lines` (integer): A figure that no longer fits inside the agent's capacity is refused. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `422`: Unprocessable - `500`: Internal server error Response body (`200`): Content type `application/json`: - `id` (string, required) - `account_sid` (string, required) - `agent_sid` (string, required) - `name` (string, required): Unique among the live policies of the same agent. - `lines` (integer, required): Calls held for the automations that name this policy. - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) ### List agents `GET /v1/a/agent` Operation id: `ListAgents` Lists the agents of the account. The parameters: - `status`: the archived agents come back only when `status` names them. - `include`: resolves a row's scenario, its number or its pool, its automations that are not archived and its SMS provider into `included`, each asked for by name. Parameters: - `limit` (query, integer): Page size, max 500 (default 100). - `offset` (query, integer) - `status` (query, string): Comma-separated statuses; an agent in any of them qualifies. Omitted, the list leaves out `archived`. A value that is not a status is refused. - `scenario_sid` (query, string) - `number_sid` (query, string): Narrows the list to the agent whose gateway is this number. An unknown number gives an empty list. - `number_pool_sid` (query, string): Narrows the list to the agent whose gateway is this number pool. An unknown pool gives an empty list. - `sms_provider_sid` (query, string): Narrows the list to the agents that send SMS through this provider. An unknown provider gives an empty list. - `filter_or` (query, string): Names the fields, comma-separated, that filter_query OR-searches. Values: - `id`: matched exactly. - `name`: matched as a substring, case-insensitive. - `filter_query` (query, string): Search term matched across the fields named in filter_or. - `order_by` (query, string): Sort field. Accepted: created_at (default created_at). - `order` (query, string): Sort direction: asc | desc (default desc). - `include` (query, string): Comma-separated related resources to resolve into `included`. Accepted: scenario, number, number_pool, automation, sms_provider. - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `500`: Internal server error Response body (`200`): Content type `application/json`: - `items` (array of object, required) - `id` (string, required) - `account_sid` (string, required) - `name` (string, required): Unique among the agents of the account that are not archived; archiving or deleting an agent frees its name. - `gateway_type` (enum(number, number_pool), required): Declares the gateway kind. Rules: - The matching sid (`number_sid` / `number_pool_sid`) carries the gateway. - The other sid stays empty. Any other combination of the sids is refused. - `number_sid` (string | null, required) - `number_pool_sid` (string | null, required) - `scenario_sid` (string, required) - `voicemail_enabled` (boolean, required): Turns on answering machine detection for the agent's outbound calls on a scenario whose start call brick is v1. - `call_recording` (boolean, required) - `calling_schedule` (CallingSchedule | null, required): Null when the agent has no window of its own; the platform default (08:00–19:59 every day) then applies. - `timezone` (string, required): Names the IANA zone the calling window is read in, such as `Europe/Warsaw`. When empty, the account's zone applies. - `lines` (integer, required): Simultaneous calls this agent holds, answered and placed together. - `is_test` (boolean, required) - `communication_result` (CommunicationResultConfig | null, required) - `sms` (AgentSms | null, required) - `status` (enum(active, inactive, archived), required): Declares the agent's status. Values: - `inactive`: pauses the agent; it keeps its number or pool, its name and its `lines`. - `archived`: is final and is reached only through archive; written in a create or a patch, it is refused. - `status_changed_at` (string (date-time), required): Records when `status` last changed. - `status_history` (array of object, required): Records every change of `status`, oldest first. - `from` (enum(active, inactive, archived), required): Declares the agent's status. Values: - `inactive`: pauses the agent; it keeps its number or pool, its name and its `lines`. - `archived`: is final and is reached only through archive; written in a create or a patch, it is refused. - `to` (enum(active, inactive, archived), required): Declares the agent's status. Values: - `inactive`: pauses the agent; it keeps its number or pool, its name and its `lines`. - `archived`: is final and is reached only through archive; written in a create or a patch, it is refused. - `at` (string (date-time), required) - `old_number` (string | null, required): Records the `identifier` of the number the agent held when it was archived. Null when: - The agent is not archived yet. - The agent is on a pool. - `old_number_pool` (string | null, required): Records the name of the pool the agent used when it was archived. Null when: - The agent is not archived yet. - The agent is on a number. - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) - `total` (integer (int64), required): Counts the agents matching the query, ignoring paging. - `limit` (integer, required): Reports the page size applied to this request. - `offset` (integer, required): Reports the offset applied to this request. - `has_more` (boolean, required): Says whether records beyond this page match the query. - `included` (object, required): Carries the related resources resolved for this response, one map per relation under the relation's name, keyed by the related resource's own id (`included.scenario[id]`). Rules: - A relation's map is present whenever it was requested, empty if nothing resolved. - A reference the caller may not read is absent from the map, and the agent keeps its sid. - `scenario` (object) - `number` (object) - `number_pool` (object) - `automation` (object): Resolves the automations of the agents of this response; a to-many relation, each automation carrying its `agent_sid`, capped the way every to-many include is. - `sms_provider` (object): Resolves the provider each `sms.provider_sid` names; an agent without SMS routing resolves nothing here. ### Create agent `POST /v1/a/agent` Operation id: `CreateAgent` Binds the scenario to a gateway. Rules: - `status`: defaults to active. - A number carries at most one agent. - A number in a pool is not given to an agent; the agent takes the pool. - A pool is shared by as many agents as use it. - An active agent needs an active number, or an active pool with an active number. An agent with no SMS settings is refused while the published version of its scenario has an SMS brick. Parameters: - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Request body: Content type `application/json`: - `name` (string, required): A name another agent of the account already holds is refused; archived and deleted agents do not count. - `gateway_type` (enum(number, number_pool), required): Declares the gateway kind. Rules: - The matching sid (`number_sid` / `number_pool_sid`) carries the gateway. - The other sid stays empty. Any other combination of the sids is refused. - `number_sid` (string | null) - `number_pool_sid` (string | null) - `scenario_sid` (string, required) - `voicemail_enabled` (boolean): Turns on answering machine detection for the agent's outbound calls on a scenario whose start call brick is v1. - `call_recording` (boolean) - `calling_schedule` (object): Restricts when the agent's calls are placed: only inside the minutes its schedules name, read in the agent's `timezone`. Rules: - A call that comes due outside them is held and placed when they next open. - Absent, the platform default applies: 08:00–19:59 every day. - Test calls are not held by it. Refused when: - The `strategy` is unknown. - The value holds no schedule. - A schedule does not parse. - `strategy` (enum(default), required): How `args` is read. `default` reads `args.schedules` as cron expressions. - `args` (object, required) - `schedules` (array of string, required): Lists five-field cron expressions (minute, hour, day of month, month, day of week). Rules: - A call may be placed in any minute at least one of them matches: for example `* 8-19 * * 1-5` is 08:00–19:59, Monday to Friday. - At least one is required. - `timezone` (string): Sets the IANA zone the calling window is read in. Refused when: - The zone is unknown. - A `calling_schedule` is set on an agent with no timezone. - `lines` (integer): Sets how many simultaneous calls this agent holds. Omitted, the agent is created holding one. Refused when: - The account's agents no longer fit its allocation. - This agent's limit policies no longer fit inside it. - `is_test` (boolean) - `communication_result` (object) - `targets` (array of object) - `url` (string) - `sms` (object): Sets the SMS routing: the provider to send through and the sender. The sender: - With `use_alpha`, it is one of the provider's alphas. - Otherwise, it is one of the provider's numbers. - It is always an explicitly registered value. - `provider_sid` (string, required) - `use_alpha` (boolean) - `alpha` (string): Sets the sender alpha. Required when use_alpha is true; one of the provider's alphas. - `number` (string): Sets the sender number. Required when use_alpha is false; one of the provider's numbers. - `status` (enum(active, inactive, archived)): Declares the agent's status. Values: - `inactive`: pauses the agent; it keeps its number or pool, its name and its `lines`. - `archived`: is final and is reached only through archive; written in a create or a patch, it is refused. Responses: - `201`: Created - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `422`: Unprocessable - `500`: Internal server error Response body (`201`): Content type `application/json`: - `id` (string, required) - `account_sid` (string, required) - `name` (string, required): Unique among the agents of the account that are not archived; archiving or deleting an agent frees its name. - `gateway_type` (enum(number, number_pool), required): Declares the gateway kind. Rules: - The matching sid (`number_sid` / `number_pool_sid`) carries the gateway. - The other sid stays empty. Any other combination of the sids is refused. - `number_sid` (string | null, required) - `number_pool_sid` (string | null, required) - `scenario_sid` (string, required) - `voicemail_enabled` (boolean, required): Turns on answering machine detection for the agent's outbound calls on a scenario whose start call brick is v1. - `call_recording` (boolean, required) - `calling_schedule` (CallingSchedule | null, required): Null when the agent has no window of its own; the platform default (08:00–19:59 every day) then applies. - `timezone` (string, required): Names the IANA zone the calling window is read in, such as `Europe/Warsaw`. When empty, the account's zone applies. - `lines` (integer, required): Simultaneous calls this agent holds, answered and placed together. - `is_test` (boolean, required) - `communication_result` (CommunicationResultConfig | null, required) - `sms` (AgentSms | null, required) - `status` (enum(active, inactive, archived), required): Declares the agent's status. Values: - `inactive`: pauses the agent; it keeps its number or pool, its name and its `lines`. - `archived`: is final and is reached only through archive; written in a create or a patch, it is refused. - `status_changed_at` (string (date-time), required): Records when `status` last changed. - `status_history` (array of object, required): Records every change of `status`, oldest first. - `from` (enum(active, inactive, archived), required): Declares the agent's status. Values: - `inactive`: pauses the agent; it keeps its number or pool, its name and its `lines`. - `archived`: is final and is reached only through archive; written in a create or a patch, it is refused. - `to` (enum(active, inactive, archived), required): Declares the agent's status. Values: - `inactive`: pauses the agent; it keeps its number or pool, its name and its `lines`. - `archived`: is final and is reached only through archive; written in a create or a patch, it is refused. - `at` (string (date-time), required) - `old_number` (string | null, required): Records the `identifier` of the number the agent held when it was archived. Null when: - The agent is not archived yet. - The agent is on a pool. - `old_number_pool` (string | null, required): Records the name of the pool the agent used when it was archived. Null when: - The agent is not archived yet. - The agent is on a number. - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) ### Get agent `GET /v1/a/agent/{id}` Operation id: `GetAgent` Finds an archived agent as well. `include` resolves the scenario, number, number pool, automations in every status and SMS provider into `included`. Parameters: - `id` (path, string, required) - `include` (query, string): Comma-separated related resources to resolve into `included`. Accepted: scenario, number, number_pool, automation, sms_provider. - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `500`: Internal server error Response body (`200`): Content type `application/json`: - `id` (string, required) - `account_sid` (string, required) - `name` (string, required): Unique among the agents of the account that are not archived; archiving or deleting an agent frees its name. - `gateway_type` (enum(number, number_pool), required): Declares the gateway kind. Rules: - The matching sid (`number_sid` / `number_pool_sid`) carries the gateway. - The other sid stays empty. Any other combination of the sids is refused. - `number_sid` (string | null, required) - `number_pool_sid` (string | null, required) - `scenario_sid` (string, required) - `voicemail_enabled` (boolean, required): Turns on answering machine detection for the agent's outbound calls on a scenario whose start call brick is v1. - `call_recording` (boolean, required) - `calling_schedule` (CallingSchedule | null, required): Null when the agent has no window of its own; the platform default (08:00–19:59 every day) then applies. - `timezone` (string, required): Names the IANA zone the calling window is read in, such as `Europe/Warsaw`. When empty, the account's zone applies. - `lines` (integer, required): Simultaneous calls this agent holds, answered and placed together. - `is_test` (boolean, required) - `communication_result` (CommunicationResultConfig | null, required) - `sms` (AgentSms | null, required) - `status` (enum(active, inactive, archived), required): Declares the agent's status. Values: - `inactive`: pauses the agent; it keeps its number or pool, its name and its `lines`. - `archived`: is final and is reached only through archive; written in a create or a patch, it is refused. - `status_changed_at` (string (date-time), required): Records when `status` last changed. - `status_history` (array of object, required): Records every change of `status`, oldest first. - `from` (enum(active, inactive, archived), required): Declares the agent's status. Values: - `inactive`: pauses the agent; it keeps its number or pool, its name and its `lines`. - `archived`: is final and is reached only through archive; written in a create or a patch, it is refused. - `to` (enum(active, inactive, archived), required): Declares the agent's status. Values: - `inactive`: pauses the agent; it keeps its number or pool, its name and its `lines`. - `archived`: is final and is reached only through archive; written in a create or a patch, it is refused. - `at` (string (date-time), required) - `old_number` (string | null, required): Records the `identifier` of the number the agent held when it was archived. Null when: - The agent is not archived yet. - The agent is on a pool. - `old_number_pool` (string | null, required): Records the name of the pool the agent used when it was archived. Null when: - The agent is not archived yet. - The agent is on a number. - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) - `included` (object, required): Carries the related resources resolved for this response, one map per relation under the relation's name, keyed by the related resource's own id (`included.scenario[id]`). Rules: - A relation's map is present whenever it was requested, empty if nothing resolved. - A reference the caller may not read is absent from the map, and the agent keeps its sid. - `scenario` (object) - `number` (object) - `number_pool` (object) - `automation` (object): Resolves the automations of the agents of this response; a to-many relation, each automation carrying its `agent_sid`, capped the way every to-many include is. - `sms_provider` (object): Resolves the provider each `sms.provider_sid` names; an agent without SMS routing resolves nothing here. ### Delete agent `DELETE /v1/a/agent/{id}` Operation id: `DeleteAgent` Deletes an archived agent together with its automations, limit policies, routings, calls and their communication results. Afterwards none of them appears in a list or a read, except the calls in the communication list with `show_deleted=true`. Refused when: - The agent is in any status other than archived. - A call of the agent is being dialled or is in progress. A second delete finds nothing. Parameters: - `id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `204`: Deleted - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `409`: Conflict - `422`: Unprocessable - `500`: Internal server error ### Update agent `PATCH /v1/a/agent/{id}` Operation id: `PatchAgent` Partial update; the same rules as on create apply to the result, except the gateway check. Rules: - A new `gateway_type` with its number or pool replaces the previous gateway. - Switching the agent on, or moving an active agent to another gateway, checks the gateway; other changes do not. Refused when: - The agent is archived. - The agent has automations that are not archived, and the change activates the agent or gives an active agent a new scenario, while that scenario has no published version. Parameters: - `id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Request body: Content type `application/json`: - `name` (string): A name another agent of the account already holds is refused; archived and deleted agents do not count. - `gateway_type` (enum(number, number_pool)): Declares the gateway kind. Rules: - The matching sid (`number_sid` / `number_pool_sid`) carries the gateway. - The other sid stays empty. Any other combination of the sids is refused. - `number_sid` (string | null) - `number_pool_sid` (string | null) - `scenario_sid` (string) - `voicemail_enabled` (boolean): Turns on answering machine detection for the agent's outbound calls on a scenario whose start call brick is v1. - `call_recording` (boolean) - `calling_schedule` (CallingSchedule | null): A change reaches the agent's calls that are not yet placed; `null` removes the window and the platform default then applies to them. - `timezone` (string): Sets the IANA zone the calling window is read in. Refused when: - The zone is unknown. - A `calling_schedule` is set on an agent with no timezone. - `lines` (integer): Sets how many simultaneous calls this agent holds. Refused when: - The account's agents no longer fit its allocation. - This agent's limit policies no longer fit inside it. - `is_test` (boolean) - `communication_result` (CommunicationResultConfig | null) - `sms` (AgentSms | null) - `status` (enum(active, inactive, archived)): Declares the agent's status. Values: - `inactive`: pauses the agent; it keeps its number or pool, its name and its `lines`. - `archived`: is final and is reached only through archive; written in a create or a patch, it is refused. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `409`: Conflict - `422`: Unprocessable - `500`: Internal server error Response body (`200`): Content type `application/json`: - `id` (string, required) - `account_sid` (string, required) - `name` (string, required): Unique among the agents of the account that are not archived; archiving or deleting an agent frees its name. - `gateway_type` (enum(number, number_pool), required): Declares the gateway kind. Rules: - The matching sid (`number_sid` / `number_pool_sid`) carries the gateway. - The other sid stays empty. Any other combination of the sids is refused. - `number_sid` (string | null, required) - `number_pool_sid` (string | null, required) - `scenario_sid` (string, required) - `voicemail_enabled` (boolean, required): Turns on answering machine detection for the agent's outbound calls on a scenario whose start call brick is v1. - `call_recording` (boolean, required) - `calling_schedule` (CallingSchedule | null, required): Null when the agent has no window of its own; the platform default (08:00–19:59 every day) then applies. - `timezone` (string, required): Names the IANA zone the calling window is read in, such as `Europe/Warsaw`. When empty, the account's zone applies. - `lines` (integer, required): Simultaneous calls this agent holds, answered and placed together. - `is_test` (boolean, required) - `communication_result` (CommunicationResultConfig | null, required) - `sms` (AgentSms | null, required) - `status` (enum(active, inactive, archived), required): Declares the agent's status. Values: - `inactive`: pauses the agent; it keeps its number or pool, its name and its `lines`. - `archived`: is final and is reached only through archive; written in a create or a patch, it is refused. - `status_changed_at` (string (date-time), required): Records when `status` last changed. - `status_history` (array of object, required): Records every change of `status`, oldest first. - `from` (enum(active, inactive, archived), required): Declares the agent's status. Values: - `inactive`: pauses the agent; it keeps its number or pool, its name and its `lines`. - `archived`: is final and is reached only through archive; written in a create or a patch, it is refused. - `to` (enum(active, inactive, archived), required): Declares the agent's status. Values: - `inactive`: pauses the agent; it keeps its number or pool, its name and its `lines`. - `archived`: is final and is reached only through archive; written in a create or a patch, it is refused. - `at` (string (date-time), required) - `old_number` (string | null, required): Records the `identifier` of the number the agent held when it was archived. Null when: - The agent is not archived yet. - The agent is on a pool. - `old_number_pool` (string | null, required): Records the name of the pool the agent used when it was archived. Null when: - The agent is not archived yet. - The agent is on a number. - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) ### List the routings of an agent `GET /v1/a/agent/{id}/routing` Operation id: `ListRoutings` Lists the routings of the agent by position, the default routing last. A call of the agent plays the scenario of the first routing whose condition matches, or the default routing when none matches. A call that is not a test passes over a routing whose scenario has no published version. Parameters: - `id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `500`: Internal server error Response body (`200`): Content type `application/json`: - `items` (array of object, required) - `id` (string, required) - `account_sid` (string, required) - `agent_sid` (string, required) - `name` (string, required): Names the routing. The default routing is named `default`. - `condition` (string | null, required): Holds the expression a call is checked against. Rules: - A segment is written by its name. - A segment that the account no longer holds is written by its id. Null on the default routing. - `scenario_sid` (string, required): Names the scenario a call plays when the condition matches. On the default routing it is the agent's scenario. - `is_published` (boolean, required): Reports whether the scenario has a published version. - `position` (integer, required): Places the routing in the order the agent checks them, from 1. The default routing is always last. - `default` (boolean, required): Marks the routing that ends the list. - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) - `total` (integer (int64), required): Counts the routings, the default routing included. - `limit` (integer, required): Reports the number of routings returned. - `offset` (integer, required): Reports 0. - `has_more` (boolean, required): Reports false. - `included` (object, required): Reports `{}`. ### Create a routing `POST /v1/a/agent/{id}/routing` Operation id: `CreateRouting` Adds a routing to the agent at the position the request names, or last before the default routing. Refused when: - The agent is archived. - The condition names a segment the account does not hold. - The condition names a contact field no contact of the account holds, or one that holds fields of its own. - The condition compares a contact field with a value of a type the account's contacts do not hold there. Parameters: - `id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Request body: Content type `application/json`: - `name` (string, required): Names the routing. - `condition` (string, required): Holds the expression a call is checked against, as `GET /v1/a/agent/-/routing/-/query-language` describes it. - `scenario_sid` (string, required): Names the scenario a call plays when the condition matches; it may have no published version. - `position` (integer): Places the routing in the order, from 1. Rules: - Omitted, the routing goes last, before the default routing. - The routings from that position on move one place down. Responses: - `201`: Created - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `422`: Unprocessable - `500`: Internal server error Response body (`201`): Content type `application/json`: - `id` (string, required) - `account_sid` (string, required) - `agent_sid` (string, required) - `name` (string, required): Names the routing. The default routing is named `default`. - `condition` (string | null, required): Holds the expression a call is checked against. Rules: - A segment is written by its name. - A segment that the account no longer holds is written by its id. Null on the default routing. - `scenario_sid` (string, required): Names the scenario a call plays when the condition matches. On the default routing it is the agent's scenario. - `is_published` (boolean, required): Reports whether the scenario has a published version. - `position` (integer, required): Places the routing in the order the agent checks them, from 1. The default routing is always last. - `default` (boolean, required): Marks the routing that ends the list. - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) ### Get a routing `GET /v1/a/agent/{id}/routing/{routing_id}` Operation id: `GetRouting` Reads one routing of the agent. The default routing is read by the id the list gives it. Parameters: - `id` (path, string, required) - `routing_id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `500`: Internal server error Response body (`200`): Content type `application/json`: - `id` (string, required) - `account_sid` (string, required) - `agent_sid` (string, required) - `name` (string, required): Names the routing. The default routing is named `default`. - `condition` (string | null, required): Holds the expression a call is checked against. Rules: - A segment is written by its name. - A segment that the account no longer holds is written by its id. Null on the default routing. - `scenario_sid` (string, required): Names the scenario a call plays when the condition matches. On the default routing it is the agent's scenario. - `is_published` (boolean, required): Reports whether the scenario has a published version. - `position` (integer, required): Places the routing in the order the agent checks them, from 1. The default routing is always last. - `default` (boolean, required): Marks the routing that ends the list. - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) ### Delete a routing `DELETE /v1/a/agent/{id}/routing/{routing_id}` Operation id: `DeleteRouting` Removes the routing and moves the routings after it one place up. Refused for the default routing and while the agent is archived. A second delete finds nothing. Parameters: - `id` (path, string, required) - `routing_id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `204`: Deleted - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `422`: Unprocessable - `500`: Internal server error ### Update a routing `PATCH /v1/a/agent/{id}/routing/{routing_id}` Operation id: `PatchRouting` Partial update; the same rules as on create apply to the result. Refused when: - The agent is archived. - The routing is the default routing. - The condition names a segment the account does not hold. - The condition names a contact field no contact of the account holds, or one that holds fields of its own. - The condition compares a contact field with a value of a type the account's contacts do not hold there. Parameters: - `id` (path, string, required) - `routing_id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Request body: Content type `application/json`: - `name` (string): Names the routing. - `condition` (string): Holds the expression a call is checked against, as `GET /v1/a/agent/-/routing/-/query-language` describes it. - `scenario_sid` (string): Names the scenario a call plays when the condition matches; it may have no published version. - `position` (integer): From 1 to the number of the agent's routings, the default routing not counted. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `422`: Unprocessable - `500`: Internal server error Response body (`200`): Content type `application/json`: - `id` (string, required) - `account_sid` (string, required) - `agent_sid` (string, required) - `name` (string, required): Names the routing. The default routing is named `default`. - `condition` (string | null, required): Holds the expression a call is checked against. Rules: - A segment is written by its name. - A segment that the account no longer holds is written by its id. Null on the default routing. - `scenario_sid` (string, required): Names the scenario a call plays when the condition matches. On the default routing it is the agent's scenario. - `is_published` (boolean, required): Reports whether the scenario has a published version. - `position` (integer, required): Places the routing in the order the agent checks them, from 1. The default routing is always last. - `default` (boolean, required): Marks the routing that ends the list. - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) ### List the fields and operators a routing condition can use `GET /v1/a/agent/-/routing/-/query-language` Operation id: `GetRoutingQueryLanguage` Lists what a routing condition can name: the fields of the call, the time of the call in the agent's time zone, the segments of the contact, and every data field a contact of the account holds with the type it holds there. A data field leaves the list when no contact holds it any more. Parameters: - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `500`: Internal server error Response body (`200`): Content type `application/json`: - `fields` (array of object, required): Lists the call fields, the time fields and `segment` first, then the contact data fields sorted by name. - `name` (string, required): Names the field as a condition writes it, `call.direction` or `contact.address.city`. - `type` (enum(string, number, boolean, array, date, time, datetime, segment), required): Names the type of the field. Values: - `segment`: compares with `=`, `!=`, `IN` and `NOT IN` only, by segment name or id. - `array`: compares with nothing. - `values` (array of string): Lists every value the field can hold. Absent when the set is open. - `operators` (array of enum(=, !=, <, <=, >, >=, IN, NOT IN), required): Lists the operators. - `durations` (array of enum(ms, s, m, h, d), required): Lists the units of a duration that shifts `now`, as in `now - 2h`. ### Archive agent `POST /v1/a/agent/{id}/archive` Operation id: `ArchiveAgent` Archives the agent together with every automation of it, in one step. Effects: - Each running attempt of those automations is stopped, and each waiting one is skipped. - Calls of the agent that were never dialled end as `stopped`, whether an automation placed them or not. - The agent releases its number or pool. - Its name and its lines become free for other agents. The agent stays readable; a patch or a second archive of it is refused. Parameters: - `id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `409`: Conflict - `422`: Unprocessable - `500`: Internal server error Response body (`200`): Content type `application/json`: - `id` (string, required) - `account_sid` (string, required) - `name` (string, required): Unique among the agents of the account that are not archived; archiving or deleting an agent frees its name. - `gateway_type` (enum(number, number_pool), required): Declares the gateway kind. Rules: - The matching sid (`number_sid` / `number_pool_sid`) carries the gateway. - The other sid stays empty. Any other combination of the sids is refused. - `number_sid` (string | null, required) - `number_pool_sid` (string | null, required) - `scenario_sid` (string, required) - `voicemail_enabled` (boolean, required): Turns on answering machine detection for the agent's outbound calls on a scenario whose start call brick is v1. - `call_recording` (boolean, required) - `calling_schedule` (CallingSchedule | null, required): Null when the agent has no window of its own; the platform default (08:00–19:59 every day) then applies. - `timezone` (string, required): Names the IANA zone the calling window is read in, such as `Europe/Warsaw`. When empty, the account's zone applies. - `lines` (integer, required): Simultaneous calls this agent holds, answered and placed together. - `is_test` (boolean, required) - `communication_result` (CommunicationResultConfig | null, required) - `sms` (AgentSms | null, required) - `status` (enum(active, inactive, archived), required): Declares the agent's status. Values: - `inactive`: pauses the agent; it keeps its number or pool, its name and its `lines`. - `archived`: is final and is reached only through archive; written in a create or a patch, it is refused. - `status_changed_at` (string (date-time), required): Records when `status` last changed. - `status_history` (array of object, required): Records every change of `status`, oldest first. - `from` (enum(active, inactive, archived), required): Declares the agent's status. Values: - `inactive`: pauses the agent; it keeps its number or pool, its name and its `lines`. - `archived`: is final and is reached only through archive; written in a create or a patch, it is refused. - `to` (enum(active, inactive, archived), required): Declares the agent's status. Values: - `inactive`: pauses the agent; it keeps its number or pool, its name and its `lines`. - `archived`: is final and is reached only through archive; written in a create or a patch, it is refused. - `at` (string (date-time), required) - `old_number` (string | null, required): Records the `identifier` of the number the agent held when it was archived. Null when: - The agent is not archived yet. - The agent is on a pool. - `old_number_pool` (string | null, required): Records the name of the pool the agent used when it was archived. Null when: - The agent is not archived yet. - The agent is on a number. - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) ### List SMS providers `GET /v1/a/integrations/sms/provider` Operation id: `ListSmsProviders` Each row carries its own registered alphas and numbers inline — the provider object is the one home of the account's senders. Parameters: - `limit` (query, integer): Page size, max 500 (default 100). - `offset` (query, integer) - `status` (query, string) - `access_type` (query, string): Restrict the listing to one administrator: account or tenant. Omit it to list both. - `filter_or` (query, string): Names the fields, comma-separated, that filter_query OR-searches. Values: - `id`: matched exactly. - `name`: matched as a substring, case-insensitive. - `filter_query` (query, string): Search term matched across the fields named in filter_or. - `order_by` (query, string): Sort field. Accepted: created_at (default created_at). - `order` (query, string): Sort direction: asc | desc (default desc). - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `500`: Internal server error Response body (`200`): Content type `application/json`: - `items` (array of object, required) - `id` (string, required) - `account_sid` (string, required) - `name` (string, required) - `type` (enum(http), required): Provider kind; `http` is a generic single-HTTP-call gateway. - `url` (string, required) - `method` (string, required) - `headers` (array of object, required) - `name` (string, required) - `value` (string, required): Template variables ({{from}}, {{to}}, {{text}}) allowed. - `body_template` (string, required) - `alphas` (array of string, required) - `numbers` (array of string, required) - `status` (enum(active, inactive), required): Says whether the provider is active. While the provider is `inactive`: - The provider is never called. - A send is recorded and answered with status failed. - Its config stays editable. - `access_type` (enum(account, tenant), required): Field declares an owner of created model. account or tenant - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) - `total` (integer (int64), required): Counts the providers matching the query, ignoring paging. - `limit` (integer, required): Reports the page size applied to this request. - `offset` (integer, required): Reports the offset applied to this request. - `has_more` (boolean, required): Says whether records beyond this page match the query. ### Create SMS provider `POST /v1/a/integrations/sms/provider` Operation id: `CreateSmsProvider` Records the gateway; nothing is sent to it here, so a test send is what proves the configuration works. Rules: - `method`: defaults to POST. - `status`: defaults to active. By principal: - A caller with the role `tenant_admin` creates a tenant-administered config unless it sends `account`. - Any other caller creates an account-administered one, and `tenant` from it is ignored. Parameters: - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Request body: Content type `application/json`: - `name` (string, required) - `type` (enum(http)): Provider kind; `http` is a generic single-HTTP-call gateway. - `url` (string, required): Sets the send endpoint. Template variables ({{from}}, {{to}}, {{text}}) allowed. - `method` (string): Sets the HTTP method, default POST. - `headers` (array of object) - `name` (string, required) - `value` (string, required): Template variables ({{from}}, {{to}}, {{text}}) allowed. - `body_template` (string, required): Sets the request-body template. Template variables ({{from}}, {{to}}, {{text}}) allowed. - `alphas` (array of string) - `numbers` (array of string) - `status` (enum(active, inactive)): Says whether the provider is active. While the provider is `inactive`: - The provider is never called. - A send is recorded and answered with status failed. - Its config stays editable. - `access_type` (enum(account, tenant)): Field declares an owner of created model. account or tenant Responses: - `201`: Created - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `422`: Unprocessable - `500`: Internal server error Response body (`201`): Content type `application/json`: - `id` (string, required) - `account_sid` (string, required) - `name` (string, required) - `type` (enum(http), required): Provider kind; `http` is a generic single-HTTP-call gateway. - `url` (string, required) - `method` (string, required) - `headers` (array of object, required) - `name` (string, required) - `value` (string, required): Template variables ({{from}}, {{to}}, {{text}}) allowed. - `body_template` (string, required) - `alphas` (array of string, required) - `numbers` (array of string, required) - `status` (enum(active, inactive), required): Says whether the provider is active. While the provider is `inactive`: - The provider is never called. - A send is recorded and answered with status failed. - Its config stays editable. - `access_type` (enum(account, tenant), required): Field declares an owner of created model. account or tenant - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) ### Get SMS provider `GET /v1/a/integrations/sms/provider/{id}` Operation id: `GetSmsProvider` The gateway configuration, with the alphas and numbers registered on it inline. Parameters: - `id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `500`: Internal server error Response body (`200`): Content type `application/json`: - `id` (string, required) - `account_sid` (string, required) - `name` (string, required) - `type` (enum(http), required): Provider kind; `http` is a generic single-HTTP-call gateway. - `url` (string, required) - `method` (string, required) - `headers` (array of object, required) - `name` (string, required) - `value` (string, required): Template variables ({{from}}, {{to}}, {{text}}) allowed. - `body_template` (string, required) - `alphas` (array of string, required) - `numbers` (array of string, required) - `status` (enum(active, inactive), required): Says whether the provider is active. While the provider is `inactive`: - The provider is never called. - A send is recorded and answered with status failed. - Its config stays editable. - `access_type` (enum(account, tenant), required): Field declares an owner of created model. account or tenant - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) ### Delete SMS provider `DELETE /v1/a/integrations/sms/provider/{id}` Operation id: `DeleteSmsProvider` Deletes the provider. Refused when: - An agent that is not archived references the provider. - The provider is tenant-administered and the caller does not have the role `tenant_admin`. Parameters: - `id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `204`: No content - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `409`: Conflict - `500`: Internal server error ### Update SMS provider `PATCH /v1/a/integrations/sms/provider/{id}` Operation id: `PatchSmsProvider` Updates the provider and validates the merged result, not the payload. Rules: - The gateway is not contacted. - A tenant-administered provider is read-only to a caller without the role `tenant_admin`, whichever field the request names. - `access_type` moves only for a caller with the role `tenant_admin`; submitted by anyone else it is ignored and the stored value stands. Parameters: - `id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Request body: Content type `application/json`: - `name` (string) - `type` (enum(http)): Provider kind; `http` is a generic single-HTTP-call gateway. - `url` (string) - `method` (string) - `headers` (array | null) - `body_template` (string) - `alphas` (array | null) - `numbers` (array | null) - `status` (enum(active, inactive)): Says whether the provider is active. While the provider is `inactive`: - The provider is never called. - A send is recorded and answered with status failed. - Its config stays editable. - `access_type` (enum(account, tenant)): Field declares an owner of created model. account or tenant Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `422`: Unprocessable - `500`: Internal server error Response body (`200`): Content type `application/json`: - `id` (string, required) - `account_sid` (string, required) - `name` (string, required) - `type` (enum(http), required): Provider kind; `http` is a generic single-HTTP-call gateway. - `url` (string, required) - `method` (string, required) - `headers` (array of object, required) - `name` (string, required) - `value` (string, required): Template variables ({{from}}, {{to}}, {{text}}) allowed. - `body_template` (string, required) - `alphas` (array of string, required) - `numbers` (array of string, required) - `status` (enum(active, inactive), required): Says whether the provider is active. While the provider is `inactive`: - The provider is never called. - A send is recorded and answered with status failed. - Its config stays editable. - `access_type` (enum(account, tenant), required): Field declares an owner of created model. account or tenant - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) ### Send SMS `POST /v1/a/integrations/sms/send` Operation id: `SendSms` Sends the message and records the attempt. When the gateway refuses or the provider is inactive: - The call still succeeds and answers with the record. - The record carries `status: "failed"` and the reason. Parameters: - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Request body: Content type `application/json`: - `communication_sid` (string) - `provider_sid` (string) - `from_alpha` (string): Sets the sender alpha on a direct send: one of the provider's registered alphas. Rules: - At least one of `from_alpha` and `from_number` accompanies `provider_sid`. - `from_alpha` wins when both are set. Refused when `from_alpha` or `from_number` is sent alongside `communication_sid`. - `from_number` (string): Sets the sender number on a direct send: one of the provider's registered numbers. Rules: - It is used when `from_alpha` is absent. - It accompanies `provider_sid` only. Refused when it is sent alongside `communication_sid`. - `to` (string, required) - `text` (string, required) - `variables` (object): Carries values for additional `{{name}}` template variables. Rules: - They are substituted into the provider config, where the reserved `from`, `to` and `text` variables always win over a same-named entry. - They are also substituted into `text` itself, where the reserved names carry no such protection. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `422`: Unprocessable - `500`: Internal server error Response body (`200`): Content type `application/json`: - `id` (string, required): Identifies the recorded sms row (sms_…). - `status` (enum(sent, failed), required) - `from` (string, required): Records the resolved sender identity the message was sent as. - `to` (string, required): Records the resolved recipient. - `http_status` (integer | null, required): Records the provider response status; null when no response was received. - `error` (string | null, required) ### Upload audio file `POST /v1/a/audio` Operation id: `UploadAudio` Stores a file for scenario bricks to play. Rules: - The part's own content type is preserved, and `audio/wav` is used when it carries none. - The client filename is kept as provenance. Parameters: - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Request body: Content type `multipart/form-data`: - `file` (string (binary), required) Responses: - `201`: Created - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `413`: Request body exceeds the 32 MiB upload limit - `500`: Internal server error Response body (`201`): Content type `application/json`: - `id` (string, required) - `location` (string, required): Serves the file over the API. It never expires, and fetching it needs the same credentials and account scope as the rest of the API, which makes it the reference for API consumers and authoring preview. - `filename` (string, required): Names the stored file: aud_.wav. - `content_type` (string, required): Declares the content type the file is stored and served with. - `url` (string, required): Points at the stored object by its permanent canonical storage URI (e.g. gs:///) — the reference a scenario brick embeds, read straight from storage by the call runtime. - `provider` (string, required): Names the storage provider holding the object (e.g. gcs); discriminates the url scheme. ### Get audio file (proxied or presigned link) `GET /v1/a/audio/{filename}` Operation id: `GetAudio` Serves a stored file. By mode: - The default: the bytes stream back with the content type they were stored under. - `mode=url`: the answer is a time-bounded presigned link instead. Parameters: - `filename` (path, string, required): Stored audio basename, `aud_.wav`; anything else is not found. - `mode` (query, string): Sets how the audio is served. Values: - `url`: returns a presigned download link. - Every other value, including the default, streams the audio through athena. - `expire` (query, integer): Sets the presigned link lifetime in seconds. Rules: - It applies in url mode only. - The default is 3600 (1h). - Anything outside 1 to 604800 (7d) is refused. - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: Returns what the mode asks for. By mode: - `url`: returns a presigned link. - Any other mode: returns the raw audio bytes. - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `500`: Internal server error Response body (`200`): Content type `application/json`: - `signed_url` (string, required) - `expires_at` (string (date-time), required) ### Login `POST /v1/a/auth/regular` Operation id: `AuthRegularLogin` Exchanges email + password for a session token. An unknown address, a wrong password, an inactive user and a user with no password set all answer alike. Request body: Content type `application/json`: - `email` (string, required) - `password` (string, required) Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `422`: Unprocessable - `429`: Too many requests - `500`: Internal server error Response body (`200`): Content type `application/json`: - `session_token` (string, required) - `user_sid` (string, required) - `account_sid` (string | null, required): Names the account the session is scoped to; null for a tenant-level user, whose session carries tenant scope. - `tenant_sid` (string, required) - `email` (string, required) ### Consume magic link `POST /v1/a/auth/magic-link/consume` Operation id: `AuthMagicConsume` Exchanges a magic-link token, issued through the `/v1/a/user/{sid}/magic-link/request` handoff, for a session token. The exchange spends the token. Request body: Content type `application/json`: - `token` (string, required) Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `429`: Too many requests - `500`: Internal server error Response body (`200`): Content type `application/json`: - `session_token` (string, required) - `user_sid` (string, required) - `account_sid` (string | null, required): Names the account the session is scoped to; null for a tenant-level user, whose session carries tenant scope. - `tenant_sid` (string, required) - `email` (string, required) ### Change password `POST /v1/a/auth/password/change` Operation id: `AuthPasswordChange` Changes the password of the authenticated user. Effects: - The user's other sessions are revoked. - The calling token keeps working. Only a session token opens this route. Request body: Content type `application/json`: - `current_password` (string, required) - `new_password` (string, required) Responses: - `204`: No content - `400`: Bad request - `401`: Unauthorized - `422`: Unprocessable - `500`: Internal server error ### Consume password reset `POST /v1/a/auth/password-reset/consume` Operation id: `AuthPasswordResetConsume` Sets a new password from a password-reset token, issued through the `/v1/a/user/{sid}/password-reset/request` handoff, and returns a session. Effects: - The token is spent by the exchange. - Sessions the user already holds are left standing. Request body: Content type `application/json`: - `token` (string, required) - `new_password` (string, required) Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `422`: Unprocessable - `429`: Too many requests - `500`: Internal server error Response body (`200`): Content type `application/json`: - `session_token` (string, required) - `user_sid` (string, required) - `account_sid` (string | null, required): Names the account the session is scoped to; null for a tenant-level user, whose session carries tenant scope. - `tenant_sid` (string, required) - `email` (string, required) ### Logout `POST /v1/a/auth/logout` Operation id: `AuthLogout` Revokes the current session token. Responses: - `204`: No content - `500`: Internal server error ### List users `GET /v1/a/user` Operation id: `ListUsers` The users of one account. Parameters: - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. - `show_deleted` (query, boolean): Include soft-deleted users in the listing. - `filter_or` (query, string): Names the fields, comma-separated, that `filter_query` searches with OR. It accepts `name` and `email`, each matched as a substring, case-insensitive. Refused when: - One of `filter_or` and `filter_query` is sent without the other. - A field is unknown. - `filter_query` (query, string): Search term matched across the fields named in filter_or. - `order_by` (query, string): Sort field. Accepted: created_at, name, email (default created_at). - `order` (query, string): Sort direction: asc | desc (default desc). - `limit` (query, integer): Page size, max 500 (default 100). - `offset` (query, integer) Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found Response body (`200`): Content type `application/json`: - `items` (array of object, required) - `sid` (string, required) - `account_sid` (string | null, required): Names the owning account; null for a tenant-level user. - `tenant_sid` (string | null, required): Names the owning tenant; null for an account-level user. - `level` (enum(account, tenant), required): Declares the owner of the user: account or tenant. - `email` (string, required) - `name` (string, required) - `external_id` (string, required): Carries the key the client system provisioning this user assigned to them. When set, unique among the live users of the account, or among the live tenant-level users of the tenant. - `roles` (array of string, required): Lists the names of the roles the user holds. - `status` (enum(active, inactive), required) - `has_password` (boolean, required): Says whether the user can sign in with a password. One created without one gets in only through a magic link or a password reset. - `last_login_at` (string | null (date-time), required) - `deleted_at` (string | null (date-time), required) - `total` (integer (int64), required): Counts the users matching the query, ignoring paging. - `limit` (integer, required): Reports the page size applied to this request. - `offset` (integer, required): Reports the offset applied to this request. - `has_more` (boolean, required): Says whether records beyond this page match the query. ### Create user `POST /v1/a/user` Operation id: `CreateUser` Creates the user active. `password` is optional; without one the user gets in only through a magic-link or password-reset handoff. While the tenant declares `user` in `managed_resources`, only a caller with the role `tenant_admin` creates one, and `external_id` is required. Parameters: - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Request body: Content type `application/json`: - `email` (string (email), required) - `name` (string) - `external_id` (string) - `password` (string): Sets the password the user signs in with. - `roles` (array of string): Names of roles listed by `GET /v1/a/role`; omitted means no roles until a patch assigns them. Responses: - `201`: Created - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `409`: Conflict - `422`: Unprocessable Response body (`201`): Content type `application/json`: - `sid` (string, required) - `account_sid` (string | null, required): Names the owning account; null for a tenant-level user. - `tenant_sid` (string | null, required): Names the owning tenant; null for an account-level user. - `level` (enum(account, tenant), required): Declares the owner of the user: account or tenant. - `email` (string, required) - `name` (string, required) - `external_id` (string, required): Carries the key the client system provisioning this user assigned to them. When set, unique among the live users of the account, or among the live tenant-level users of the tenant. - `roles` (array of string, required): Lists the names of the roles the user holds. - `status` (enum(active, inactive), required) - `has_password` (boolean, required): Says whether the user can sign in with a password. One created without one gets in only through a magic link or a password reset. - `last_login_at` (string | null (date-time), required) - `deleted_at` (string | null (date-time), required) ### Get user by external identifier `GET /v1/a/user/-/external/{external_id}` Operation id: `GetUserByExternalID` Resolves the user the calling account gave this key, without the caller knowing the platform sid. Parameters: - `external_id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found Response body (`200`): Content type `application/json`: - `sid` (string, required) - `account_sid` (string | null, required): Names the owning account; null for a tenant-level user. - `tenant_sid` (string | null, required): Names the owning tenant; null for an account-level user. - `level` (enum(account, tenant), required): Declares the owner of the user: account or tenant. - `email` (string, required) - `name` (string, required) - `external_id` (string, required): Carries the key the client system provisioning this user assigned to them. When set, unique among the live users of the account, or among the live tenant-level users of the tenant. - `roles` (array of string, required): Lists the names of the roles the user holds. - `status` (enum(active, inactive), required) - `has_password` (boolean, required): Says whether the user can sign in with a password. One created without one gets in only through a magic link or a password reset. - `last_login_at` (string | null (date-time), required) - `deleted_at` (string | null (date-time), required) ### Delete user by external identifier `DELETE /v1/a/user/-/external/{external_id}` Operation id: `DeleteUserByExternalID` Deletes the user the calling account gave this key, without the caller knowing the platform sid. Rules: - The delete is soft, as by sid. - The key is released for reuse by a live user. Refused when: - The tenant declares `user` in `managed_resources` and the caller does not hold the role `tenant_admin`. - The user's roles carry a permission the caller does not hold. Parameters: - `external_id` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `204`: No content - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found ### Get user `GET /v1/a/user/{sid}` Operation id: `GetUser` One user of the account. Parameters: - `sid` (path, string, required) Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found Response body (`200`): Content type `application/json`: - `sid` (string, required) - `account_sid` (string | null, required): Names the owning account; null for a tenant-level user. - `tenant_sid` (string | null, required): Names the owning tenant; null for an account-level user. - `level` (enum(account, tenant), required): Declares the owner of the user: account or tenant. - `email` (string, required) - `name` (string, required) - `external_id` (string, required): Carries the key the client system provisioning this user assigned to them. When set, unique among the live users of the account, or among the live tenant-level users of the tenant. - `roles` (array of string, required): Lists the names of the roles the user holds. - `status` (enum(active, inactive), required) - `has_password` (boolean, required): Says whether the user can sign in with a password. One created without one gets in only through a magic link or a password reset. - `last_login_at` (string | null (date-time), required) - `deleted_at` (string | null (date-time), required) ### Delete user `DELETE /v1/a/user/{sid}` Operation id: `DeleteUser` Soft-deletes the user. Rules: - The user reads as absent afterwards but still appears under `show_deleted`. - The email address is free to use again. Effects: - Its credentials are removed at once, so every session and outstanding token stops working. Refused when: - The tenant declares `user` in `managed_resources` and the caller does not hold the role `tenant_admin`. - The user's roles carry a permission the caller does not hold. Parameters: - `sid` (path, string, required) Responses: - `204`: No content - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found ### Update user `PATCH /v1/a/user/{sid}` Operation id: `PatchUser` `email` replaces the address the user signs in with. Setting `status` to inactive stops the user obtaining a new session, whether by password, magic link or password reset, and ends the sessions, magic links and reset tokens they already hold; setting it back to active restores none of them. While the tenant declares `user` in `managed_resources`, a caller without the role `tenant_admin` may send `status`, in either direction, and nothing else. The caller's own user is edited through `/v1/a/profile`, never here. Refused when the user's roles carry a permission the caller does not hold. Parameters: - `sid` (path, string, required) Request body: Content type `application/json`: - `name` (string) - `email` (string (email)): Replaces the address the user signs in with; unique among the live users of its level. - `external_id` (string) - `roles` (array of string): Replaces the user's roles outright with names of roles listed by `GET /v1/a/role`. - `status` (enum(active, inactive)) - `password` (string): Replaces the password the user signs in with; an empty string removes it. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `409`: Conflict - `422`: Unprocessable Response body (`200`): Content type `application/json`: - `sid` (string, required) - `account_sid` (string | null, required): Names the owning account; null for a tenant-level user. - `tenant_sid` (string | null, required): Names the owning tenant; null for an account-level user. - `level` (enum(account, tenant), required): Declares the owner of the user: account or tenant. - `email` (string, required) - `name` (string, required) - `external_id` (string, required): Carries the key the client system provisioning this user assigned to them. When set, unique among the live users of the account, or among the live tenant-level users of the tenant. - `roles` (array of string, required): Lists the names of the roles the user holds. - `status` (enum(active, inactive), required) - `has_password` (boolean, required): Says whether the user can sign in with a password. One created without one gets in only through a magic link or a password reset. - `last_login_at` (string | null (date-time), required) - `deleted_at` (string | null (date-time), required) ### Request user magic link `POST /v1/a/user/{sid}/magic-link/request` Operation id: `IssueUserMagicLink` Returns a single-use magic-link token for the user, with the consume URL and a browser link (`web_url`) into the web frontend that signs the person in. Rules: - The platform sends no email; the caller delivers the link, or the token, to the user through its own channel. - A new token invalidates the previous outstanding one. - Nothing is created for a user who could not use it. - The call stays open to every caller whatever the tenant declares in `managed_resources`. Refused when the user's roles carry a permission the caller does not hold. Parameters: - `sid` (path, string, required) Responses: - `201`: Created - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `409`: Conflict Response body (`201`): Content type `application/json`: - `token` (string, required) - `expires_at` (string (date-time), required) - `consume_url` (string, required): Points at the public consume endpoint the token is redeemed at. - `web_url` (string, required): Signs the person in from a browser link — the web frontend's consume page carrying the token. ### Request user password reset `POST /v1/a/user/{sid}/password-reset/request` Operation id: `IssueUserPasswordReset` Creates a single-use password-reset token for the user and returns it with the consume URL. Rules: - Issuing a second one retires the first. - Delivery is the caller's, since the platform sends no email. - While the tenant declares `user` in `managed_resources`, a caller without the role `tenant_admin` uses `/v1/a/user/{sid}/magic-link/request` instead. Refused when: - The tenant declares `user` in `managed_resources` and the caller does not hold the role `tenant_admin`. - The user's roles carry a permission the caller does not hold. Parameters: - `sid` (path, string, required) Responses: - `201`: Created - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `409`: Conflict Response body (`201`): Content type `application/json`: - `token` (string, required) - `expires_at` (string (date-time), required) - `consume_url` (string, required): Points at the public consume endpoint the token is redeemed at. ### List the account's API keys `GET /v1/a/user/-/api-key` Operation id: `ListAccountAPIKeys` Lists the keys owned by the account's users, newest first, without the secret. Rules: - A revoked key leaves the list. - A key leaves the list when its owner is deleted. - An expired key leaves the list. Parameters: - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. - `order_by` (query, string): Sort field. Accepted: created_at, name, expires_at, last_used_at (default created_at). - `order` (query, string): Sort direction: asc | desc (default desc). - `limit` (query, integer): Page size, max 500 (default 100). - `offset` (query, integer) Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found Response body (`200`): Content type `application/json`: - `items` (array of object, required) - `sid` (string, required) - `name` (string, required) - `user_sid` (string, required): Names the owner. - `account_sid` (string | null, required): Names the owner's account; null for a tenant-level owner. - `level` (enum(account, tenant), required): Declares the owner's level: account or tenant. - `metadata` (object, required): Carries the object given at issue, as given. - `created_at` (string (date-time), required) - `expires_at` (string | null (date-time), required): Records when the key stops authenticating. - `last_used_at` (string | null (date-time), required): Records the last request the key authenticated; null while it has not been used. - `total` (integer (int64), required): Counts the keys matching the query, ignoring paging. - `limit` (integer, required): Reports the page size applied to this request. - `offset` (integer, required): Reports the offset applied to this request. - `has_more` (boolean, required): Says whether records beyond this page match the query. ### List a user's API keys `GET /v1/a/user/{sid}/api-key` Operation id: `ListUserAPIKeys` The keys the user owns, in the same shape as the account's list. Parameters: - `sid` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. - `order_by` (query, string): Sort field. Accepted: created_at, name, expires_at, last_used_at (default created_at). - `order` (query, string): Sort direction: asc | desc (default desc). - `limit` (query, integer): Page size, max 500 (default 100). - `offset` (query, integer) Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found Response body (`200`): Content type `application/json`: - `items` (array of object, required) - `sid` (string, required) - `name` (string, required) - `user_sid` (string, required): Names the owner. - `account_sid` (string | null, required): Names the owner's account; null for a tenant-level owner. - `level` (enum(account, tenant), required): Declares the owner's level: account or tenant. - `metadata` (object, required): Carries the object given at issue, as given. - `created_at` (string (date-time), required) - `expires_at` (string | null (date-time), required): Records when the key stops authenticating. - `last_used_at` (string | null (date-time), required): Records the last request the key authenticated; null while it has not been used. - `total` (integer (int64), required): Counts the keys matching the query, ignoring paging. - `limit` (integer, required): Reports the page size applied to this request. - `offset` (integer, required): Reports the offset applied to this request. - `has_more` (boolean, required): Says whether records beyond this page match the query. ### Issue user API key `POST /v1/a/user/{sid}/api-key` Operation id: `IssueUserAPIKey` Creates an API key owned by the user and returns its secret once; only a hash is kept, so a lost secret cannot be recovered. Rules: - The key acts with the user's roles at the user's account. - The key stops authenticating while the user, their account or its tenant is not active, and works again once they are. - Omitting `expires_at` creates a key that expires one year after issue. - Earlier keys stay valid: issuing revokes nothing. - A key stops working when its `expires_at` passes, its user is deleted or it is revoked. Refused when the user's roles carry a permission the caller does not hold. Parameters: - `sid` (path, string, required) Request body: Content type `application/json`: - `name` (string, required): Labels the key in listings. - `expires_at` (string (date-time)): Sets when the key stops authenticating. Omitted, the key expires one year after issue. - `metadata` (object): Carries the caller's own note on the key, held and returned as given. Nothing in it is read by the platform. Responses: - `201`: Created - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `409`: Conflict - `422`: Unprocessable Response body (`201`): Content type `application/json`: - `sid` (string, required) - `secret` (string, required) ### Revoke a user's API key `DELETE /v1/a/user/{sid}/api-key/{key_sid}` Operation id: `RevokeUserAPIKey` Deletes the key. Rules: - The key authenticates nothing from the next request on. - The user's other keys are untouched. Refused when the user's roles carry a permission the caller does not hold. Parameters: - `sid` (path, string, required) - `key_sid` (path, string, required) - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `204`: No content - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found ### List account roles `GET /v1/a/role` Operation id: `ListAccountRoles` The live `account` roles of the account's tenant: the roles an account-level user can hold. The fixed roles come first. Parameters: - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. - `order_by` (query, string): Sort field. Accepted: created_at, name (default created_at). - `order` (query, string): Sort direction: asc | desc (default desc). - `limit` (query, integer): Page size, max 500 (default 100). - `offset` (query, integer) Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found Response body (`200`): Content type `application/json`: - `items` (array of object, required) - `id` (string, required): Prefixed `rol_…`. - `name` (string, required) - `level` (any, required): Declares who holds the role. Values: - `account`: the role is held by users of either level. - `tenant`: the role is held by tenant-level users only. - `permissions` (array of enum(agent:read, agent:write, agent:manage, agent:automation:read, agent:automation:write, agent:automation:manage, agent:routing:read, agent:routing:write, agent:routing:manage, scenario:read, scenario:write, scenario:manage, communication:read, communication:write, communication:manage, number:read, number:write, number:manage, number:pool:read, number:pool:write, number:pool:manage, contact:read, contact:write, contact:manage, segment:read, segment:write, segment:manage, integration:sms:read, integration:sms:write, integration:sms:manage, account:read, account:manage, account:capacity:manage, tenant:user:read, tenant:user:manage, tenant:api_key:manage, tenant:sign_in:manage, tenant:role:read, tenant:role:manage, tenant:scenario_template:manage, scenario:template:read, analytics:read, account:user:manage, account:api_key:manage, account:sign_in:manage, account:profile:write, account:role:read, tts:synthesize:manage, tts:voice:read, llm:chat:manage, llm:document:manage, llm:model:read, ids:classifier:write, ids:classifier:manage, ids:entity:write, ids:model:read, stt:recognition:write, stt:dictionary:read, stt:dictionary:write, stt:dictionary:manage, edge:function:read, edge:function:write, edge:function:manage), required): Lists the role's own permissions, without the ones its parents carry. - `inherits` (array of string, required): Lists the `id` of every parent role, a role whose permissions this one inherits. - `fixed` (boolean, required): Declares a role defined by the platform. Refused when: - A fixed role is edited. - A fixed role is deleted. - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) - `total` (integer (int64), required): Counts the roles matching the query, ignoring paging. - `limit` (integer, required): Reports the page size applied to this request. - `offset` (integer, required): Reports the offset applied to this request. - `has_more` (boolean, required): Says whether records beyond this page match the query. ### List scenario templates `GET /v1/a/scenario-template` Operation id: `ListAccountScenarioTemplates` The live templates of the account's tenant, without `constructor`. Parameters: - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. - `order_by` (query, string): Sort field. Accepted: created_at, name (default created_at). - `order` (query, string): Sort direction: asc | desc (default desc). - `limit` (query, integer): Page size, max 500 (default 100). - `offset` (query, integer) Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found Response body (`200`): Content type `application/json`: - `items` (array of object, required) - `id` (string, required): Prefixed `sct_…`. - `name` (string, required) - `description` (string, required) - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) - `total` (integer (int64), required): Counts the templates matching the query, ignoring paging. - `limit` (integer, required): Reports the page size applied to this request. - `offset` (integer, required): Reports the offset applied to this request. - `has_more` (boolean, required): Says whether records beyond this page match the query. ### Get scenario template `GET /v1/a/scenario-template/{id}` Operation id: `GetAccountScenarioTemplate` One template of the account's tenant, with `constructor`. Parameters: - `id` (path, string, required): The template's `id`. - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found Response body (`200`): Content type `application/json`: - `id` (string, required): Prefixed `sct_…`. - `name` (string, required) - `description` (string, required) - `constructor` (object, required) - `bricks` (object): Holds the properties of a brick, one key per brick type. Rules: - A text property reads a variable when it holds `{{name}}`, and a contact field when it holds `{{contact.}}`; the call puts the value in place when the brick runs. - A number, a boolean and an enum property take no variable. - `start_call`, `inbound_call`, `outbound_call`, `recording_setup`, `tree`, `start_tree`, `end_tree` and `end`: no property takes a variable. - `condition_group` and `assignment`: only `value` takes a variable. - `webhook`: only the method, the URL, the body, the names and values of the headers and of the form fields, the basic-auth username and password, the bearer token, the proxy URL, and the `path` and `set_if_not_found` of a response mapping take a variable. - A property that names a variable to write, such as `variable` of a response mapping or of `increment`, is written to and not read. - The guide with examples: https://docs.aiva.apifonica.com/guides/build/variables/ - `audio` (object) - `v1` (array of object) - `audio_file` (object) - `v1` (array of object) - `audio_tts` (object) - `v1` (array of object) - `sms` (object) - `v1` (array of object) - `goal` (object) - `v1` (array of object) - `end_call` (object) - `v1` (array of object) - `assignment` (object) - `v1` (array of object) - `increment` (object) - `v1` (array of object) - `condition_group` (object) - `v1` (array of object) - `start_tree` (object) - `v1` (array of object) - `start_call` (object) - `v1` (array of object) - `v2` (array of object) - `outbound_call` (object) - `v1` (array of object) - `inbound_call` (object) - `v1` (array of object) - `end` (object) - `v1` (array of object) - `call_transfer` (object) - `v1` (array of object) - `question` (object) - `v1` (array of object) - `webhook` (object) - `v1` (array of object) - `data_mapping` (object) - `v1` (array of object) - `tree` (object) - `v1` (array of object) - `end_tree` (object) - `v1` (array of object) - `background_audio` (object) - `v1` (array of object) - `javascript` (object) - `v1` (array of object) - `warm_up_tts` (object) - `v1` (array of object) - `business_metric` (object) - `v1` (array of object) - `ai_agent` (object) - `v1` (array of object) - `send_dtmf` (object) - `v1` (array of object) - `recording_setup` (object) - `v1` (array of object) - `transcription` (object) - `v1` (array of object) - `forest` (object) - `trees` (array of object) - `description` (string) - `tree_id` (string) - `nodes` (array of object) - `properties` (object) - `engine_version` (enum(v3)): Any value sent is stored as v3. - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) ### Copy scenario template into the account `POST /v1/a/scenario-template/{id}/copy` Operation id: `CopyScenarioTemplate` Creates a scenario in the caller's account from a template of the account's tenant. Rules: - The scenario starts unpublished: `version` 0, the template content as its work-in-progress draft. - Every classifier, edge function, RAG document and audio file the template names is created again in the account, and the scenario names the new ones. - Webhook authentication is not copied. - A later change or delete of the template does not change the scenario. Refused when: - The account made a copy, of a template or of a shared scenario, less than a minute ago. - A resource the template names cannot be copied. Nothing is created then. Parameters: - `id` (path, string, required): The template's `id`. - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `201`: Created - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `422`: Unprocessable - `429`: Too many requests Response body (`201`): Content type `application/json`: - `id` (string, required) - `type` (enum(constructor), required) - `name` (string, required) - `template` (string, required) - `description` (string, required) - `account_sid` (string, required) - `constructor` (Constructor | null, required) - `fix_communication_ttl` (integer, required) - `is_shared_for_copy` (boolean, required): Shares the scenario for read and copy with other accounts of the owning tenant. Rules: - The permission of each operation still applies. - Outside the owning tenant, the scenario is absent. - Writes are unaffected. - `GET /v1/a/scenario` still lists the caller's own account alone. - A shared scenario does resolve into another resource's `included` map. - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) - `version` (integer, required) - `draft_exists` (boolean, required) - `is_published` (boolean, required): Says whether a version has been published. false while the scenario exists as a draft only. ### Get own profile `GET /v1/a/profile` Operation id: `GetProfile` Returns the caller's own user, the account it belongs to, the feature flags evaluated for that account, the permissions the caller holds and the links of the caller's tenant, resolved from the bearer token. The route needs a user behind the token. Responses: - `200`: OK - `401`: Unauthorized - `403`: Forbidden Response body (`200`): Content type `application/json`: - `user` (object, required) - `sid` (string, required) - `account_sid` (string | null, required): Names the owning account; null for a tenant-level caller. - `tenant_sid` (string | null, required): Names the owning tenant; null for an account-level caller. - `level` (enum(account, tenant), required): Declares the owner of the caller: account or tenant. - `email` (string, required) - `name` (string, required) - `external_id` (string, required): Carries the key the client system provisioning this user assigned to them; empty when unset. - `roles` (array of string, required) - `status` (enum(active, inactive), required) - `has_password` (boolean, required): Says whether the user can sign in with a password. One created without one gets in only through a magic link or a password reset. - `last_login_at` (string | null (date-time), required) - `account` (ProfileAccount | null, required): Carries the account-shaped half of the profile; null for a tenant-level caller, who has none. - `feature_flags` (object, required): Every declared feature flag evaluated for the caller's account. The set is closed, so each flag is present whatever its value. - `global_llm` (boolean, required) - `global_stt` (boolean, required) - `global_tts` (boolean, required) - `sentry_enabled` (boolean, required): Declares whether the client may send its errors, traces and session replays to an error tracker. - `managed_resources` (any, required): Declares what the caller's own tenant provisions, as it applies to this account. - `account` (boolean, required): Declares that the tenant provisions its own accounts. Refused when: - An account is created without an `external_id`. - The account edits its own contact fields through `/v1/a/profile`. The account and profile operations name the codes. - `user` (boolean, required): Declares that the tenant provisions its accounts' users. For a caller without the role `tenant_admin`: - Creating, changing or deleting a user is refused. - Resetting a user's password is refused. - Switching users on and off stays allowed. - The magic link stays open. The user operations name the code. - `number` (boolean, required): Declares that the tenant provisions its accounts' numbers: a caller without the role `tenant_admin` that creates, changes or deletes one is refused, but still switches them on and off; the number operations name the code. - `number_pool` (boolean, required): Declares that the tenant provisions its accounts' number pools, on the same terms as `number`. - `permissions` (array of enum(agent:read, agent:write, agent:manage, agent:automation:read, agent:automation:write, agent:automation:manage, agent:routing:read, agent:routing:write, agent:routing:manage, scenario:read, scenario:write, scenario:manage, communication:read, communication:write, communication:manage, number:read, number:write, number:manage, number:pool:read, number:pool:write, number:pool:manage, contact:read, contact:write, contact:manage, segment:read, segment:write, segment:manage, integration:sms:read, integration:sms:write, integration:sms:manage, account:read, account:manage, account:capacity:manage, tenant:user:read, tenant:user:manage, tenant:api_key:manage, tenant:sign_in:manage, tenant:role:read, tenant:role:manage, tenant:scenario_template:manage, scenario:template:read, analytics:read, account:user:manage, account:api_key:manage, account:sign_in:manage, account:profile:write, account:role:read, tts:synthesize:manage, tts:voice:read, llm:chat:manage, llm:document:manage, llm:model:read, ids:classifier:write, ids:classifier:manage, ids:entity:write, ids:model:read, stt:recognition:write, stt:dictionary:read, stt:dictionary:write, stt:dictionary:manage, edge:function:read, edge:function:write, edge:function:manage), required): Lists every permission the caller holds, sorted by name. A route that requires one admits the caller only when it is in this list. - `links` (array of object, required): Lists the links the caller's tenant places in the interface, in the order a client shows them; the same for every caller of the tenant. - `title` (string, required): Carries the text a client shows for the link; it carries no `<` or `>`. - `url` (string, required): Carries the `https` address the link opens. - `group` (string, required): Carries the label a client groups the link under; empty for none. It carries no `<` or `>`. ### Update own profile `PATCH /v1/a/profile` Operation id: `PatchProfile` Partially updates the caller's own user and account. The groups: - `user`: carries `name` and `email`. - `account`: carries `name`, `country`, `timezone` and `phone`. Rules: - An omitted group preserves the current value. - An omitted field within a group preserves the current value. A field outside these groups is refused, never ignored. Request body: Content type `application/json`: - `user` (object) - `name` (string) - `email` (string (email)): Replaces the address the person signs in with; unique among live account-level users. - `account` (object) - `name` (string) - `country` (string) - `timezone` (string) - `phone` (string): Digits only, no separators. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `409`: Conflict - `422`: Unprocessable Response body (`200`): Content type `application/json`: - `user` (object, required) - `sid` (string, required) - `account_sid` (string | null, required): Names the owning account; null for a tenant-level caller. - `tenant_sid` (string | null, required): Names the owning tenant; null for an account-level caller. - `level` (enum(account, tenant), required): Declares the owner of the caller: account or tenant. - `email` (string, required) - `name` (string, required) - `external_id` (string, required): Carries the key the client system provisioning this user assigned to them; empty when unset. - `roles` (array of string, required) - `status` (enum(active, inactive), required) - `has_password` (boolean, required): Says whether the user can sign in with a password. One created without one gets in only through a magic link or a password reset. - `last_login_at` (string | null (date-time), required) - `account` (ProfileAccount | null, required): Carries the account-shaped half of the profile; null for a tenant-level caller, who has none. - `feature_flags` (object, required): Every declared feature flag evaluated for the caller's account. The set is closed, so each flag is present whatever its value. - `global_llm` (boolean, required) - `global_stt` (boolean, required) - `global_tts` (boolean, required) - `sentry_enabled` (boolean, required): Declares whether the client may send its errors, traces and session replays to an error tracker. - `managed_resources` (any, required): Declares what the caller's own tenant provisions, as it applies to this account. - `account` (boolean, required): Declares that the tenant provisions its own accounts. Refused when: - An account is created without an `external_id`. - The account edits its own contact fields through `/v1/a/profile`. The account and profile operations name the codes. - `user` (boolean, required): Declares that the tenant provisions its accounts' users. For a caller without the role `tenant_admin`: - Creating, changing or deleting a user is refused. - Resetting a user's password is refused. - Switching users on and off stays allowed. - The magic link stays open. The user operations name the code. - `number` (boolean, required): Declares that the tenant provisions its accounts' numbers: a caller without the role `tenant_admin` that creates, changes or deletes one is refused, but still switches them on and off; the number operations name the code. - `number_pool` (boolean, required): Declares that the tenant provisions its accounts' number pools, on the same terms as `number`. - `permissions` (array of enum(agent:read, agent:write, agent:manage, agent:automation:read, agent:automation:write, agent:automation:manage, agent:routing:read, agent:routing:write, agent:routing:manage, scenario:read, scenario:write, scenario:manage, communication:read, communication:write, communication:manage, number:read, number:write, number:manage, number:pool:read, number:pool:write, number:pool:manage, contact:read, contact:write, contact:manage, segment:read, segment:write, segment:manage, integration:sms:read, integration:sms:write, integration:sms:manage, account:read, account:manage, account:capacity:manage, tenant:user:read, tenant:user:manage, tenant:api_key:manage, tenant:sign_in:manage, tenant:role:read, tenant:role:manage, tenant:scenario_template:manage, scenario:template:read, analytics:read, account:user:manage, account:api_key:manage, account:sign_in:manage, account:profile:write, account:role:read, tts:synthesize:manage, tts:voice:read, llm:chat:manage, llm:document:manage, llm:model:read, ids:classifier:write, ids:classifier:manage, ids:entity:write, ids:model:read, stt:recognition:write, stt:dictionary:read, stt:dictionary:write, stt:dictionary:manage, edge:function:read, edge:function:write, edge:function:manage), required): Lists every permission the caller holds, sorted by name. A route that requires one admits the caller only when it is in this list. - `links` (array of object, required): Lists the links the caller's tenant places in the interface, in the order a client shows them; the same for every caller of the tenant. - `title` (string, required): Carries the text a client shows for the link; it carries no `<` or `>`. - `url` (string, required): Carries the `https` address the link opens. - `group` (string, required): Carries the label a client groups the link under; empty for none. It carries no `<` or `>`. ### List own API keys `GET /v1/a/profile/api-key` Operation id: `ListProfileAPIKeys` Lists the caller's own keys, newest first, without the secret. Rules: - The route is open to every role. - The request must carry a session. Parameters: - `order_by` (query, string): Sort field. Accepted: created_at, name, expires_at, last_used_at (default created_at). - `order` (query, string): Sort direction: asc | desc (default desc). - `limit` (query, integer): Page size, max 500 (default 100). - `offset` (query, integer) Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden Response body (`200`): Content type `application/json`: - `items` (array of object, required) - `sid` (string, required) - `name` (string, required) - `user_sid` (string, required): Names the owner. - `account_sid` (string | null, required): Names the owner's account; null for a tenant-level owner. - `level` (enum(account, tenant), required): Declares the owner's level: account or tenant. - `metadata` (object, required): Carries the object given at issue, as given. - `created_at` (string (date-time), required) - `expires_at` (string | null (date-time), required): Records when the key stops authenticating. - `last_used_at` (string | null (date-time), required): Records the last request the key authenticated; null while it has not been used. - `total` (integer (int64), required): Counts the keys matching the query, ignoring paging. - `limit` (integer, required): Reports the page size applied to this request. - `offset` (integer, required): Reports the offset applied to this request. - `has_more` (boolean, required): Says whether records beyond this page match the query. ### Issue own API key `POST /v1/a/profile/api-key` Operation id: `IssueProfileAPIKey` Creates a key owned by the caller and returns its secret once; only a hash is kept. Rules: - The route is open to every role. - The request must carry a session. Request body: Content type `application/json`: - `name` (string, required): Labels the key in listings. - `expires_at` (string (date-time)): Sets when the key stops authenticating. Omitted, the key expires one year after issue. - `metadata` (object): Carries the caller's own note on the key, held and returned as given. Nothing in it is read by the platform. Responses: - `201`: Created - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `409`: Conflict - `422`: Unprocessable Response body (`201`): Content type `application/json`: - `sid` (string, required) - `secret` (string, required) ### Revoke own API key `DELETE /v1/a/profile/api-key/{key_sid}` Operation id: `RevokeProfileAPIKey` Deletes one of the caller's keys. Rules: - The request must carry a session. - The key authenticates nothing from the next request on. - The caller's other keys are untouched. Parameters: - `key_sid` (path, string, required) Responses: - `204`: No content - `401`: Unauthorized - `403`: Forbidden - `404`: Not found ### List countries `GET /v1/a/info/countries` Operation id: `GetCountries` Returns the countries that `account.country` and a source's `country_code` accept, as static reference data: ISO 3166-1 alpha-2 codes, lowercase, ordered by code. Rules: - The route takes no credential. - The list has no paging. - The list has no filtering. Responses: - `200`: OK Response body (`200`): Content type `application/json`: - `items` (array of object, required) - `code` (string, required): Carries the country code: ISO 3166-1 alpha-2, lowercase. - `name` (string, required) ### List regions `GET /v1/a/info/regions` Operation id: `GetRegions` Returns every region a feature-flag rule may scope to, as a short code with its display name, ordered by code. Rules: - Every call returns the whole dataset. - The route takes no credential. - The list has no paging. - The list has no filters. Responses: - `200`: OK Response body (`200`): Content type `application/json`: - `items` (array of object, required) - `code` (string, required): Carries the region code, lowercase — the value stored in feature-flag rules. - `name` (string, required) ### Account API document `GET /v1/a/openapi.yaml` Operation id: `GetAccountOpenAPIDocument` The OpenAPI 3.0 document of the Account API, byte-identical to the committed bundle this deployment was built from. Served without a credential; generate clients from it. Responses: - `200`: The Account API document, as `application/yaml`. - `500`: Internal server error Response body (`200`): Content type `application/yaml`: ### Changelog `GET /v1/changelog.md` Operation id: `GetChangelog` The release notes of the Account API and the Tenant API up to the version this deployment was built from, newest version first, as one Markdown document. Each version lists its changes under Added, Changed, Deprecated, Removed and Fixed. Served without a credential. Responses: - `200`: The changelog, as `text/markdown`. - `500`: Internal server error Response body (`200`): Content type `text/markdown`: ### Get a function version by slug and version `GET /v1/a/adapters/edge/functions/{slug}/{version}` Operation id: `AdapterEdgeGetFunctionsSlugVersion` Parameters: - `slug` (path, string, required) - `version` (path, integer, required) - `X-Account-Sid` (header, string): Target account for principals broader than one account (tenant / account API key); account-scoped principals use their own. Responses: - `200`: The version - `400`: Domain error. A failed bundle comes as `400` with `err_code: INTERNAL_SERVER_ERROR`. On a run route a bundle that could not be rebuilt is this `400` too. - `401`: Unauthorized - `403`: Forbidden - `404`: No version with these keys in the account - `422`: The body, query or path params did not pass the zod schema - `500`: Unexpected error, for example a database or a disk failure. The body has `err_code: INTERNAL_SERVER_ERROR`. - `502`: Bad gateway (upstream adapter error) Response body (`200`): Content type `application/json`: - `ok` (enum(true), required) - `edgeFunction` (object, required) - `slug` (string, required) - `version` (integer, required) - `original_code` (string, required) ### Run a function version by slug and version `POST /v1/a/adapters/edge/functions/{slug}/{version}` Operation id: `AdapterEdgePostFunctionsSlugVersion` Same behaviour and response as `POST /api/functions/by-id/{id}`. Parameters: - `slug` (path, string, required) - `version` (path, integer, required) - `X-Account-Sid` (header, string): Target account for principals broader than one account (tenant / account API key); account-scoped principals use their own. Request body: Content type `application/json`: - `variables` (object): Scenario variables. Read in the code with `storage.get(key)` and passed to the handler as the second argument. - `args` (object): Passed to the handler as the first argument. Iris sends `{}`. Responses: - `200`: The run finished. `ok: true` when the handler returned, `ok: false` with `error` when it threw or the sandbox stopped it. - `400`: Domain error. A failed bundle comes as `400` with `err_code: INTERNAL_SERVER_ERROR`. On a run route a bundle that could not be rebuilt is this `400` too. - `401`: Unauthorized - `403`: Forbidden - `404`: No version with these keys in the account - `422`: The body, query or path params did not pass the zod schema - `500`: Unexpected error, for example a database or a disk failure. The body has `err_code: INTERNAL_SERVER_ERROR`. - `502`: Bad gateway (upstream adapter error) Response body (`200`): Content type `application/json`: - `ok` (boolean, required) - `return` (string, required): What the handler returned. A string as is, an object or array as JSON, `null` and `undefined` as an empty string, the rest via `String()`. - `variables` (object, required): Only the keys the run wrote with `storage.set`, every value as a string (objects as JSON, `null` and `undefined` as an empty string). Iris writes them back into the scenario variables. - `stdout` (string, required): `console.log` lines, cut at 1 KiB with `... [truncated]` - `stderr` (string, required): `console.error` lines plus the thrown message, cut at 1 KiB - `error` (string): Present only when `ok` is false - `execution_time` (integer, required): Milliseconds, including the bundle download ### Delete a function version `DELETE /v1/a/adapters/edge/functions/{slug}/{version}` Operation id: `AdapterEdgeDeleteFunctionsSlugVersion` Deletes the row, then removes the bundle from the bucket and the local version folder. A run after that gets `404` and cannot rebuild the bundle. If the removal fails, the call is `500` and goes to Sentry with both paths; the row is already gone. A missing local folder is fine, the cache cron may have removed it. Deleting the latest version does not make an older one latest. Parameters: - `slug` (path, string, required) - `version` (path, integer, required) - `X-Account-Sid` (header, string): Target account for principals broader than one account (tenant / account API key); account-scoped principals use their own. Responses: - `200`: Deleted - `400`: Domain error. A failed bundle comes as `400` with `err_code: INTERNAL_SERVER_ERROR`. On a run route a bundle that could not be rebuilt is this `400` too. - `401`: Unauthorized - `403`: Forbidden - `404`: No version with these keys in the account - `422`: The body, query or path params did not pass the zod schema - `500`: Unexpected error, for example a database or a disk failure. The body has `err_code: INTERNAL_SERVER_ERROR`. - `502`: Bad gateway (upstream adapter error) Response body (`200`): Content type `application/json`: - `ok` (enum(true), required) - `deleted` (enum(true), required) ### List the latest version of every function `GET /v1/a/adapters/edge/functions` Operation id: `AdapterEdgeGetFunctions` Only versions with `is_latest = true`, newest first by `created_at`. Parameters: - `offset` (query, integer) - `limit` (query, integer) - `X-Account-Sid` (header, string): Target account for principals broader than one account (tenant / account API key); account-scoped principals use their own. Responses: - `200`: One page of functions - `400`: Domain error. A failed bundle comes as `400` with `err_code: INTERNAL_SERVER_ERROR`. On a run route a bundle that could not be rebuilt is this `400` too. - `401`: Unauthorized - `403`: Forbidden - `422`: The body, query or path params did not pass the zod schema - `500`: Unexpected error, for example a database or a disk failure. The body has `err_code: INTERNAL_SERVER_ERROR`. - `502`: Bad gateway (upstream adapter error) Response body (`200`): Content type `application/json`: - `ok` (enum(true), required) - `total` (integer, required) - `hasMore` (boolean, required) - `results` (array of object, required) - `slug` (string, required) - `version` (integer, required) - `original_code` (string, required) ### Create a function version `POST /v1/a/adapters/edge/functions` Operation id: `AdapterEdgePostFunctions` Validates the code, bundles it and stores a new version of `slug`. If the latest version of `slug` has exactly the same `code`, nothing is bundled: the existing version is returned. Otherwise the version is the latest one plus 1 (the first one is 1) and it becomes the latest. Validation runs inside the request and can take seconds: forbidden lexemes, `deno check` against the runtime globals, ESLint. Bundling (`deno install` + `deno bundle`) runs inside the request too. Parameters: - `X-Account-Sid` (header, string): Target account for principals broader than one account (tenant / account API key); account-scoped principals use their own. Request body: Content type `application/json`: - `slug` (string, required): Function name inside the account. Needs at least one `[A-Za-z0-9_]` character and must not be `by-id`. Other characters are not rejected. - `code` (string, required): TypeScript or JavaScript module with a default export (or a `handler` export). Rejected with `422` when it has a forbidden lexeme, fails `deno check` against the runtime globals, or fails ESLint. See FLOW.md for the lists. Responses: - `200`: Version created, or the latest one reused - `400`: Domain error. A failed bundle comes as `400` with `err_code: INTERNAL_SERVER_ERROR`. On a run route a bundle that could not be rebuilt is this `400` too. - `401`: Unauthorized - `403`: Forbidden - `422`: The body, query or path params did not pass the zod schema - `500`: Unexpected error, for example a database or a disk failure. The body has `err_code: INTERNAL_SERVER_ERROR`. - `502`: Bad gateway (upstream adapter error) Response body (`200`): Content type `application/json`: - `ok` (enum(true), required) - `id` (string (uuid), required) - `version` (integer, required) - `storage_reads` (array of string, required): Keys found in the code as string literals of `storage.get` / `storage.unpack` (reads) or `storage.set` (writes). Keys built at runtime are not found. - `storage_writes` (array of string, required): Keys found in the code as string literals of `storage.get` / `storage.unpack` (reads) or `storage.set` (writes). Keys built at runtime are not found. ### Get a function version by id `GET /v1/a/adapters/edge/functions/by-id/{id}` Operation id: `AdapterEdgeGetFunctionsByIdId` Parameters: - `id` (path, string (uuid), required): Version id, a UUID - `X-Account-Sid` (header, string): Target account for principals broader than one account (tenant / account API key); account-scoped principals use their own. Responses: - `200`: The version - `400`: Domain error. A failed bundle comes as `400` with `err_code: INTERNAL_SERVER_ERROR`. On a run route a bundle that could not be rebuilt is this `400` too. - `401`: Unauthorized - `403`: Forbidden - `404`: No version with these keys in the account - `422`: The body, query or path params did not pass the zod schema - `500`: Unexpected error, for example a database or a disk failure. The body has `err_code: INTERNAL_SERVER_ERROR`. - `502`: Bad gateway (upstream adapter error) Response body (`200`): Content type `application/json`: - `ok` (enum(true), required) - `edgeFunction` (object, required) - `slug` (string, required) - `version` (integer, required) - `original_code` (string, required) ### Run a function version by id `POST /v1/a/adapters/edge/functions/by-id/{id}` Operation id: `AdapterEdgePostFunctionsByIdId` The route the Iris backend uses to run a brick. A failed run (the code throws, timeout, memory limit) is still `200` with `ok: false` and `error`. Only a missing version and a broken request get another status. Parameters: - `id` (path, string (uuid), required): Version id, a UUID - `X-Account-Sid` (header, string): Target account for principals broader than one account (tenant / account API key); account-scoped principals use their own. Request body: Content type `application/json`: - `variables` (object): Scenario variables. Read in the code with `storage.get(key)` and passed to the handler as the second argument. - `args` (object): Passed to the handler as the first argument. Iris sends `{}`. Responses: - `200`: The run finished. `ok: true` when the handler returned, `ok: false` with `error` when it threw or the sandbox stopped it. - `400`: Domain error. A failed bundle comes as `400` with `err_code: INTERNAL_SERVER_ERROR`. On a run route a bundle that could not be rebuilt is this `400` too. - `401`: Unauthorized - `403`: Forbidden - `404`: No version with these keys in the account - `422`: The body, query or path params did not pass the zod schema - `500`: Unexpected error, for example a database or a disk failure. The body has `err_code: INTERNAL_SERVER_ERROR`. - `502`: Bad gateway (upstream adapter error) Response body (`200`): Content type `application/json`: - `ok` (boolean, required) - `return` (string, required): What the handler returned. A string as is, an object or array as JSON, `null` and `undefined` as an empty string, the rest via `String()`. - `variables` (object, required): Only the keys the run wrote with `storage.set`, every value as a string (objects as JSON, `null` and `undefined` as an empty string). Iris writes them back into the scenario variables. - `stdout` (string, required): `console.log` lines, cut at 1 KiB with `... [truncated]` - `stderr` (string, required): `console.error` lines plus the thrown message, cut at 1 KiB - `error` (string): Present only when `ok` is false - `execution_time` (integer, required): Milliseconds, including the bundle download ### List every version of a function `GET /v1/a/adapters/edge/functions/{slug}/versions` Operation id: `AdapterEdgeGetFunctionsSlugVersions` Newest version first. An unknown slug gives an empty list, not 404. Parameters: - `slug` (path, string, required) - `X-Account-Sid` (header, string): Target account for principals broader than one account (tenant / account API key); account-scoped principals use their own. Responses: - `200`: All versions of the slug - `400`: Domain error. A failed bundle comes as `400` with `err_code: INTERNAL_SERVER_ERROR`. On a run route a bundle that could not be rebuilt is this `400` too. - `401`: Unauthorized - `403`: Forbidden - `422`: The body, query or path params did not pass the zod schema - `500`: Unexpected error, for example a database or a disk failure. The body has `err_code: INTERNAL_SERVER_ERROR`. - `502`: Bad gateway (upstream adapter error) Response body (`200`): Content type `application/json`: - `ok` (enum(true), required) - `versions` (array of object, required) - `id` (string (uuid), required) - `version` (integer, required) - `status` (enum(deployed, error, pending, expired, cleaning, archived), required): See the status lifecycle in FLOW.md - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) - `original_code` (string, required) - `is_latest` (boolean, required) - `storage_reads` (array of string, required): Keys found in the code as string literals of `storage.get` / `storage.unpack` (reads) or `storage.set` (writes). Keys built at runtime are not found. - `storage_writes` (array of string, required): Keys found in the code as string literals of `storage.get` / `storage.unpack` (reads) or `storage.set` (writes). Keys built at runtime are not found. ### Put the bundle of a version into the local cache `POST /v1/a/adapters/edge/functions/{slug}/{version}/warmup` Operation id: `AdapterEdgePostFunctionsSlugVersionWarmup` Makes the next run skip the bundle download. Does nothing when the bundle is already on the local disk. Otherwise downloads it from the bucket or rebuilds it from `original_code`. Parameters: - `slug` (path, string, required) - `version` (path, integer, required) - `X-Account-Sid` (header, string): Target account for principals broader than one account (tenant / account API key); account-scoped principals use their own. Responses: - `200`: The bundle is on the local disk - `400`: Domain error. A failed bundle comes as `400` with `err_code: INTERNAL_SERVER_ERROR`. On a run route a bundle that could not be rebuilt is this `400` too. - `401`: Unauthorized - `403`: Forbidden - `404`: No version with these keys in the account - `422`: The body, query or path params did not pass the zod schema - `500`: Unexpected error, for example a database or a disk failure. The body has `err_code: INTERNAL_SERVER_ERROR`. - `502`: Bad gateway (upstream adapter error) Response body (`200`): Content type `application/json`: - `ok` (enum(true), required) - `warmed_up` (enum(true), required) - `version` (integer, required) ### Save classifier content `PUT /v1/a/adapters/ids/classifier/{id}` Operation id: `AdapterIdsPutClassifierId` Records the supplied training-relevant content as the next version of the classifier and queues training for it (`201`). Content identical to a version the classifier already holds resolves to that version instead and trains nothing (`200`), which is what keeps a publish from triggering a mass retrain. Recorded versions are immutable, so this never alters an existing one. Queueing is never refused, however much an account already has waiting: training capacity is shared out when a run starts, not here. Parameters: - `id` (path, string (uuid), required): Classifier id (UUID). - `X-Account-Sid` (header, string): Target account for principals broader than one account (tenant / account API key); account-scoped principals use their own. Request body: Content type `application/json`: - `model_id` (string (uuid), required) - `description` (string) - `intent` (object, required) - `intents` (array of object, required) - `id` (string, required) - `description` (string) - `phrase` (object, required) - `phrases` (array of string, required) Responses: - `200`: Content resolved to a version the classifier already holds - `201`: Version recorded and queued for training - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `409`: Concurrent writers kept taking the version this save was going to record. The save is safe to repeat. - `500`: Internal server error - `502`: Bad gateway (upstream adapter error) Response body (`200`): Content type `application/json`: - `id` (string, required) - `version` (integer, required): Version number. `0` is an ordinary version like any other — the first one a classifier gets, and the one existing scenario bricks name. - `account_sid` (string, required) - `model_id` (string, required) - `description` (string, required) - `intent` (object, required) - `intents` (array of object, required) - `id` (string, required) - `description` (string) - `phrase` (object, required) - `phrases` (array of string, required) - `content_hash` (string, required): Identity of this version's training-relevant content. Two versions of one classifier can never carry the same value; it is what lets identical content resolve to an existing version instead of training again. - `state` (enum(new, training, fail, success, unknown), required) - `training` (object): Why the last training run of this version ended as it did. Present on a single-version read; absent from list entries. - `error` (string): Why the last training run failed. Absent unless it failed. - `created_at` (string (date-time)): When the training run was queued. Absent if none was ever queued. - `updated_at` (string (date-time)): When the training run last changed state. Absent if none was ever queued. ### Delete a classifier `DELETE /v1/a/adapters/ids/classifier/{id}` Operation id: `AdapterIdsDeleteClassifierId` Soft-deletes the classifier and every version of it: the records stay in the database but disappear from reads, are never trained again, and never satisfy content dedupe. Version history is kept so past calls remain explainable. Physical removal happens only when the owning account is purged. Parameters: - `id` (path, string (uuid), required): Classifier id (UUID). - `X-Account-Sid` (header, string): Target account for principals broader than one account (tenant / account API key); account-scoped principals use their own. Responses: - `204`: Deleted - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `500`: Internal server error - `502`: Bad gateway (upstream adapter error) ### List an account's classifier versions `GET /v1/a/adapters/ids/classifier` Operation id: `AdapterIdsGetClassifier` Every live version the account owns, each as its own entry: a version is the addressable thing, so several entries can share a classifier id and differ only by version. Parameters: - `X-Account-Sid` (header, string): Target account for principals broader than one account (tenant / account API key); account-scoped principals use their own. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `500`: Internal server error - `502`: Bad gateway (upstream adapter error) Response body (`200`): Content type `application/json`: - `id` (string, required) - `version` (integer, required): Version number. `0` is an ordinary version like any other — the first one a classifier gets, and the one existing scenario bricks name. - `account_sid` (string, required) - `model_id` (string, required) - `description` (string, required) - `intent` (object, required) - `intents` (array of object, required) - `id` (string, required) - `description` (string) - `phrase` (object, required) - `phrases` (array of string, required) - `content_hash` (string, required): Identity of this version's training-relevant content. Two versions of one classifier can never carry the same value; it is what lets identical content resolve to an existing version instead of training again. - `state` (enum(new, training, fail, success, unknown), required) - `training` (object): Why the last training run of this version ended as it did. Present on a single-version read; absent from list entries. - `error` (string): Why the last training run failed. Absent unless it failed. - `created_at` (string (date-time)): When the training run was queued. Absent if none was ever queued. - `updated_at` (string (date-time)): When the training run last changed state. Absent if none was ever queued. ### Create a classifier `POST /v1/a/adapters/ids/classifier` Operation id: `AdapterIdsPostClassifier` Records a new classifier at its first version (`0`) owned by the account, and queues its training. Later content changes are saved with `PUT /v1/classifier/{id}/account/{account_sid}`, which records the next version rather than altering this one. Parameters: - `X-Account-Sid` (header, string): Target account for principals broader than one account (tenant / account API key); account-scoped principals use their own. Request body: Content type `application/json`: - `model_id` (string (uuid), required) - `description` (string) - `intent` (object, required) - `intents` (array of object, required) - `id` (string, required) - `description` (string) - `phrase` (object, required) - `phrases` (array of string, required) Responses: - `201`: Created - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `500`: Internal server error - `502`: Bad gateway (upstream adapter error) Response body (`201`): Content type `application/json`: - `id` (string, required) - `version` (integer, required): Version number. `0` is an ordinary version like any other — the first one a classifier gets, and the one existing scenario bricks name. - `account_sid` (string, required) - `model_id` (string, required) - `description` (string, required) - `intent` (object, required) - `intents` (array of object, required) - `id` (string, required) - `description` (string) - `phrase` (object, required) - `phrases` (array of string, required) - `content_hash` (string, required): Identity of this version's training-relevant content. Two versions of one classifier can never carry the same value; it is what lets identical content resolve to an existing version instead of training again. - `state` (enum(new, training, fail, success, unknown), required) - `training` (object): Why the last training run of this version ended as it did. Present on a single-version read; absent from list entries. - `error` (string): Why the last training run failed. Absent unless it failed. - `created_at` (string (date-time)): When the training run was queued. Absent if none was ever queued. - `updated_at` (string (date-time)): When the training run last changed state. Absent if none was ever queued. ### Get one version `GET /v1/a/adapters/ids/classifier/{id}/version/{version}` Operation id: `AdapterIdsGetClassifierIdVersionVersion` Returns the recorded content of one version together with its training state — including why the last training run failed, and when it was queued and last changed. A version's content never changes once recorded, so a consumer that pinned this version always resolves exactly what it pinned. Parameters: - `id` (path, string (uuid), required): Classifier id (UUID). - `version` (path, integer, required): Classifier version. Version 0 is the one every classifier created before versioning occupies. - `X-Account-Sid` (header, string): Target account for principals broader than one account (tenant / account API key); account-scoped principals use their own. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `500`: Internal server error - `502`: Bad gateway (upstream adapter error) Response body (`200`): Content type `application/json`: - `id` (string, required) - `version` (integer, required): Version number. `0` is an ordinary version like any other — the first one a classifier gets, and the one existing scenario bricks name. - `account_sid` (string, required) - `model_id` (string, required) - `description` (string, required) - `intent` (object, required) - `intents` (array of object, required) - `id` (string, required) - `description` (string) - `phrase` (object, required) - `phrases` (array of string, required) - `content_hash` (string, required): Identity of this version's training-relevant content. Two versions of one classifier can never carry the same value; it is what lets identical content resolve to an existing version instead of training again. - `state` (enum(new, training, fail, success, unknown), required) - `training` (object): Why the last training run of this version ended as it did. Present on a single-version read; absent from list entries. - `error` (string): Why the last training run failed. Absent unless it failed. - `created_at` (string (date-time)): When the training run was queued. Absent if none was ever queued. - `updated_at` (string (date-time)): When the training run last changed state. Absent if none was ever queued. ### List entity types per language `GET /v1/a/adapters/ids/entities/types` Operation id: `AdapterIdsGetEntitiesTypes` Responses: - `200`: OK - `401`: Unauthorized - `403`: Forbidden - `500`: Internal server error - `502`: Bad gateway (upstream adapter error) Response body (`200`): Content type `application/json`: - `language` (string, required) - `types` (array of string, required) ### List models `GET /v1/a/adapters/ids/models` Operation id: `AdapterIdsGetModels` Parameters: - `language` (query, string): Filter models by language code (e.g. en, de, pl). Responses: - `200`: OK - `401`: Unauthorized - `403`: Forbidden - `500`: Internal server error - `502`: Bad gateway (upstream adapter error) Response body (`200`): Content type `application/json`: - `id` (string, required) - `title` (string, required) - `description` (string, required) - `language` (string, required) - `is_default_for_language` (boolean) ### Classify a phrase against one version `POST /v1/a/adapters/ids/classifier/{id}/version/{version}/classify` Operation id: `AdapterIdsPostClassifierIdVersionVersionClassify` Classifies a phrase using the trained artefact of the addressed version, so a caller that pinned a version keeps getting that version's behavior while another version is being trained. Classification is bound to a short deadline; exceeding it yields 504, a client cancellation 499. Parameters: - `id` (path, string (uuid), required): Classifier id (UUID). - `version` (path, integer, required): Classifier version. Version 0 is the one every classifier created before versioning occupies. - `X-Account-Sid` (header, string): Target account for principals broader than one account (tenant / account API key); account-scoped principals use their own. Request body: Content type `application/json`: - `phrase` (string, required) Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `500`: Internal server error - `502`: Bad gateway (upstream adapter error) - `504`: Classification deadline exceeded Response body (`200`): Content type `application/json`: - `intents` (object, required) ### Extract entities from a phrase `POST /v1/a/adapters/ids/entities/extract` Operation id: `AdapterIdsPostEntitiesExtract` Request body: Content type `application/json`: - `types` (array of string, required) - `language` (string, required) - `time_zone` (string) - `timestamp` (integer (int64)) - `phrase` (string, required) Responses: - `200`: OK - `204`: No entities extracted - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `502`: Bad gateway (upstream adapter error) Response body (`200`): Content type `application/json`: - `type` (string, required) - `value` (object, required): Shape depends on the entity type (e.g. date, time, address, phone-number). ### Download a RAG document file `GET /v1/a/adapters/llm/rag/document/{id}` Operation id: `AdapterLlmGetRagDocumentId` Parameters: - `id` (path, string, required): RAG document id. - `X-Account-Sid` (header, string): Target account for principals broader than one account (tenant / account API key); account-scoped principals use their own. Responses: - `200`: Document file stream - `400`: Invalid request body or parameters - `401`: Unauthorized - `403`: Forbidden - `404`: Resource does not exist - `500`: Internal server error - `502`: Bad gateway (upstream adapter error) Response body (`200`): Content type `application/octet-stream`: ### Upload a RAG document for an account `PUT /v1/a/adapters/llm/rag/document/{id}` Operation id: `AdapterLlmPutRagDocumentId` Accepts either a JSON text body or a multipart file upload, selected by Content-Type. Parameters: - `id` (path, string, required): RAG document id. - `mode` (query, string): Document split mode. - `index_type` (query, enum(vector, fulltext)) - `chunk_size` (query, integer) - `X-Account-Sid` (header, string): Target account for principals broader than one account (tenant / account API key); account-scoped principals use their own. Request body: Content type `application/json`: - `content` (string, required) - `type` (enum(txt, csv), required) Content type `multipart/form-data`: - `document` (string (binary), required) Responses: - `202`: Accepted - `400`: Invalid request body or parameters - `401`: Unauthorized - `403`: Forbidden - `409`: Resource busy - `502`: Bad gateway (upstream adapter error) Response body (`202`): Content type `application/json`: - `message` (string) ### Delete a RAG document for an account `DELETE /v1/a/adapters/llm/rag/document/{id}` Operation id: `AdapterLlmDeleteRagDocumentId` Parameters: - `id` (path, string, required): RAG document id. - `X-Account-Sid` (header, string): Target account for principals broader than one account (tenant / account API key); account-scoped principals use their own. Responses: - `204`: Deleted - `400`: Invalid request body or parameters - `401`: Unauthorized - `403`: Forbidden - `502`: Bad gateway (upstream adapter error) Response body (`204`): Content type `application/json`: - `message` (string) ### Get chat stream info `GET /v1/a/adapters/llm/chat/stream/info/{id}` Operation id: `AdapterLlmGetChatStreamInfoId` Parameters: - `id` (path, string, required): Chat stream id. Responses: - `200`: OK - `400`: Invalid request body or parameters - `401`: Unauthorized - `403`: Forbidden - `404`: Resource does not exist - `500`: Internal server error - `502`: Bad gateway (upstream adapter error) Response body (`200`): Content type `application/json`: - `id` (string, required) - `status` (string, required) - `error` (string) - `finish_reason` (string) - `text` (string) - `created` (string, required) - `engine` (string, required) - `commit` (string) - `request` (any, required) - `model` (string, required) - `messages` (array of object, required) - `role` (string, required) - `content` (string, required) - `name` (string) - `function_call` (object): A model-emitted function call (deprecated single-function form). - `name` (string) - `arguments` (string): JSON-encoded argument string. - `tool_calls` (array of object) - `id` (string, required) - `type` (string, required) - `function` (object, required): The function name and JSON-encoded arguments carried by a tool call. - `tool_call_id` (string) - `max_tokens` (integer) - `temperature` (number (float)) - `top_p` (number (float)) - `reasoning_effort` (enum(none, minimal, low, medium, high)): Reasoning budget for reasoning-capable models (GPT-5 and newer). Omit to keep the model default (medium). Lower values cut latency; 'none' disables reasoning entirely. Forwarded to OpenAI and Azure OpenAI backends only; ignored by the other providers. - `n` (integer) - `stream` (boolean) - `stop` (array of string) - `presence_penalty` (number (float)) - `frequency_penalty` (number (float)) - `logit_bias` (object) - `logprobs` (boolean) - `top_logprobs` (integer) - `user` (string) - `seed` (integer) - `response_format` (object) - `tools` (array of object) - `type` (string, required) - `function` (object) - `name` (string, required) - `description` (string) - `parameters` (object, required): JSON-Schema parameter definition, kept deliberately loose. - `tool_choice` (any): Tool-selection control: "none"/"auto"/"required" or an object. - `functions` (array of object) - `name` (string, required) - `description` (string) - `parameters` (object, required): JSON-Schema parameter definition, kept deliberately loose. - `function_call` (any): Function-selection control (deprecated): "none"/"auto" or an object. - `parallel_tool_calls` (any): Whether tool calls may run in parallel. - `stream_options` (object) - `engine` (enum(open_ai, azure)) - `provider` (string) - `backend` (string) - `gdpr_required` (boolean) - `metadata` (object) - `call_sid` (string) - `agent_sid` (string): The agent the call runs under. - `automation_sid` (string): The automation that placed the call. Empty when no automation placed it. - `scenario_sid` (string) - `node_id` (string) - `account_sid` (string) - `target` (string): entity|intent|fallback|streaming - `source` (string): hermes|bff|ss|ids - `is_test` (boolean) - `fallback_model` (string) - `rag` (object) - `document` (object) - `ids` (array of string) - `number` (integer) - `threshold` (number (float)) - `is_limit_with_documents` (boolean) - `function_call` (any): Deprecated: use tool_calls instead. - `name` (string) - `arguments` (string): JSON-encoded argument string. - `tool_calls` (array of object) - `id` (string, required) - `type` (string, required) - `function` (object, required): The function name and JSON-encoded arguments carried by a tool call. - `name` (string) - `arguments` (string) - `usage` (array of object) - `name` (string, required) - `usage` (object) - `prompt_tokens` (integer, required) - `completion_tokens` (integer, required) - `total_tokens` (integer, required) - `tiktokens` (integer, required) - `timeline` (array of object) - `name` (string, required) - `seconds` (number (float), required) - `details` (array of object) - `name` (string, required) - `detail` (any, required): Arbitrary detail payload. - `rag` (object) - `document` (object) - `ids` (array of string) - `number` (integer) - `threshold` (number (float)) - `is_limit_with_documents` (boolean) ### Poll chat stream result `GET /v1/a/adapters/llm/chat/stream/{id}` Operation id: `AdapterLlmGetChatStreamId` Parameters: - `id` (path, string, required): Chat stream id. - `parts_behavior` (query, enum(on_finish_get_all, on_finish_get_sentence)) Responses: - `200`: Stream completed and fully read - `206`: Stream in progress or finished but not fully read - `400`: Invalid request body or parameters - `401`: Unauthorized - `403`: Forbidden - `404`: Resource does not exist - `500`: Internal server error - `502`: Bad gateway (upstream adapter error) Response body (`200`): Content type `application/json`: - `type` (string) - `status` (enum(in_progress, error, finished, completed), required) - `error` (string) - `content` (object) - `part` (string) - `total` (string) - `function_call` (any): Deprecated: use tool_calls instead. - `name` (string) - `arguments` (string): JSON-encoded argument string. - `tool_calls` (array of object) - `id` (string, required) - `type` (string, required) - `function` (object, required): The function name and JSON-encoded arguments carried by a tool call. - `name` (string) - `arguments` (string) ### List available models `GET /v1/a/adapters/llm/public/data/models` Operation id: `AdapterLlmGetPublicDataModels` Parameters: - `provider` (query, string) - `type` (query, string) - `mode` (query, enum(flat, group)) - `gdpr` (query, boolean) - `enabled` (query, boolean) - `limit` (query, integer) - `offset` (query, integer) Responses: - `200`: OK. By `mode`: - `flat`: the default. Each item is one model on one backend. - `group`: each item is one model of one provider, across its backends. - `401`: Unauthorized - `403`: Forbidden - `500`: Internal server error - `502`: Bad gateway (upstream adapter error) Response body (`200`): Content type `application/json`: ### List RAG documents for an account `GET /v1/a/adapters/llm/rag/document/list` Operation id: `AdapterLlmGetRagDocumentList` Returns one page of the account's documents, newest first. Parameters: - `limit` (query, integer): Page size. A value above 500 is reduced to 500. - `offset` (query, integer): Number of documents to skip. A negative value is read as 0. - `X-Account-Sid` (header, string): Target account for principals broader than one account (tenant / account API key); account-scoped principals use their own. Responses: - `200`: OK - `400`: Invalid request body or parameters - `401`: Unauthorized - `403`: Forbidden - `500`: Internal server error - `502`: Bad gateway (upstream adapter error) Response body (`200`): Content type `application/json`: - `documents` (array of object, required) - `id` (string (uuid), required) - `name` (string, required) - `size` (integer (int64), required): Size of the uploaded file in bytes. - `status` (enum(pending, processed, error), required) - `error` (string): The reason of the failure. Present only when status is error. - `content_type` (string, required) - `mode` (enum(chunk, lines), required) - `index_type` (enum(fulltext, vector), required) - `chunk_size` (integer, required) - `embedding_model` (string) - `embedding_provider` (string) - `uploaded_at` (string (date-time), required) - `total` (integer (int64), required): Number of the account's documents. - `limit` (integer, required): The page size applied. - `offset` (integer, required): The offset applied. - `has_more` (boolean, required): True when more documents follow this page. ### Semantic search over an account's RAG documents `GET /v1/a/adapters/llm/rag/document/search` Operation id: `AdapterLlmGetRagDocumentSearch` Parameters: - `query` (query, string, required) - `document_id` (query, array of string) - `top_k` (query, integer) - `threshold` (query, number (float)) - `X-Account-Sid` (header, string): Target account for principals broader than one account (tenant / account API key); account-scoped principals use their own. Responses: - `200`: OK - `400`: Invalid request body or parameters - `401`: Unauthorized - `403`: Forbidden - `500`: Internal server error - `502`: Bad gateway (upstream adapter error) Response body (`200`): Content type `application/json`: - `chunks` (array of object) ### Chat completion (RAG-capable) `POST /v1/a/adapters/llm/chat/completion` Operation id: `AdapterLlmPostChatCompletion` Request body: Content type `application/json`: - `model` (string, required) - `messages` (array of object, required) - `role` (string, required) - `content` (string, required) - `name` (string) - `function_call` (object): A model-emitted function call (deprecated single-function form). - `name` (string) - `arguments` (string): JSON-encoded argument string. - `tool_calls` (array of object) - `id` (string, required) - `type` (string, required) - `function` (object, required): The function name and JSON-encoded arguments carried by a tool call. - `name` (string) - `arguments` (string) - `tool_call_id` (string) - `max_tokens` (integer) - `temperature` (number (float)) - `top_p` (number (float)) - `reasoning_effort` (enum(none, minimal, low, medium, high)): Reasoning budget for reasoning-capable models (GPT-5 and newer). Omit to keep the model default (medium). Lower values cut latency; 'none' disables reasoning entirely. Forwarded to OpenAI and Azure OpenAI backends only; ignored by the other providers. - `n` (integer) - `stream` (boolean) - `stop` (array of string) - `presence_penalty` (number (float)) - `frequency_penalty` (number (float)) - `logit_bias` (object) - `logprobs` (boolean) - `top_logprobs` (integer) - `user` (string) - `seed` (integer) - `response_format` (object) - `tools` (array of object) - `type` (string, required) - `function` (object) - `name` (string, required) - `description` (string) - `parameters` (object, required): JSON-Schema parameter definition, kept deliberately loose. - `tool_choice` (any): Tool-selection control: "none"/"auto"/"required" or an object. - `functions` (array of object) - `name` (string, required) - `description` (string) - `parameters` (object, required): JSON-Schema parameter definition, kept deliberately loose. - `function_call` (any): Function-selection control (deprecated): "none"/"auto" or an object. - `parallel_tool_calls` (any): Whether tool calls may run in parallel. - `stream_options` (object) - `engine` (enum(open_ai, azure)) - `provider` (string) - `backend` (string) - `gdpr_required` (boolean) - `metadata` (object) - `call_sid` (string) - `agent_sid` (string): The agent the call runs under. - `automation_sid` (string): The automation that placed the call. Empty when no automation placed it. - `scenario_sid` (string) - `node_id` (string) - `account_sid` (string) - `target` (string): entity|intent|fallback|streaming - `source` (string): hermes|bff|ss|ids - `is_test` (boolean) - `fallback_model` (string) - `rag` (object) - `document` (object) - `ids` (array of string) - `number` (integer) - `threshold` (number (float)) - `is_limit_with_documents` (boolean) Responses: - `200`: OK - `400`: Invalid request body or parameters - `401`: Unauthorized - `403`: Forbidden - `408`: Upstream provider timed out - `500`: Internal server error - `502`: Bad gateway (upstream adapter error) Response body (`200`): Content type `application/json`: - `id` (string, required) - `object` (string, required) - `created` (integer (int64), required) - `model` (string, required) - `choices` (array of object, required) - `index` (integer, required) - `message` (object, required): A chat message. Content is a string; multimodal content is not supported. - `role` (string, required) - `content` (string, required) - `name` (string) - `function_call` (object): A model-emitted function call (deprecated single-function form). - `name` (string) - `arguments` (string): JSON-encoded argument string. - `tool_calls` (array of object) - `id` (string, required) - `type` (string, required) - `function` (object, required): The function name and JSON-encoded arguments carried by a tool call. - `tool_call_id` (string) - `finish_reason` (string, required) - `logprobs` (any): Per-token log-probability detail. - `usage` (object, required) - `prompt_tokens` (integer, required) - `completion_tokens` (integer, required) - `total_tokens` (integer, required) - `system_fingerprint` (string, required) ### Start a RAG-augmented chat stream `POST /v1/a/adapters/llm/chat/stream` Operation id: `AdapterLlmPostChatStream` Request body: Content type `application/json`: - `model` (string, required) - `messages` (array of object, required) - `role` (string, required) - `content` (string, required) - `name` (string) - `function_call` (object): A model-emitted function call (deprecated single-function form). - `name` (string) - `arguments` (string): JSON-encoded argument string. - `tool_calls` (array of object) - `id` (string, required) - `type` (string, required) - `function` (object, required): The function name and JSON-encoded arguments carried by a tool call. - `name` (string) - `arguments` (string) - `tool_call_id` (string) - `max_tokens` (integer) - `temperature` (number (float)) - `top_p` (number (float)) - `reasoning_effort` (enum(none, minimal, low, medium, high)): Reasoning budget for reasoning-capable models (GPT-5 and newer). Omit to keep the model default (medium). Lower values cut latency; 'none' disables reasoning entirely. Forwarded to OpenAI and Azure OpenAI backends only; ignored by the other providers. - `n` (integer) - `stream` (boolean) - `stop` (array of string) - `presence_penalty` (number (float)) - `frequency_penalty` (number (float)) - `logit_bias` (object) - `logprobs` (boolean) - `top_logprobs` (integer) - `user` (string) - `seed` (integer) - `response_format` (object) - `tools` (array of object) - `type` (string, required) - `function` (object) - `name` (string, required) - `description` (string) - `parameters` (object, required): JSON-Schema parameter definition, kept deliberately loose. - `tool_choice` (any): Tool-selection control: "none"/"auto"/"required" or an object. - `functions` (array of object) - `name` (string, required) - `description` (string) - `parameters` (object, required): JSON-Schema parameter definition, kept deliberately loose. - `function_call` (any): Function-selection control (deprecated): "none"/"auto" or an object. - `parallel_tool_calls` (any): Whether tool calls may run in parallel. - `stream_options` (object) - `engine` (enum(open_ai, azure)) - `provider` (string) - `backend` (string) - `gdpr_required` (boolean) - `rag` (object) - `document` (object) - `ids` (array of string) - `number` (integer) - `threshold` (number (float)) - `is_limit_with_documents` (boolean) - `metadata` (object) - `call_sid` (string) - `agent_sid` (string): The agent the call runs under. - `automation_sid` (string): The automation that placed the call. Empty when no automation placed it. - `scenario_sid` (string) - `node_id` (string) - `account_sid` (string) - `target` (string): entity|intent|fallback|streaming - `source` (string): hermes|bff|ss|ids - `is_test` (boolean) - `fallback_model` (string) - `rephrase_question` (boolean) Responses: - `201`: Created - `400`: Invalid request body or parameters - `401`: Unauthorized - `403`: Forbidden - `500`: Internal server error - `502`: Bad gateway (upstream adapter error) Response body (`201`): Content type `application/json`: - `stream_id` (string, required) ### Commit or cancel a chat stream `POST /v1/a/adapters/llm/chat/stream/{id}/{action}` Operation id: `AdapterLlmPostChatStreamIdAction` Parameters: - `id` (path, string, required): Chat stream id. - `action` (path, enum(commit, cancel), required): Stream lifecycle action. Responses: - `202`: Action accepted - `400`: Invalid request body or parameters - `401`: Unauthorized - `403`: Forbidden - `404`: Resource does not exist - `500`: Internal server error - `502`: Bad gateway (upstream adapter error) ### Create text embeddings `POST /v1/a/adapters/llm/embeddings` Operation id: `AdapterLlmPostEmbeddings` Request body: Content type `application/json`: - `engine` (enum(open_ai, azure)) - `provider` (string) - `model` (string, required) - `input` (array of string, required) - `metadata` (object) - `call_sid` (string) - `agent_sid` (string): The agent the call runs under. - `automation_sid` (string): The automation that placed the call. Empty when no automation placed it. - `scenario_sid` (string) - `node_id` (string) - `account_sid` (string) - `target` (string): entity|intent|fallback|streaming - `source` (string): hermes|bff|ss|ids - `is_test` (boolean) Responses: - `201`: Created - `400`: Invalid request body or parameters - `401`: Unauthorized - `403`: Forbidden - `502`: Bad gateway (upstream adapter error) Response body (`201`): Content type `application/json`: - `embeddings` (array of array of number (float), required) ### Synthesize speech (query params) `GET /v1/a/adapters/tts/{engine}` Operation id: `AdapterTtsGetEngine` Synthesizes speech from the query parameters and streams the audio. Either `text` or `text_b64` is required. Parameters: - `engine` (path, enum(polly, azure, gc, ya_v3, techmo, elevenlabs, alfanum, voxtream, kugel), required): TTS engine selector. - `voice` (query, string): Voice id. Short alias `v`. - `language` (query, string): Language code. Short alias `l`. - `text` (query, string): Plain text to synthesize. Required unless `text_b64` is set. - `text_b64` (query, string): Base64-encoded text. Required unless `text` is set. - `speed` (query, string): Speech speed. Short alias `s`. - `format` (query, string): Audio format. Short alias `f`. Defaults to `mp3`. - `sampleRate` (query, integer): Sample rate in Hz. Short alias `sr`. - `model` (query, string): Provider model. Short alias `m`. - `fallback` (query, boolean): Allow voice fallback. Short alias `fb`. Defaults to `true`. - `v` (query, string): Short alias for `voice`. - `l` (query, string): Short alias for `language`. - `s` (query, string): Short alias for `speed`. - `f` (query, string): Short alias for `format`. - `sr` (query, integer): Short alias for `sampleRate`. - `m` (query, string): Short alias for `model`. - `fb` (query, boolean): Short alias for `fallback`. - `advanced_settings` (query, object): Provider-specific free-form synthesis settings, supplied as dot-delimited nested query keys of the form `advanced_settings.
.=` (alias prefix `as`), e.g. `as.s.param1=100`. The keys are flattened into a nested object per section; the accepted sections and keys are provider-specific. - `skip_uri_length_validation` (query, boolean): Skip the freeswitch URI length guard when `true`. Responses: - `200`: Synthesized audio stream. - `400`: Error response. - `401`: Unauthorized - `403`: Forbidden - `429`: Error response. - `502`: Error response. Response body (`200`): Content type `audio/mpeg`: Content type `audio/wav`: ### Synthesize speech (JSON body) `POST /v1/a/adapters/tts/{engine}` Operation id: `AdapterTtsPostEngine` Synthesizes speech from a JSON body and streams the audio. Parameters: - `engine` (path, enum(polly, azure, gc, ya_v3, techmo, elevenlabs, alfanum, voxtream, kugel), required): TTS engine selector. Request body: Content type `application/json`: - `model` (string) - `voice` (string) - `language` (string) - `speed` (string) - `format` (string) - `text` (string) - `sample_rate` (integer) - `advanced_settings` (object) - `fallback` (boolean | null): Defaults to true when omitted. Responses: - `200`: Synthesized audio stream. - `400`: Error response. - `401`: Unauthorized - `403`: Forbidden - `429`: Error response. - `502`: Error response. Response body (`200`): Content type `audio/mpeg`: Content type `audio/wav`: ### Drop the cached audio `DELETE /v1/a/adapters/tts/{engine}` Operation id: `AdapterTtsDeleteEngine` Removes the cached audio for the request described in the JSON body. Parameters: - `engine` (path, enum(polly, azure, gc, ya_v3, techmo, elevenlabs, alfanum, voxtream, kugel), required): TTS engine selector. Request body: Content type `application/json`: - `model` (string) - `voice` (string) - `language` (string) - `speed` (string) - `format` (string) - `text` (string) - `sample_rate` (integer) - `advanced_settings` (object) - `fallback` (boolean | null): Defaults to true when omitted. Responses: - `204`: Cache entry removed. - `400`: Error response. - `401`: Unauthorized - `403`: Forbidden - `500`: Error response. - `502`: Bad gateway (upstream adapter error) ### Prime the synthesis cache `HEAD /v1/a/adapters/tts/{engine}` Operation id: `AdapterTtsHeadEngine` Checks the cache for the requested audio. Returns `200` on a cache hit, otherwise queues synthesis and returns `202`. Accepts the same query parameters as `GET /{engine}`. Parameters: - `engine` (path, enum(polly, azure, gc, ya_v3, techmo, elevenlabs, alfanum, voxtream, kugel), required): TTS engine selector. - `voice` (query, string): Voice id. Short alias `v`. - `language` (query, string): Language code. Short alias `l`. - `text` (query, string): Plain text to synthesize. Required unless `text_b64` is set. - `text_b64` (query, string): Base64-encoded text. Required unless `text` is set. - `speed` (query, string): Speech speed. Short alias `s`. - `format` (query, string): Audio format. Short alias `f`. Defaults to `mp3`. - `sampleRate` (query, integer): Sample rate in Hz. Short alias `sr`. - `model` (query, string): Provider model. Short alias `m`. - `fallback` (query, boolean): Allow voice fallback. Short alias `fb`. Defaults to `true`. - `v` (query, string): Short alias for `voice`. - `l` (query, string): Short alias for `language`. - `s` (query, string): Short alias for `speed`. - `f` (query, string): Short alias for `format`. - `sr` (query, integer): Short alias for `sampleRate`. - `m` (query, string): Short alias for `model`. - `fb` (query, boolean): Short alias for `fallback`. - `advanced_settings` (query, object): Provider-specific free-form synthesis settings, supplied as dot-delimited nested query keys of the form `advanced_settings.
.=` (alias prefix `as`), e.g. `as.s.param1=100`. The keys are flattened into a nested object per section; the accepted sections and keys are provider-specific. Responses: - `200`: Audio already cached. - `202`: Synthesis queued. - `400`: Error response. - `401`: Unauthorized - `403`: Forbidden - `405`: Error response. - `502`: Bad gateway (upstream adapter error) ### List languages `GET /v1/a/adapters/tts/lang` Operation id: `AdapterTtsGetLang` Lists the languages supported by an engine (default `gc`). Parameters: - `engine` (query, string) Responses: - `200`: Languages. - `400`: Error response. - `401`: Unauthorized - `403`: Forbidden - `502`: Error response. Response body (`200`): Content type `application/json`: - `language_code` (string, required) - `engine` (string, required) ### Normalize synthesis parameters `GET /v1/a/adapters/tts/normalize/{path}` Operation id: `AdapterTtsGetNormalizePath` Rewrites synthesis parameters to platform-safe values: forces `f=wav`, sets `sr` (default 16000), strips `sampleRate`, `format` and `fsFix`. Every other parameter is returned unchanged. Requires `text` or `text_b64` in the query. The response holds the normalized query parameters. Send them as the query of a `GET` or `HEAD` synthesis request for the same engine. The audio is WAV for every engine and model. Parameters: - `path` (path, string, required): Engine name, for example `gc`. The response is the same for every value. - `text` (query, string): Plain text to synthesize. Required unless `text_b64` is set. - `text_b64` (query, string): Base64-encoded text. Required unless `text` is set. Responses: - `200`: The normalized query parameters. - `400`: Missing text. - `401`: Unauthorized - `403`: Forbidden - `502`: Bad gateway (upstream adapter error) Response body (`200`): Content type `application/json`: - `query` (object, required): The normalized query parameters, by name. ### List voices `GET /v1/a/adapters/tts/voice` Operation id: `AdapterTtsGetVoice` Lists voices for an engine, optionally filtered by language and gender. Parameters: - `engine` (query, string) - `lang` (query, string) - `gender` (query, string) Responses: - `200`: Voices. - `204`: No voices matched the filter. - `400`: Error response. - `401`: Unauthorized - `403`: Forbidden - `502`: Error response. Response body (`200`): Content type `application/json`: - `name` (string, required) - `human_name` (string, required) - `languages_codes` (array of string, required) - `gender` (string, required) - `engine` (string, required) - `status` (enum(active, deprecated, unavailable), required) - `models` (array of string) ### Resolve a voice `POST /v1/a/adapters/tts/voice/resolve` Operation id: `AdapterTtsPostVoiceResolve` Resolves the active voice for the request, falling back to a compatible voice when the requested one is unavailable. The `fallback` flag in the response indicates whether a fallback was used. Request body: Content type `application/json`: - `engine` (string, required) - `name` (string, required) - `language_code` (string, required) - `model` (string) - `gender` (string) - `format` (string) Responses: - `200`: Resolved voice. - `400`: Error response. - `401`: Unauthorized - `403`: Forbidden - `500`: Error response. - `502`: Bad gateway (upstream adapter error) - `503`: Error response. Response body (`200`): Content type `application/json`: - `engine` (string, required) - `name` (string, required) - `model` (string, required) - `language_code` (string, required) - `gender` (string, required) - `fallback` (boolean, required) ### Run an STT engine over audio sources `POST /v1/a/adapters/stt/{engine_name}/run` Operation id: `RunSTTEngine` Runs the named engine over the supplied audio sources on a live hermes node, picked least-loaded from the shared snapshot. Request and response are hermes' `/v1/stt/{engine_name}/run` contract unchanged, referenced here from the vendored hermes spec. What athena adds is the bearer credential, the permission check, the account scope the flags are evaluated in, and a not-found answer for an engine those flags withhold. Parameters: - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. - `engine_name` (path, string, required) Request body: Content type `application/json`: - `requests` (array of object, required) - `type` (string): Item kind; only `source` is supported. - `params` (object) - `is_realtime_processing` (boolean): Stream the source in real time and collect interim results. - `language` (string) - `model` (string) - `source` (object) - `url` (string): Signed URL or gs:// path of the audio to recognize. - `is_test` (boolean): Benchmark flag; passed through to the engine run. Responses: - `200`: The node's response, passed through. - `400`: The node's rejection of the run, passed through. A request body athena cannot parse, or an account scope it cannot resolve, is refused before the node is reached and carries athena's own error envelope instead. - `401`: Missing or invalid credentials - `403`: Caller has no access - `404`: No such engine, or the caller's feature flags withhold it — a gated engine is indistinguishable from an absent one. - `500`: The node's failure before it produced per-item results, passed through. Athena answers with its own error envelope when the caller's feature flags cannot be resolved. - `502`: The selected hermes node failed to serve the recognition. - `503`: No ready hermes node is available. Response body (`200`): Content type `application/json`: - `responses` (array of object, required) - `type` (string, required) - `source` (STTEngineRunResponseItemSource | null, required) ### Start an asynchronous transcription of a WAV file `POST /v1/a/adapters/stt/transcribe` Operation id: `StartSTTTranscription` Starts a job that transcribes every channel of a PCM WAV file and merges the channels into one dialog in time order. The audio: - `file`: a multipart upload of the WAV file. - `url` with `gs://`: a call recording of the caller's account, or a shared test file in the `test-cases/` folder of the environment bucket. - `url` with `http://` or `https://`: a file on a public host. `engine` is one of the engines that `GET /v1/a/adapters/stt/info/transcribe` lists, and `model` is one of the models it lists for that engine. Refused when: - `engine` is absent, or the engine or the model is unknown. - The engine is not enabled for the caller's account. - A `gs://` url names an object outside the call recordings of the caller's account and outside the shared test files. The job belongs to the caller's account and is kept for 1 hour. Parameters: - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Request body: Content type `application/json`: - `url` (string, required): A gs:// link to a call recording of the account, or an http or https link to a PCM WAV file on a public host. - `model` (string): A model of the engine; the engine's default model when absent. - `language` (string): Comma-separated language codes, or `auto`. `gsr@v2` takes one code or `auto` and uses `auto` when `language` is absent; the other engines use `de-DE,en-US` when it is absent. - `start_ms` (integer (int64)): Start of the cut. Times in the result count from it. - `end_ms` (integer (int64)): End of the cut. - `speaker_labels` (array of string): One label per channel, 1 to 32 letters, digits, '_' or '-'. - `engine` (string, required): The engine that transcribes the file, e.g. "gsr@v2". Content type `multipart/form-data`: - `file` (string (binary)): The PCM WAV file. - `url` (string): Used when no file is sent; never with a file. - `model` (string): A model of the engine; the engine's default model when absent. - `language` (string): Comma-separated language codes, or `auto`. `gsr@v2` takes one code or `auto` and uses `auto` when `language` is absent; the other engines use `de-DE,en-US` when it is absent. - `start_ms` (string): Integer, milliseconds. - `end_ms` (string): Integer, milliseconds. - `speaker_labels` (string): Comma-separated, one label per channel. - `engine` (string, required): The engine that transcribes the file, e.g. "gsr@v2". Responses: - `202`: The queued job. - `400`: `engine` is absent, the engine or the model is unknown, the engine is not enabled for the caller's account, or the audio or a field of the request is invalid. - `401`: Missing or invalid credentials - `403`: Caller has no access - `404`: A gs:// url names no recording of the caller's account and no shared test file, or an http or https host answers 404. - `413`: The body is larger than 65 MiB. - `500`: The transcription service failed to start the job. - `502`: The transcription service failed to serve the request. - `503`: The transcription service cannot take a job now. Response body (`202`): Content type `application/json`: - `id` (string, required): The job id. - `status` (enum(queued, running, completed, failed), required): The state of the job. `result` is set when it is `completed`. - `error` (string): Set when the job failed. - `created_at` (string (date-time), required): When the job was created. - `expires_at` (string (date-time), required): When the job is deleted, 1 hour after it was created. - `result` (object) - `engine` (string, required): The engine that transcribed the audio. - `model` (string, required): The model of the engine. - `endpoint` (string, required): The URL of the engine that received the audio. - `sample_rate` (integer, required): The sample rate of the file, in Hz. - `start_ms` (integer (int64), required): The start of the cut in the file, in milliseconds. - `duration_ms` (integer (int64), required): The length of the transcribed audio, in milliseconds. - `chunk_ms` (integer (int64), required): Chunk length sent to the engine; 0 when each channel went whole. - `channels` (array of object, required): One entry per channel of the file. - `channel` (integer, required) - `role` (string): The speaker label of the channel. Without `speaker_labels`, a stereo call recording has `client` on channel 0 and `bot` on channel 1, and a mono file has no role. - `language` (string, required) - `text` (string, required) - `utterances` (array of object, required) - `start_ms` (integer (int64), required) - `end_ms` (integer (int64), required) - `language` (string) - `text` (string, required) - `words` (array of object, required) - `dialog` (array of object, required): The turns of all channels, in time order. - `speaker` (string, required): The role of the channel, or `speaker` when the channel has no role. - `start_ms` (integer (int64), required) - `end_ms` (integer (int64), required) - `language` (string): The language of the turn. Absent when the engine gives none. - `text` (string, required) - `issues` (array of string, required): Warnings about the result, one text per warning: a channel with no recognized speech, a channel too short for reliable language detection, or a word time moved to the end of the audio. ### Get a transcription job `GET /v1/a/adapters/stt/transcribe/{id}` Operation id: `GetSTTTranscription` Returns a transcription job of the caller's account. A job that stops before it completes is `failed`, and `error` says why. Parameters: - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. - `id` (path, string, required) Responses: - `200`: The job. - `401`: Missing or invalid credentials - `403`: Caller has no access - `404`: The job is not found. - `500`: The transcription service failed to read the job. - `502`: The transcription service failed to serve the request. - `503`: The transcription service is not available. Response body (`200`): Content type `application/json`: - `id` (string, required): The job id. - `status` (enum(queued, running, completed, failed), required): The state of the job. `result` is set when it is `completed`. - `error` (string): Set when the job failed. - `created_at` (string (date-time), required): When the job was created. - `expires_at` (string (date-time), required): When the job is deleted, 1 hour after it was created. - `result` (object) - `engine` (string, required): The engine that transcribed the audio. - `model` (string, required): The model of the engine. - `endpoint` (string, required): The URL of the engine that received the audio. - `sample_rate` (integer, required): The sample rate of the file, in Hz. - `start_ms` (integer (int64), required): The start of the cut in the file, in milliseconds. - `duration_ms` (integer (int64), required): The length of the transcribed audio, in milliseconds. - `chunk_ms` (integer (int64), required): Chunk length sent to the engine; 0 when each channel went whole. - `channels` (array of object, required): One entry per channel of the file. - `channel` (integer, required) - `role` (string): The speaker label of the channel. Without `speaker_labels`, a stereo call recording has `client` on channel 0 and `bot` on channel 1, and a mono file has no role. - `language` (string, required) - `text` (string, required) - `utterances` (array of object, required) - `start_ms` (integer (int64), required) - `end_ms` (integer (int64), required) - `language` (string) - `text` (string, required) - `words` (array of object, required) - `dialog` (array of object, required): The turns of all channels, in time order. - `speaker` (string, required): The role of the channel, or `speaker` when the channel has no role. - `start_ms` (integer (int64), required) - `end_ms` (integer (int64), required) - `language` (string): The language of the turn. Absent when the engine gives none. - `text` (string, required) - `issues` (array of string, required): Warnings about the result, one text per warning: a channel with no recognized speech, a channel too short for reliable language detection, or a word time moved to the end of the audio. ### List transcription models `GET /v1/a/adapters/stt/info/transcribe` Operation id: `ListSTTTranscriptionModels` Lists the engine models that transcribe a recorded file. A model of an engine not enabled for the caller's account is absent. Parameters: - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: The transcription models. - `400`: Invalid request body or parameters - `401`: Missing or invalid credentials - `403`: Caller has no access - `500`: Internal server error Response body (`200`): Content type `application/json`: - `models` (array of object, required) - `engine` (string, required): Names the engine, e.g. "gsr@v2". - `model` (string, required): Identifies the model, e.g. "chirp_3". - `is_default_model` (boolean, required): Says whether a transcription with no `model` uses this model of the engine. ### List recognition languages `GET /v1/a/adapters/stt/info/language` Operation id: `ListSTTLanguages` The recognition languages offered to the caller, each with its display name. A language served only by an engine the caller's feature flags withhold is absent. A bare two-character code appears only when no regional variant of that language exists. Parameters: - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: The language list. - `400`: Invalid request body or parameters - `401`: Missing or invalid credentials - `403`: Caller has no access - `500`: Internal server error Response body (`200`): Content type `application/json`: - `languages` (array of object, required) - `code` (string, required): Carries the language code, e.g. "en-US". - `name` (string, required): Gives the human-readable language name, e.g. "English (United States)". ### List recognition model options `GET /v1/a/adapters/stt/info/model` Operation id: `ListSTTModels` The engine / language / model combinations offered to the caller, each marked when it is the default model for its engine and language. A combination whose engine the caller's feature flags withhold is absent. Filters combine with AND. A bare `language` selects that whole family (`ru` → every `ru-*` locale); a locale also selects an engine that lists the language without a region (`ru-RU` → an engine offering `ru`). An unmatched language yields an empty page. Parameters: - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. - `engine` (query, string) - `language` (query, string) - `model` (query, string) - `limit` (query, integer): Page size, max 500 (default 100). - `offset` (query, integer) Responses: - `200`: The matching recognition model options. - `400`: Invalid request body or parameters - `401`: Missing or invalid credentials - `403`: Caller has no access - `500`: Internal server error Response body (`200`): Content type `application/json`: - `items` (array of object, required) - `engine` (string, required): Names the engine, e.g. "gsr@v2". - `language` (string, required): Carries the language code, e.g. "en-US". - `language_name` (string, required): Gives the English language name. - `language_local_name` (string, required): Gives the language name in its own script. - `model` (string, required): Identifies the model. - `model_name` (string, required): Gives the human-readable model name; empty when the engine has none. - `is_default_model` (boolean, required): Says whether this model is the default for its engine and language. - `metadata` (any, required): Lists the capability flags of this engine / language / model combination. - `auto_punctuation` (boolean, required): Says whether the combination can punctuate the transcript automatically. - `diarization` (boolean, required): Says whether the combination can attribute speech to distinct speakers. - `model_adaptation` (boolean, required): Says whether the combination accepts adaptation hints such as class tokens. - `word_level_confidence` (boolean, required): Says whether the combination reports a confidence score per word. - `profanity_filter` (boolean, required): Says whether the combination can mask profanities in the transcript. - `spoken_punctuation` (boolean, required): Says whether the combination can transcribe spoken punctuation as marks. - `spoken_emojis` (boolean, required): Says whether the combination can transcribe spoken emoji names as emoji. - `launch_readiness` (string, required): Reports the maturity the engine publishes for this combination — `GA` or `Preview`; empty when the engine publishes none. - `total` (integer (int64), required): Counts the options matching the query, ignoring paging. - `limit` (integer, required): Reports the page size applied to this request. - `offset` (integer, required): Reports the offset applied to this request. - `has_more` (boolean, required): Says whether records beyond this page match the query. ### List tuning options per engine and language `GET /v1/a/adapters/stt/info/spec` Operation id: `ListSTTSpecs` Which tuning options apply to each engine / language pair the caller is offered: the grammar parameters that alter recognition, the class tokens the engine understands, and the filters applicable to the transcript. Each pair also states whether endpoint detection is available for its engine. A pair whose engine the caller's feature flags withhold is absent. Both filters accept a comma-separated set; omitting one means no filter on it. A bare language in `languages` selects that whole family (`en` → every `en-*` locale); a locale also selects an engine that lists the language without a region (`en-US` → an engine offering `en`). A value that matches no language adds no pair. Parameters: - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. - `engines` (query, string): Comma-separated engine names. - `languages` (query, string): Comma-separated language codes. - `limit` (query, integer): Page size, max 500 (default 100). - `offset` (query, integer) Responses: - `200`: The matching engine / language tuning options. - `400`: Invalid request body or parameters - `401`: Missing or invalid credentials - `403`: Caller has no access - `500`: Internal server error Response body (`200`): Content type `application/json`: - `items` (array of object, required) - `engine` (string, required) - `language` (string, required): Carries the language code as the engine lists it, e.g. "en" for `languages=en-US`. - `endpoint_detection` (boolean, required): Says whether endpoint detection is available for the engine. A scenario switches it on in a brick's speech recognition settings only where this is true. - `specs` (array of object, required) - `key` (enum(grammar_parameters, class_tokens, filters), required): Names the kind of tuning option this entry lists. - `value` (array of string | GrammarParameter, required): Carries the options. By `key`: - `grammar_parameters`: carries objects. - `class_tokens` and `filters`: carry plain strings. - `total` (integer (int64), required): Counts the engine / language pairs matching the filters. - `limit` (integer, required): Reports the page size applied to this request. - `offset` (integer, required): Reports the offset applied to this request. - `has_more` (boolean, required): Says whether records beyond this page match the query. ### List STT dictionaries `GET /v1/a/adapters/stt/data/dictionary` Operation id: `ListAccountSTTDictionaries` The global presets plus the caller's own account dictionaries, told apart by `public`. The account is resolved from the principal — a broader principal targets one of its accounts with `X-Account-Sid`. Parameters: - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. - `language` (query, string): Exact match on the language code; there is no partial match. - `name` (query, string): The dictionary name, matched in full; a prefix selects nothing. - `limit` (query, integer): Page size, max 500 (default 100). - `offset` (query, integer) Responses: - `200`: The matching dictionaries. - `400`: Invalid request body or parameters - `401`: Missing or invalid credentials - `403`: Caller has no access - `500`: Internal server error Response body (`200`): Content type `application/json`: - `items` (array of object, required) - `id` (string, required) - `account_sid` (string | null, required): Names the owning account; `null` for a global preset. - `name` (string, required) - `language` (string, required): Names the locale the vocabulary belongs to, e.g. "en-US". - `public` (boolean, required): Says whether this is a global preset (no owning account). - `description` (string, required) - `tokens` (array of string, required): Carries the vocabulary, the words and phrases fed to recognition. - `engines` (array of string, required): Lists the engines serving this dictionary's language, drawn from the recognition catalog. By plane: - Under `/v1/a/adapters/stt/data/*`, the list holds only the engines the caller's feature flags offer. - The operator plane returns all of them. - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) - `total` (integer (int64), required): Counts the dictionaries matching the query, ignoring paging. - `limit` (integer, required): Reports the page size applied to this request. - `offset` (integer, required): Reports the offset applied to this request. - `has_more` (boolean, required): Says whether records beyond this page match the query. ### Create an STT dictionary `POST /v1/a/adapters/stt/data/dictionary` Operation id: `CreateAccountSTTDictionary` Creates a dictionary owned by the caller's account. The global presets are operator-curated and cannot be created here. `name` and `language` are both required and refused when either is empty, and a name another live dictionary of the account holds for that language is refused. Parameters: - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Request body: Content type `application/json`: - `name` (string, required) - `language` (string, required) - `tokens` (array of string, required) - `description` (string) Responses: - `201`: The created dictionary. - `400`: Invalid request body or parameters - `401`: Missing or invalid credentials - `403`: Caller has no access - `409`: Request conflicts with current resource state - `422`: Semantic validation failure - `500`: Internal server error Response body (`201`): Content type `application/json`: - `id` (string, required) - `account_sid` (string | null, required): Names the owning account; `null` for a global preset. - `name` (string, required) - `language` (string, required): Names the locale the vocabulary belongs to, e.g. "en-US". - `public` (boolean, required): Says whether this is a global preset (no owning account). - `description` (string, required) - `tokens` (array of string, required): Carries the vocabulary, the words and phrases fed to recognition. - `engines` (array of string, required): Lists the engines serving this dictionary's language, drawn from the recognition catalog. By plane: - Under `/v1/a/adapters/stt/data/*`, the list holds only the engines the caller's feature flags offer. - The operator plane returns all of them. - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) ### Get an STT dictionary `GET /v1/a/adapters/stt/data/dictionary/{id}` Operation id: `GetAccountSTTDictionary` A global preset or one of the caller's own account dictionaries. Parameters: - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. - `id` (path, string, required) Responses: - `200`: The dictionary. - `401`: Missing or invalid credentials - `403`: Caller has no access - `404`: Resource does not exist - `500`: Internal server error Response body (`200`): Content type `application/json`: - `id` (string, required) - `account_sid` (string | null, required): Names the owning account; `null` for a global preset. - `name` (string, required) - `language` (string, required): Names the locale the vocabulary belongs to, e.g. "en-US". - `public` (boolean, required): Says whether this is a global preset (no owning account). - `description` (string, required) - `tokens` (array of string, required): Carries the vocabulary, the words and phrases fed to recognition. - `engines` (array of string, required): Lists the engines serving this dictionary's language, drawn from the recognition catalog. By plane: - Under `/v1/a/adapters/stt/data/*`, the list holds only the engines the caller's feature flags offer. - The operator plane returns all of them. - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) ### Delete an STT dictionary `DELETE /v1/a/adapters/stt/data/dictionary/{id}` Operation id: `DeleteAccountSTTDictionary` Soft-deletes one of the caller's own dictionaries. A global preset is operator-curated, so deleting one is refused. Parameters: - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. - `id` (path, string, required) Responses: - `204`: Deleted - `401`: Missing or invalid credentials - `403`: Caller has no access - `404`: Resource does not exist - `500`: Internal server error ### Update an STT dictionary `PATCH /v1/a/adapters/stt/data/dictionary/{id}` Operation id: `PatchAccountSTTDictionary` Updates one of the caller's own dictionaries. Partial update: an omitted field preserves the current value. A global preset is operator-curated, so writing to one is refused. A name another live dictionary of the account holds for that language is refused. Parameters: - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. - `id` (path, string, required) Request body: Content type `application/json`: - `name` (string) - `language` (string) - `tokens` (array of string) - `description` (string) Responses: - `200`: The updated dictionary. - `400`: Invalid request body or parameters - `401`: Missing or invalid credentials - `403`: Caller has no access - `404`: Resource does not exist - `409`: Request conflicts with current resource state - `422`: Semantic validation failure - `500`: Internal server error Response body (`200`): Content type `application/json`: - `id` (string, required) - `account_sid` (string | null, required): Names the owning account; `null` for a global preset. - `name` (string, required) - `language` (string, required): Names the locale the vocabulary belongs to, e.g. "en-US". - `public` (boolean, required): Says whether this is a global preset (no owning account). - `description` (string, required) - `tokens` (array of string, required): Carries the vocabulary, the words and phrases fed to recognition. - `engines` (array of string, required): Lists the engines serving this dictionary's language, drawn from the recognition catalog. By plane: - Under `/v1/a/adapters/stt/data/*`, the list holds only the engines the caller's feature flags offer. - The operator plane returns all of them. - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) ### List speech text rules `GET /v1/a/adapters/tts/validation-rules` Operation id: `ListTTSValidationRules` The text rules of every speech engine offered to the caller, and the default rule of an engine that has no rule of its own. An engine the caller's feature flags withhold is absent. A limit applies to the text trimmed of spaces. Parameters: - `X-Account-Sid` (header, string): Names the target account for account-scoped resources. By principal: - A tenant API key carries no account scope of its own and names the account here. - An account-scoped principal may omit it. Refused when: - A tenant API key omits it. - An account-scoped principal sends a value naming any other account. - The named account belongs to another tenant. - The named account does not exist; it is answered as not found. Responses: - `200`: The rules. - `400`: Invalid request body or parameters - `401`: Missing or invalid credentials - `403`: Caller has no access - `500`: Internal server error Response body (`200`): Content type `application/json`: - `default` (any, required): Carries the rule of an engine that has no item. - `max_bytes` (integer): Carries the most bytes of the text in UTF-8. Absent when the engine counts characters. - `max_chars` (integer): Carries the most characters of the text. Absent when the engine counts bytes. - `max_chars_non_latin` (integer): Carries the most characters of a text that holds a character other than an ASCII letter, an ASCII digit, a space or a common punctuation mark. Absent when the engine has one limit for every text. - `items` (array of any, required): Carries the rule of each offered engine. - `engine` (string, required): Carries the engine name, as a brick's `engine` property takes it. - `max_bytes` (integer): Carries the most bytes of the text in UTF-8. Absent when the engine counts characters. - `max_chars` (integer): Carries the most characters of the text. Absent when the engine counts bytes. - `max_chars_non_latin` (integer): Carries the most characters of a text that holds a character other than an ASCII letter, an ASCII digit, a space or a common punctuation mark. Absent when the engine has one limit for every text. ## Tenant API The tenant plane: what a tenant administers across its own accounts — account provisioning, the tenant's own people and their API keys, and the roles its users hold. Reached with a tenant-level user's session or API key; neither tenant nor account is a path segment — both resolve from the credential, with the scope-override headers for a principal broader than its target. A permission is named `:` or `::`, and the action is `read`, `write` or `manage`. On one resource `manage` includes `write`, and `write` includes `read`. Every tenant has five fixed roles: the `account` roles `reader`, `writer` and `account_admin`, and the `tenant` roles `tenant_admin` and `tenant_dpu`. `tenant_dpu` holds what `account_admin` holds, reads the accounts of the tenant and changes their `lines`, also on an account that carries an `external_id`. Any other write that `managed_resources` restricts is refused to it; only `tenant_admin` makes that write. A tenant's own role may inherit a fixed `account` role. Each operation names the permission it needs in `x-athena-permission`; `none` means the operation checks no permission. A list refuses a `limit` above its maximum, and an `order_by`, `filter_or` or `include` name that its parameter does not accept. ## 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 the W3C `traceparent` header or in `X-Trace-ID`. An `X-Trace-ID` value is 32 hexadecimal characters or a UUID; the response returns it in lowercase and without dashes. A valid `traceparent` takes precedence over `X-Trace-ID`. A request with no valid id in either header is served under a new id. ## Errors An error response carries an `error` field that names the case. A client branches on `error`; the text in `message` is for people. ### 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 | `email_required` | The tenant declares `account` in `managed_resources`, which makes `email` required, and the request carries none. | | 400 | `external_id_required` | The tenant declares this resource type in `managed_resources`, which makes `external_id` required, and the request carries none. | | 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 | `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 | `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 | `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`. | | 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 | `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. | | 409 | `account_calls_in_flight` | A call of the account, or of an account under the tenant, is being dialled or is in progress. | | 409 | `conflict` | The write collides with the current state of the resource; `message` says what collided. | | 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 | `role_fixed` | The role is defined by the platform and cannot be edited or deleted. | | 409 | `role_in_use` | Refuses the request while the role is in use.
Returned when:
- A live user of the tenant holds the role.
- A live role inherits it.
The data:
- `data.users`: names the users that hold the role.
- `data.roles`: names the roles that inherit it. | | 413 | `payload_too_large` | The body exceeds the size limit of the operation. | | 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 | `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. | | 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. | ### List accounts `GET /v1/t/account` Operation id: `ListAccounts` The accounts of one tenant. Soft-deleted rows stay out unless `show_deleted` asks for them, and each row carries its own `deleted_at`. Parameters: - `show_deleted` (query, boolean): Include soft-deleted rows in the listing. - `X-Tenant-Sid` (header, string): Names the target tenant. By principal: - A tenant-scoped principal may omit it. - A principal with no tenant of its own names one here. Refused when: - A tenant-scoped principal sends a value naming any other tenant. - A principal with no tenant of its own omits it. - `filter_or` (query, string): Names the fields, comma-separated, that filter_query OR-searches. Values: - `sid`: matched exactly. - `name`: matched as a substring, case-insensitive. - `email`: matched as a substring, case-insensitive. It is supplied together with filter_query. Refused when: - One of the two is sent without the other. - A field is unknown. - `filter_query` (query, string): Search term matched across the fields named in filter_or. - `order_by` (query, string): Sort field. Accepted: created_at, name, email (default created_at). - `order` (query, string): Sort direction: asc | desc (default desc). - `limit` (query, integer): Page size, max 500 (default 100). - `offset` (query, integer) Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden Response body (`200`): Content type `application/json`: - `items` (array of object, required) - `sid` (string, required) - `tenant_sid` (string, required) - `name` (string, required) - `email` (string, required) - `external_id` (string, required) - `country` (string, required) - `timezone` (string, required) - `phone` (string, required) - `lines` (integer, required): Simultaneous calls the account may hold across its agents. - `retention` (object, required): Carries the retention periods this level sets, in days. For a `null` period: - An account follows its tenant. - A tenant follows the global retention period of 365 days. - `communication` (integer | null, required): Sets how many days a communication and its data are kept after its creation. An SMS is kept the same number of days after its creation. - `contact` (integer | null, required): Sets how many days a contact and its data are kept after its last communication or its last update, whichever is later. A contact is kept while it has a communication. - `contact_limits` (object, required): Records the contact limits set on this account. A `null` limit is the platform's. The platform's limits: - `data_fields` is 30. - `value_bytes` is 100. - `array_items` is 100. - `contacts` is 100 000. - `data_fields` (integer | null, required): Bounds the fields of a contact's data, counted at any depth, an array as one field. - `value_bytes` (integer | null, required): Bounds the bytes of one value of a contact's data, and of each item of an array. - `array_items` (integer | null, required): Bounds the items of an array in a contact's data. - `contacts` (integer | null, required): Bounds the contacts the account holds. - `status` (enum(active, inactive), required) - `deleted_at` (string | null (date-time), required) - `total` (integer (int64), required): Counts the accounts matching the query, ignoring paging. - `limit` (integer, required): Reports the page size applied to this request. - `offset` (integer, required): Reports the offset applied to this request. - `has_more` (boolean, required): Says whether records beyond this page match the query. ### Create account `POST /v1/t/account` Operation id: `CreateAccount` Creates the account row and nothing else (no API key, no segments, no flags) and starts it active on the allocation `lines` gives it. Rules: - `name`: need not be unique. - `external_id`: required while the tenant declares `account` in `managed_resources`. Parameters: - `X-Tenant-Sid` (header, string): Names the target tenant. By principal: - A tenant-scoped principal may omit it. - A principal with no tenant of its own names one here. Refused when: - A tenant-scoped principal sends a value naming any other tenant. - A principal with no tenant of its own omits it. Request body: Content type `application/json`: - `name` (string, required) - `email` (string (email), required) - `external_id` (string) - `country` (string) - `timezone` (string) - `phone` (string): Digits only, no separators. - `lines` (integer, required): Simultaneous calls the account may hold across its agents. - `retention` (object): Sets both retention periods of this level, in days. - `communication` (integer, required): Sets how many days a communication and its data are kept after its creation. An SMS is kept the same number of days after its creation. - `contact` (integer, required): Sets how many days a contact and its data are kept after its last communication or its last update, whichever is later. A contact is kept while it has a communication. - `contact_limits` (object): Sets the account's contact limits. A limit left out is the platform's. - `data_fields` (integer): Bounds the fields of a contact's data, counted at any depth, an array as one field. - `value_bytes` (integer): Bounds the bytes of one value of a contact's data, and of each item of an array. - `array_items` (integer): Bounds the items of an array in a contact's data. - `contacts` (integer): Bounds the contacts the account holds. Responses: - `201`: Created - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `409`: Conflict - `422`: Unprocessable Response body (`201`): Content type `application/json`: - `sid` (string, required) - `tenant_sid` (string, required) - `name` (string, required) - `email` (string, required) - `external_id` (string, required) - `country` (string, required) - `timezone` (string, required) - `phone` (string, required) - `lines` (integer, required): Simultaneous calls the account may hold across its agents. - `retention` (object, required): Carries the retention periods this level sets, in days. For a `null` period: - An account follows its tenant. - A tenant follows the global retention period of 365 days. - `communication` (integer | null, required): Sets how many days a communication and its data are kept after its creation. An SMS is kept the same number of days after its creation. - `contact` (integer | null, required): Sets how many days a contact and its data are kept after its last communication or its last update, whichever is later. A contact is kept while it has a communication. - `contact_limits` (object, required): Records the contact limits set on this account. A `null` limit is the platform's. The platform's limits: - `data_fields` is 30. - `value_bytes` is 100. - `array_items` is 100. - `contacts` is 100 000. - `data_fields` (integer | null, required): Bounds the fields of a contact's data, counted at any depth, an array as one field. - `value_bytes` (integer | null, required): Bounds the bytes of one value of a contact's data, and of each item of an array. - `array_items` (integer | null, required): Bounds the items of an array in a contact's data. - `contacts` (integer | null, required): Bounds the contacts the account holds. - `status` (enum(active, inactive), required) - `deleted_at` (string | null (date-time), required) ### Get account by external identifier `GET /v1/t/account/-/external/{external_id}` Operation id: `GetAccountByExternalID` Resolves the account the client system gave this key, without the caller knowing the platform sid. The key is unique within a tenant, so the lookup runs inside the caller's tenant. By principal: - A tenant-scoped principal looks up in its own tenant. - A broader principal looks up in the tenant it names with `X-Tenant-Sid`. Parameters: - `external_id` (path, string, required) - `X-Tenant-Sid` (header, string): Names the target tenant. By principal: - A tenant-scoped principal may omit it. - A principal with no tenant of its own names one here. Refused when: - A tenant-scoped principal sends a value naming any other tenant. - A principal with no tenant of its own omits it. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found Response body (`200`): Content type `application/json`: - `sid` (string, required) - `tenant_sid` (string, required) - `name` (string, required) - `email` (string, required) - `external_id` (string, required) - `country` (string, required) - `timezone` (string, required) - `phone` (string, required) - `lines` (integer, required): Simultaneous calls the account may hold across its agents. - `retention` (object, required): Carries the retention periods this level sets, in days. For a `null` period: - An account follows its tenant. - A tenant follows the global retention period of 365 days. - `communication` (integer | null, required): Sets how many days a communication and its data are kept after its creation. An SMS is kept the same number of days after its creation. - `contact` (integer | null, required): Sets how many days a contact and its data are kept after its last communication or its last update, whichever is later. A contact is kept while it has a communication. - `contact_limits` (object, required): Records the contact limits set on this account. A `null` limit is the platform's. The platform's limits: - `data_fields` is 30. - `value_bytes` is 100. - `array_items` is 100. - `contacts` is 100 000. - `data_fields` (integer | null, required): Bounds the fields of a contact's data, counted at any depth, an array as one field. - `value_bytes` (integer | null, required): Bounds the bytes of one value of a contact's data, and of each item of an array. - `array_items` (integer | null, required): Bounds the items of an array in a contact's data. - `contacts` (integer | null, required): Bounds the contacts the account holds. - `status` (enum(active, inactive), required) - `deleted_at` (string | null (date-time), required) ### Delete account by external identifier `DELETE /v1/t/account/-/external/{external_id}` Operation id: `DeleteAccountByExternalID` Soft-deletes the account the client system gave this key, as a delete by sid does, without the caller knowing the platform sid. Resolution is the read's, inside the caller's tenant: its own, or the one it names with `X-Tenant-Sid`. Effects: - The delete cascades to the account's users. - The key is released for reuse by a live account. Parameters: - `external_id` (path, string, required) - `X-Tenant-Sid` (header, string): Names the target tenant. By principal: - A tenant-scoped principal may omit it. - A principal with no tenant of its own names one here. Refused when: - A tenant-scoped principal sends a value naming any other tenant. - A principal with no tenant of its own omits it. Responses: - `204`: No content - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `409`: Conflict ### Get account `GET /v1/t/account/{sid}` Operation id: `GetAccount` One account of the tenant. Parameters: - `sid` (path, string, required) Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found Response body (`200`): Content type `application/json`: - `sid` (string, required) - `tenant_sid` (string, required) - `name` (string, required) - `email` (string, required) - `external_id` (string, required) - `country` (string, required) - `timezone` (string, required) - `phone` (string, required) - `lines` (integer, required): Simultaneous calls the account may hold across its agents. - `retention` (object, required): Carries the retention periods this level sets, in days. For a `null` period: - An account follows its tenant. - A tenant follows the global retention period of 365 days. - `communication` (integer | null, required): Sets how many days a communication and its data are kept after its creation. An SMS is kept the same number of days after its creation. - `contact` (integer | null, required): Sets how many days a contact and its data are kept after its last communication or its last update, whichever is later. A contact is kept while it has a communication. - `contact_limits` (object, required): Records the contact limits set on this account. A `null` limit is the platform's. The platform's limits: - `data_fields` is 30. - `value_bytes` is 100. - `array_items` is 100. - `contacts` is 100 000. - `data_fields` (integer | null, required): Bounds the fields of a contact's data, counted at any depth, an array as one field. - `value_bytes` (integer | null, required): Bounds the bytes of one value of a contact's data, and of each item of an array. - `array_items` (integer | null, required): Bounds the items of an array in a contact's data. - `contacts` (integer | null, required): Bounds the contacts the account holds. - `status` (enum(active, inactive), required) - `deleted_at` (string | null (date-time), required) ### Delete account `DELETE /v1/t/account/{sid}` Operation id: `DeleteAccount` Soft-deletes the account, cascading to its users, agents, scenarios, numbers, number pools, SMS providers, communications, results, contacts, segments, STT dictionaries, limit policies and automations. Effects: - Each cascaded record is marked deleted, and none is physically removed. - With `show_deleted=true` the account list still returns the account. - No other list on the account or tenant plane returns anything under the account. - Credentials are the one exception: they are deleted outright, so the account's API keys and sessions stop authenticating immediately. There is no hard delete at account level; physical removal exists only for a tenant. Parameters: - `sid` (path, string, required) Responses: - `204`: No content - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `409`: Conflict ### Update account `PATCH /v1/t/account/{sid}` Operation id: `PatchAccount` Updates the account. Rules: - `tenant_sid` is not among the fields, so an account stays with the tenant it was created under. - A caller may hold the permission for `lines` without the permission for the other fields, and then changes `lines` only. - The permission for the other fields includes the permission for `lines`. - An archived agent holds no line, so it is neither counted nor reduced. When `lines` is lowered below what the account's agents already hold: - The agents are fitted inside it rather than the request being refused. - They are reduced oldest first, each to the one line an agent needs to answer at all, until the total fits. - The agent the allocation runs out at keeps what is left of it. When `status` is set to inactive: - The account's users are signed out. - Every credential scoped to the account stops authenticating. - The account's API keys survive that: they refuse for as long as the hold lasts, then authenticate again unchanged. - The sessions do not come back. Refused when: - A caller with only the permission for `lines` sends a request that carries any other field. - The `lines` allocation is below the number of agents that are not archived. Parameters: - `sid` (path, string, required) Request body: Content type `application/json`: - `name` (string) - `email` (string (email)) - `external_id` (string) - `country` (string) - `timezone` (string) - `phone` (string): Digits only, no separators. - `lines` (integer): Simultaneous calls the account may hold across its agents. - `retention` (RetentionConfigurationInput | null): Replaces both periods. An explicit `null` clears both, and the account follows its tenant again. - `contact_limits` (ContactLimitsInput | null): Replaces the account's contact limits. Rules: - A limit left out is the platform's. - An explicit `null` makes every limit the platform's. - Data already stored past a lowered limit is kept. A later write to a contact whose data is past a lowered limit, a dispatch included, is refused while it leaves the data past the limit. - `status` (enum(active, inactive)) Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `409`: Conflict - `422`: Unprocessable Response body (`200`): Content type `application/json`: - `sid` (string, required) - `tenant_sid` (string, required) - `name` (string, required) - `email` (string, required) - `external_id` (string, required) - `country` (string, required) - `timezone` (string, required) - `phone` (string, required) - `lines` (integer, required): Simultaneous calls the account may hold across its agents. - `retention` (object, required): Carries the retention periods this level sets, in days. For a `null` period: - An account follows its tenant. - A tenant follows the global retention period of 365 days. - `communication` (integer | null, required): Sets how many days a communication and its data are kept after its creation. An SMS is kept the same number of days after its creation. - `contact` (integer | null, required): Sets how many days a contact and its data are kept after its last communication or its last update, whichever is later. A contact is kept while it has a communication. - `contact_limits` (object, required): Records the contact limits set on this account. A `null` limit is the platform's. The platform's limits: - `data_fields` is 30. - `value_bytes` is 100. - `array_items` is 100. - `contacts` is 100 000. - `data_fields` (integer | null, required): Bounds the fields of a contact's data, counted at any depth, an array as one field. - `value_bytes` (integer | null, required): Bounds the bytes of one value of a contact's data, and of each item of an array. - `array_items` (integer | null, required): Bounds the items of an array in a contact's data. - `contacts` (integer | null, required): Bounds the contacts the account holds. - `status` (enum(active, inactive), required) - `deleted_at` (string | null (date-time), required) ### List tenant-level users `GET /v1/t/user` Operation id: `ListTenantUsers` The tenant-level users of the caller's tenant: the people who belong to the tenant itself rather than to one of its accounts. Parameters: - `X-Tenant-Sid` (header, string): Names the target tenant. By principal: - A tenant-scoped principal may omit it. - A principal with no tenant of its own names one here. Refused when: - A tenant-scoped principal sends a value naming any other tenant. - A principal with no tenant of its own omits it. - `show_deleted` (query, boolean): Include soft-deleted users in the listing. - `filter_or` (query, string): Names the fields, comma-separated, that `filter_query` searches with OR. It accepts `name` and `email`, each matched as a substring, case-insensitive. Refused when: - One of `filter_or` and `filter_query` is sent without the other. - A field is unknown. - `filter_query` (query, string): Search term matched across the fields named in filter_or. - `order_by` (query, string): Sort field. Accepted: created_at, name, email (default created_at). - `order` (query, string): Sort direction: asc | desc (default desc). - `limit` (query, integer): Page size, max 500 (default 100). - `offset` (query, integer) Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found Response body (`200`): Content type `application/json`: - `items` (array of object, required) - `sid` (string, required) - `account_sid` (string | null, required): Names the owning account; null for a tenant-level user. - `tenant_sid` (string | null, required): Names the owning tenant; null for an account-level user. - `level` (enum(account, tenant), required): Declares the owner of the user: account or tenant. - `email` (string, required) - `name` (string, required) - `external_id` (string, required): Carries the key the client system provisioning this user assigned to them. When set, unique among the live users of the account, or among the live tenant-level users of the tenant. - `roles` (array of string, required): Lists the names of the roles the user holds. - `status` (enum(active, inactive), required) - `has_password` (boolean, required): Says whether the user can sign in with a password. One created without one gets in only through a magic link or a password reset. - `last_login_at` (string | null (date-time), required) - `deleted_at` (string | null (date-time), required) - `total` (integer (int64), required): Counts the users matching the query, ignoring paging. - `limit` (integer, required): Reports the page size applied to this request. - `offset` (integer, required): Reports the offset applied to this request. - `has_more` (boolean, required): Says whether records beyond this page match the query. ### Create tenant-level user `POST /v1/t/user` Operation id: `CreateTenantUser` Creates the tenant-level user active. Rules: - The request carries no password: the user holds none, and sign-in is by magic link only. - `external_id` stays optional while the tenant declares `user` in `managed_resources`. Parameters: - `X-Tenant-Sid` (header, string): Names the target tenant. By principal: - A tenant-scoped principal may omit it. - A principal with no tenant of its own names one here. Refused when: - A tenant-scoped principal sends a value naming any other tenant. - A principal with no tenant of its own omits it. Request body: Content type `application/json`: - `email` (string (email), required) - `name` (string) - `external_id` (string) - `roles` (array of string): Names of roles listed by `GET /v1/t/role`; omitted means no roles until a patch assigns them. Responses: - `201`: Created - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `409`: Conflict - `422`: Unprocessable Response body (`201`): Content type `application/json`: - `sid` (string, required) - `account_sid` (string | null, required): Names the owning account; null for a tenant-level user. - `tenant_sid` (string | null, required): Names the owning tenant; null for an account-level user. - `level` (enum(account, tenant), required): Declares the owner of the user: account or tenant. - `email` (string, required) - `name` (string, required) - `external_id` (string, required): Carries the key the client system provisioning this user assigned to them. When set, unique among the live users of the account, or among the live tenant-level users of the tenant. - `roles` (array of string, required): Lists the names of the roles the user holds. - `status` (enum(active, inactive), required) - `has_password` (boolean, required): Says whether the user can sign in with a password. One created without one gets in only through a magic link or a password reset. - `last_login_at` (string | null (date-time), required) - `deleted_at` (string | null (date-time), required) ### Get tenant-level user by external identifier `GET /v1/t/user/-/external/{external_id}` Operation id: `GetTenantUserByExternalID` Reads the tenant-level user of the caller's tenant that carries this external identifier. The caller does not need the platform sid. Parameters: - `external_id` (path, string, required) - `X-Tenant-Sid` (header, string): Names the target tenant. By principal: - A tenant-scoped principal may omit it. - A principal with no tenant of its own names one here. Refused when: - A tenant-scoped principal sends a value naming any other tenant. - A principal with no tenant of its own omits it. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found Response body (`200`): Content type `application/json`: - `sid` (string, required) - `account_sid` (string | null, required): Names the owning account; null for a tenant-level user. - `tenant_sid` (string | null, required): Names the owning tenant; null for an account-level user. - `level` (enum(account, tenant), required): Declares the owner of the user: account or tenant. - `email` (string, required) - `name` (string, required) - `external_id` (string, required): Carries the key the client system provisioning this user assigned to them. When set, unique among the live users of the account, or among the live tenant-level users of the tenant. - `roles` (array of string, required): Lists the names of the roles the user holds. - `status` (enum(active, inactive), required) - `has_password` (boolean, required): Says whether the user can sign in with a password. One created without one gets in only through a magic link or a password reset. - `last_login_at` (string | null (date-time), required) - `deleted_at` (string | null (date-time), required) ### Delete tenant-level user by external identifier `DELETE /v1/t/user/-/external/{external_id}` Operation id: `DeleteTenantUserByExternalID` Deletes the tenant-level user of the caller's tenant that carries this external identifier. Rules: - The delete is soft and has the same effect as the delete by sid. - After it, another user can take the identifier. Refused when: - The request is for the caller's own user, with that user's session or with that user's API key. - The user's roles carry a permission the caller does not hold. Parameters: - `external_id` (path, string, required) - `X-Tenant-Sid` (header, string): Names the target tenant. By principal: - A tenant-scoped principal may omit it. - A principal with no tenant of its own names one here. Refused when: - A tenant-scoped principal sends a value naming any other tenant. - A principal with no tenant of its own omits it. Responses: - `204`: No content - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found ### Get tenant-level user `GET /v1/t/user/{sid}` Operation id: `GetTenantUser` One tenant-level user. Parameters: - `sid` (path, string, required) - `X-Tenant-Sid` (header, string): Names the target tenant. By principal: - A tenant-scoped principal may omit it. - A principal with no tenant of its own names one here. Refused when: - A tenant-scoped principal sends a value naming any other tenant. - A principal with no tenant of its own omits it. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found Response body (`200`): Content type `application/json`: - `sid` (string, required) - `account_sid` (string | null, required): Names the owning account; null for a tenant-level user. - `tenant_sid` (string | null, required): Names the owning tenant; null for an account-level user. - `level` (enum(account, tenant), required): Declares the owner of the user: account or tenant. - `email` (string, required) - `name` (string, required) - `external_id` (string, required): Carries the key the client system provisioning this user assigned to them. When set, unique among the live users of the account, or among the live tenant-level users of the tenant. - `roles` (array of string, required): Lists the names of the roles the user holds. - `status` (enum(active, inactive), required) - `has_password` (boolean, required): Says whether the user can sign in with a password. One created without one gets in only through a magic link or a password reset. - `last_login_at` (string | null (date-time), required) - `deleted_at` (string | null (date-time), required) ### Delete tenant-level user `DELETE /v1/t/user/{sid}` Operation id: `DeleteTenantUser` Soft-deletes the tenant-level user. Rules: - The user reads as absent afterwards but still appears under `show_deleted`. - The email address is free to use again. Effects: - Its credentials are removed at once, so every session and outstanding magic link stops working. Refused when: - The request is for the caller's own user, with that user's session or with that user's API key. - The user's roles carry a permission the caller does not hold. Parameters: - `sid` (path, string, required) - `X-Tenant-Sid` (header, string): Names the target tenant. By principal: - A tenant-scoped principal may omit it. - A principal with no tenant of its own names one here. Refused when: - A tenant-scoped principal sends a value naming any other tenant. - A principal with no tenant of its own omits it. Responses: - `204`: No content - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found ### Update tenant-level user `PATCH /v1/t/user/{sid}` Operation id: `PatchTenantUser` Updates the tenant-level user. Rules: - `email` replaces the address the user signs in with. - No password field exists at this level. On a move of `status` to `inactive`: - The user can no longer get a new session. - The sessions and magic links the user already holds end. - A move back restores none of them. Refused when: - The request is for the caller's own user, with that user's session or with that user's API key. - The user's roles carry a permission the caller does not hold. Parameters: - `sid` (path, string, required) - `X-Tenant-Sid` (header, string): Names the target tenant. By principal: - A tenant-scoped principal may omit it. - A principal with no tenant of its own names one here. Refused when: - A tenant-scoped principal sends a value naming any other tenant. - A principal with no tenant of its own omits it. Request body: Content type `application/json`: - `name` (string) - `email` (string (email)): Replaces the address the user signs in with; unique among the live users of its level. - `external_id` (string) - `roles` (array of string): Replaces the user's roles outright with names of roles listed by `GET /v1/t/role`. - `status` (enum(active, inactive)) Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `409`: Conflict - `422`: Unprocessable Response body (`200`): Content type `application/json`: - `sid` (string, required) - `account_sid` (string | null, required): Names the owning account; null for a tenant-level user. - `tenant_sid` (string | null, required): Names the owning tenant; null for an account-level user. - `level` (enum(account, tenant), required): Declares the owner of the user: account or tenant. - `email` (string, required) - `name` (string, required) - `external_id` (string, required): Carries the key the client system provisioning this user assigned to them. When set, unique among the live users of the account, or among the live tenant-level users of the tenant. - `roles` (array of string, required): Lists the names of the roles the user holds. - `status` (enum(active, inactive), required) - `has_password` (boolean, required): Says whether the user can sign in with a password. One created without one gets in only through a magic link or a password reset. - `last_login_at` (string | null (date-time), required) - `deleted_at` (string | null (date-time), required) ### Request tenant-level user magic link `POST /v1/t/user/{sid}/magic-link/request` Operation id: `IssueTenantUserMagicLink` Returns a single-use magic-link token for the tenant-level user, with the consume URL and a browser link (`web_url`) into the web frontend that signs the person in. Rules: - This is the only way to sign in at tenant level; no password exists to reset. - The platform sends no email. - A new token invalidates the previous outstanding one. Refused when the user's roles carry a permission the caller does not hold. Parameters: - `sid` (path, string, required) - `X-Tenant-Sid` (header, string): Names the target tenant. By principal: - A tenant-scoped principal may omit it. - A principal with no tenant of its own names one here. Refused when: - A tenant-scoped principal sends a value naming any other tenant. - A principal with no tenant of its own omits it. Responses: - `201`: Created - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `409`: Conflict Response body (`201`): Content type `application/json`: - `token` (string, required) - `expires_at` (string (date-time), required) - `consume_url` (string, required): Points at the public consume endpoint the token is redeemed at. - `web_url` (string, required): Signs the person in from a browser link — the web frontend's consume page carrying the token. ### List the tenant-level users' API keys `GET /v1/t/user/-/api-key` Operation id: `ListTenantAPIKeys` The keys owned by the tenant's own people, newest first, without the secret. An account user's key is listed on the account plane, naming the account. Parameters: - `X-Tenant-Sid` (header, string): Names the target tenant. By principal: - A tenant-scoped principal may omit it. - A principal with no tenant of its own names one here. Refused when: - A tenant-scoped principal sends a value naming any other tenant. - A principal with no tenant of its own omits it. - `order_by` (query, string): Sort field. Accepted: created_at, name, expires_at, last_used_at (default created_at). - `order` (query, string): Sort direction: asc | desc (default desc). - `limit` (query, integer): Page size, max 500 (default 100). - `offset` (query, integer) Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found Response body (`200`): Content type `application/json`: - `items` (array of object, required) - `sid` (string, required) - `name` (string, required) - `user_sid` (string, required): Names the owner. - `account_sid` (string | null, required): Names the owner's account; null for a tenant-level owner. - `level` (enum(account, tenant), required): Declares the owner's level: account or tenant. - `metadata` (object, required): Carries the object given at issue, as given. - `created_at` (string (date-time), required) - `expires_at` (string | null (date-time), required): Records when the key stops authenticating. - `last_used_at` (string | null (date-time), required): Records the last request the key authenticated; null while it has not been used. - `total` (integer (int64), required): Counts the keys matching the query, ignoring paging. - `limit` (integer, required): Reports the page size applied to this request. - `offset` (integer, required): Reports the offset applied to this request. - `has_more` (boolean, required): Says whether records beyond this page match the query. ### List a tenant-level user's API keys `GET /v1/t/user/{sid}/api-key` Operation id: `ListTenantUserAPIKeys` The keys the tenant-level user owns, in the same shape as the tenant's list. Parameters: - `sid` (path, string, required) - `X-Tenant-Sid` (header, string): Names the target tenant. By principal: - A tenant-scoped principal may omit it. - A principal with no tenant of its own names one here. Refused when: - A tenant-scoped principal sends a value naming any other tenant. - A principal with no tenant of its own omits it. - `order_by` (query, string): Sort field. Accepted: created_at, name, expires_at, last_used_at (default created_at). - `order` (query, string): Sort direction: asc | desc (default desc). - `limit` (query, integer): Page size, max 500 (default 100). - `offset` (query, integer) Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found Response body (`200`): Content type `application/json`: - `items` (array of object, required) - `sid` (string, required) - `name` (string, required) - `user_sid` (string, required): Names the owner. - `account_sid` (string | null, required): Names the owner's account; null for a tenant-level owner. - `level` (enum(account, tenant), required): Declares the owner's level: account or tenant. - `metadata` (object, required): Carries the object given at issue, as given. - `created_at` (string (date-time), required) - `expires_at` (string | null (date-time), required): Records when the key stops authenticating. - `last_used_at` (string | null (date-time), required): Records the last request the key authenticated; null while it has not been used. - `total` (integer (int64), required): Counts the keys matching the query, ignoring paging. - `limit` (integer, required): Reports the page size applied to this request. - `offset` (integer, required): Reports the offset applied to this request. - `has_more` (boolean, required): Says whether records beyond this page match the query. ### Issue tenant-level user API key `POST /v1/t/user/{sid}/api-key` Operation id: `IssueTenantUserAPIKey` Creates an API key owned by the tenant-level user and returns its secret once; only a hash is kept, so a lost secret cannot be recovered. Rules: - The key acts with the user's roles across the tenant's accounts, naming its target with `X-Account-Sid` like the user's own session. - The key stops authenticating while the user or their tenant is not active, and works again once they are. - Omitting `expires_at` creates a key that expires one year after issue. - Earlier keys stay valid: issuing revokes nothing. - A key stops working when its `expires_at` passes, its user is deleted or it is revoked. Refused when the user's roles carry a permission the caller does not hold. Parameters: - `sid` (path, string, required) - `X-Tenant-Sid` (header, string): Names the target tenant. By principal: - A tenant-scoped principal may omit it. - A principal with no tenant of its own names one here. Refused when: - A tenant-scoped principal sends a value naming any other tenant. - A principal with no tenant of its own omits it. Request body: Content type `application/json`: - `name` (string, required): Labels the key in listings. - `expires_at` (string (date-time)): Sets when the key stops authenticating. Omitted, the key expires one year after issue. - `metadata` (object): Carries the caller's own note on the key, held and returned as given. Nothing in it is read by the platform. Responses: - `201`: Created - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `409`: Conflict - `422`: Unprocessable Response body (`201`): Content type `application/json`: - `sid` (string, required) - `secret` (string, required) ### Revoke a tenant-level user's API key `DELETE /v1/t/user/{sid}/api-key/{key_sid}` Operation id: `RevokeTenantUserAPIKey` Deletes the key. Rules: - The key authenticates nothing from the next request on. - The user's other keys are untouched. Refused when the user's roles carry a permission the caller does not hold. Parameters: - `sid` (path, string, required) - `key_sid` (path, string, required) - `X-Tenant-Sid` (header, string): Names the target tenant. By principal: - A tenant-scoped principal may omit it. - A principal with no tenant of its own names one here. Refused when: - A tenant-scoped principal sends a value naming any other tenant. - A principal with no tenant of its own omits it. Responses: - `204`: No content - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found ### List the permission catalog `GET /v1/t/permission` Operation id: `ListPermissions` The permissions a role of the tenant may name, each with its level. Parameters: - `X-Tenant-Sid` (header, string): Names the target tenant. By principal: - A tenant-scoped principal may omit it. - A principal with no tenant of its own names one here. Refused when: - A tenant-scoped principal sends a value naming any other tenant. - A principal with no tenant of its own omits it. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden Response body (`200`): Content type `application/json`: - `items` (array of object, required) - `name` (any, required): Carries the name a route requires. - `level` (any, required): Sets the roles that may name the permission. Values: - `account`: roles of either level may name it. - `tenant`: only `tenant` roles may name it. ### List roles `GET /v1/t/role` Operation id: `ListRoles` The live roles of the caller's tenant: the fixed roles, marked `fixed`, then the tenant's own roles of both levels. Parameters: - `X-Tenant-Sid` (header, string): Names the target tenant. By principal: - A tenant-scoped principal may omit it. - A principal with no tenant of its own names one here. Refused when: - A tenant-scoped principal sends a value naming any other tenant. - A principal with no tenant of its own omits it. - `order_by` (query, string): Sort field. Accepted: created_at, name (default created_at). - `order` (query, string): Sort direction: asc | desc (default desc). - `limit` (query, integer): Page size, max 500 (default 100). - `offset` (query, integer) Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden Response body (`200`): Content type `application/json`: - `items` (array of object, required) - `id` (string, required): Prefixed `rol_…`. - `name` (string, required) - `level` (any, required): Declares who holds the role. Values: - `account`: the role is held by users of either level. - `tenant`: the role is held by tenant-level users only. - `permissions` (array of enum(agent:read, agent:write, agent:manage, agent:automation:read, agent:automation:write, agent:automation:manage, agent:routing:read, agent:routing:write, agent:routing:manage, scenario:read, scenario:write, scenario:manage, communication:read, communication:write, communication:manage, number:read, number:write, number:manage, number:pool:read, number:pool:write, number:pool:manage, contact:read, contact:write, contact:manage, segment:read, segment:write, segment:manage, integration:sms:read, integration:sms:write, integration:sms:manage, account:read, account:manage, account:capacity:manage, tenant:user:read, tenant:user:manage, tenant:api_key:manage, tenant:sign_in:manage, tenant:role:read, tenant:role:manage, tenant:scenario_template:manage, scenario:template:read, analytics:read, account:user:manage, account:api_key:manage, account:sign_in:manage, account:profile:write, account:role:read, tts:synthesize:manage, tts:voice:read, llm:chat:manage, llm:document:manage, llm:model:read, ids:classifier:write, ids:classifier:manage, ids:entity:write, ids:model:read, stt:recognition:write, stt:dictionary:read, stt:dictionary:write, stt:dictionary:manage, edge:function:read, edge:function:write, edge:function:manage), required): Lists the role's own permissions, without the ones its parents carry. - `inherits` (array of string, required): Lists the `id` of every parent role, a role whose permissions this one inherits. - `fixed` (boolean, required): Declares a role defined by the platform. Refused when: - A fixed role is edited. - A fixed role is deleted. - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) - `total` (integer (int64), required): Counts the roles matching the query, ignoring paging. - `limit` (integer, required): Reports the page size applied to this request. - `offset` (integer, required): Reports the offset applied to this request. - `has_more` (boolean, required): Says whether records beyond this page match the query. ### Create role `POST /v1/t/role` Operation id: `CreateRole` Creates a role of the caller's tenant. Refused when: - The parent is not a live role of the tenant. - The parent is a fixed `tenant` role. - The role is an `account` role with a `tenant` parent. - A live role of the tenant holds the name, whatever its letter case. - The role's permissions, with those of its parents, go beyond the caller's own. Parameters: - `X-Tenant-Sid` (header, string): Names the target tenant. By principal: - A tenant-scoped principal may omit it. - A principal with no tenant of its own names one here. Refused when: - A tenant-scoped principal sends a value naming any other tenant. - A principal with no tenant of its own omits it. Request body: Content type `application/json`: - `name` (string, required) - `level` (any): Sets who holds the role; a later edit does not change it. Omitted means `account`. - `permissions` (array of enum(agent:read, agent:write, agent:manage, agent:automation:read, agent:automation:write, agent:automation:manage, agent:routing:read, agent:routing:write, agent:routing:manage, scenario:read, scenario:write, scenario:manage, communication:read, communication:write, communication:manage, number:read, number:write, number:manage, number:pool:read, number:pool:write, number:pool:manage, contact:read, contact:write, contact:manage, segment:read, segment:write, segment:manage, integration:sms:read, integration:sms:write, integration:sms:manage, account:read, account:manage, account:capacity:manage, tenant:user:read, tenant:user:manage, tenant:api_key:manage, tenant:sign_in:manage, tenant:role:read, tenant:role:manage, tenant:scenario_template:manage, scenario:template:read, analytics:read, account:user:manage, account:api_key:manage, account:sign_in:manage, account:profile:write, account:role:read, tts:synthesize:manage, tts:voice:read, llm:chat:manage, llm:document:manage, llm:model:read, ids:classifier:write, ids:classifier:manage, ids:entity:write, ids:model:read, stt:recognition:write, stt:dictionary:read, stt:dictionary:write, stt:dictionary:manage, edge:function:read, edge:function:write, edge:function:manage)): Names from the permission catalog; omitted means none. - `inherits` (array of string): Lists the `id` of every parent role; omitted means none. Responses: - `201`: Created - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `409`: Conflict - `422`: Unprocessable Response body (`201`): Content type `application/json`: - `id` (string, required): Prefixed `rol_…`. - `name` (string, required) - `level` (any, required): Declares who holds the role. Values: - `account`: the role is held by users of either level. - `tenant`: the role is held by tenant-level users only. - `permissions` (array of enum(agent:read, agent:write, agent:manage, agent:automation:read, agent:automation:write, agent:automation:manage, agent:routing:read, agent:routing:write, agent:routing:manage, scenario:read, scenario:write, scenario:manage, communication:read, communication:write, communication:manage, number:read, number:write, number:manage, number:pool:read, number:pool:write, number:pool:manage, contact:read, contact:write, contact:manage, segment:read, segment:write, segment:manage, integration:sms:read, integration:sms:write, integration:sms:manage, account:read, account:manage, account:capacity:manage, tenant:user:read, tenant:user:manage, tenant:api_key:manage, tenant:sign_in:manage, tenant:role:read, tenant:role:manage, tenant:scenario_template:manage, scenario:template:read, analytics:read, account:user:manage, account:api_key:manage, account:sign_in:manage, account:profile:write, account:role:read, tts:synthesize:manage, tts:voice:read, llm:chat:manage, llm:document:manage, llm:model:read, ids:classifier:write, ids:classifier:manage, ids:entity:write, ids:model:read, stt:recognition:write, stt:dictionary:read, stt:dictionary:write, stt:dictionary:manage, edge:function:read, edge:function:write, edge:function:manage), required): Lists the role's own permissions, without the ones its parents carry. - `inherits` (array of string, required): Lists the `id` of every parent role, a role whose permissions this one inherits. - `fixed` (boolean, required): Declares a role defined by the platform. Refused when: - A fixed role is edited. - A fixed role is deleted. - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) ### Get role `GET /v1/t/role/{sid}` Operation id: `GetRole` One role of the caller's tenant. Parameters: - `sid` (path, string, required): The role's `id`. - `X-Tenant-Sid` (header, string): Names the target tenant. By principal: - A tenant-scoped principal may omit it. - A principal with no tenant of its own names one here. Refused when: - A tenant-scoped principal sends a value naming any other tenant. - A principal with no tenant of its own omits it. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found Response body (`200`): Content type `application/json`: - `id` (string, required): Prefixed `rol_…`. - `name` (string, required) - `level` (any, required): Declares who holds the role. Values: - `account`: the role is held by users of either level. - `tenant`: the role is held by tenant-level users only. - `permissions` (array of enum(agent:read, agent:write, agent:manage, agent:automation:read, agent:automation:write, agent:automation:manage, agent:routing:read, agent:routing:write, agent:routing:manage, scenario:read, scenario:write, scenario:manage, communication:read, communication:write, communication:manage, number:read, number:write, number:manage, number:pool:read, number:pool:write, number:pool:manage, contact:read, contact:write, contact:manage, segment:read, segment:write, segment:manage, integration:sms:read, integration:sms:write, integration:sms:manage, account:read, account:manage, account:capacity:manage, tenant:user:read, tenant:user:manage, tenant:api_key:manage, tenant:sign_in:manage, tenant:role:read, tenant:role:manage, tenant:scenario_template:manage, scenario:template:read, analytics:read, account:user:manage, account:api_key:manage, account:sign_in:manage, account:profile:write, account:role:read, tts:synthesize:manage, tts:voice:read, llm:chat:manage, llm:document:manage, llm:model:read, ids:classifier:write, ids:classifier:manage, ids:entity:write, ids:model:read, stt:recognition:write, stt:dictionary:read, stt:dictionary:write, stt:dictionary:manage, edge:function:read, edge:function:write, edge:function:manage), required): Lists the role's own permissions, without the ones its parents carry. - `inherits` (array of string, required): Lists the `id` of every parent role, a role whose permissions this one inherits. - `fixed` (boolean, required): Declares a role defined by the platform. Refused when: - A fixed role is edited. - A fixed role is deleted. - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) ### Delete role `DELETE /v1/t/role/{sid}` Operation id: `DeleteRole` Soft-deletes the role. Rules: - The role is no longer listed. - Its name can be used again. Refused when: - A live user of the tenant holds the role, or a live role inherits it. - The role carries a permission the caller does not hold. - The role is fixed. Parameters: - `sid` (path, string, required): The role's `id`. - `X-Tenant-Sid` (header, string): Names the target tenant. By principal: - A tenant-scoped principal may omit it. - A principal with no tenant of its own names one here. Refused when: - A tenant-scoped principal sends a value naming any other tenant. - A principal with no tenant of its own omits it. Responses: - `204`: No content - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `409`: Conflict ### Update role `PATCH /v1/t/role/{sid}` Operation id: `PatchRole` Updates the role partially. Rules: - An omitted field preserves the current value. - A list that is sent replaces the stored list. - The level stays as created. - A rename is applied to every user of the tenant holding the role. Refused when: - The role as it would be after the update meets a refusal of `POST /v1/t/role`. - The parent inherits this role, directly or through other roles. - The role as stored carries a permission the caller does not hold. - The role is a fixed role. Parameters: - `sid` (path, string, required): The role's `id`. - `X-Tenant-Sid` (header, string): Names the target tenant. By principal: - A tenant-scoped principal may omit it. - A principal with no tenant of its own names one here. Refused when: - A tenant-scoped principal sends a value naming any other tenant. - A principal with no tenant of its own omits it. Request body: Content type `application/json`: - `name` (string) - `permissions` (array of enum(agent:read, agent:write, agent:manage, agent:automation:read, agent:automation:write, agent:automation:manage, agent:routing:read, agent:routing:write, agent:routing:manage, scenario:read, scenario:write, scenario:manage, communication:read, communication:write, communication:manage, number:read, number:write, number:manage, number:pool:read, number:pool:write, number:pool:manage, contact:read, contact:write, contact:manage, segment:read, segment:write, segment:manage, integration:sms:read, integration:sms:write, integration:sms:manage, account:read, account:manage, account:capacity:manage, tenant:user:read, tenant:user:manage, tenant:api_key:manage, tenant:sign_in:manage, tenant:role:read, tenant:role:manage, tenant:scenario_template:manage, scenario:template:read, analytics:read, account:user:manage, account:api_key:manage, account:sign_in:manage, account:profile:write, account:role:read, tts:synthesize:manage, tts:voice:read, llm:chat:manage, llm:document:manage, llm:model:read, ids:classifier:write, ids:classifier:manage, ids:entity:write, ids:model:read, stt:recognition:write, stt:dictionary:read, stt:dictionary:write, stt:dictionary:manage, edge:function:read, edge:function:write, edge:function:manage)) - `inherits` (array of string) Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `409`: Conflict - `422`: Unprocessable Response body (`200`): Content type `application/json`: - `id` (string, required): Prefixed `rol_…`. - `name` (string, required) - `level` (any, required): Declares who holds the role. Values: - `account`: the role is held by users of either level. - `tenant`: the role is held by tenant-level users only. - `permissions` (array of enum(agent:read, agent:write, agent:manage, agent:automation:read, agent:automation:write, agent:automation:manage, agent:routing:read, agent:routing:write, agent:routing:manage, scenario:read, scenario:write, scenario:manage, communication:read, communication:write, communication:manage, number:read, number:write, number:manage, number:pool:read, number:pool:write, number:pool:manage, contact:read, contact:write, contact:manage, segment:read, segment:write, segment:manage, integration:sms:read, integration:sms:write, integration:sms:manage, account:read, account:manage, account:capacity:manage, tenant:user:read, tenant:user:manage, tenant:api_key:manage, tenant:sign_in:manage, tenant:role:read, tenant:role:manage, tenant:scenario_template:manage, scenario:template:read, analytics:read, account:user:manage, account:api_key:manage, account:sign_in:manage, account:profile:write, account:role:read, tts:synthesize:manage, tts:voice:read, llm:chat:manage, llm:document:manage, llm:model:read, ids:classifier:write, ids:classifier:manage, ids:entity:write, ids:model:read, stt:recognition:write, stt:dictionary:read, stt:dictionary:write, stt:dictionary:manage, edge:function:read, edge:function:write, edge:function:manage), required): Lists the role's own permissions, without the ones its parents carry. - `inherits` (array of string, required): Lists the `id` of every parent role, a role whose permissions this one inherits. - `fixed` (boolean, required): Declares a role defined by the platform. Refused when: - A fixed role is edited. - A fixed role is deleted. - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) ### List scenario templates `GET /v1/t/scenario-template` Operation id: `ListTenantScenarioTemplates` The live templates of the caller's tenant, without `constructor`. Parameters: - `X-Tenant-Sid` (header, string): Names the target tenant. By principal: - A tenant-scoped principal may omit it. - A principal with no tenant of its own names one here. Refused when: - A tenant-scoped principal sends a value naming any other tenant. - A principal with no tenant of its own omits it. - `order_by` (query, string): Sort field. Accepted: created_at, name (default created_at). - `order` (query, string): Sort direction: asc | desc (default desc). - `limit` (query, integer): Page size, max 500 (default 100). - `offset` (query, integer) Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden Response body (`200`): Content type `application/json`: - `items` (array of object, required) - `id` (string, required): Prefixed `sct_…`. - `name` (string, required) - `description` (string, required) - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) - `total` (integer (int64), required): Counts the templates matching the query, ignoring paging. - `limit` (integer, required): Reports the page size applied to this request. - `offset` (integer, required): Reports the offset applied to this request. - `has_more` (boolean, required): Says whether records beyond this page match the query. ### Create scenario template `POST /v1/t/scenario-template` Operation id: `CreateScenarioTemplate` Creates a template of the caller's tenant. Rules: - The resources the constructor names belong to the tenant. Parameters: - `X-Tenant-Sid` (header, string): Names the target tenant. By principal: - A tenant-scoped principal may omit it. - A principal with no tenant of its own names one here. Refused when: - A tenant-scoped principal sends a value naming any other tenant. - A principal with no tenant of its own omits it. Request body: Content type `application/json`: - `name` (string, required) - `description` (string): Omitted means empty. - `constructor` (object, required) - `bricks` (object): Holds the properties of a brick, one key per brick type. Rules: - A text property reads a variable when it holds `{{name}}`, and a contact field when it holds `{{contact.}}`; the call puts the value in place when the brick runs. - A number, a boolean and an enum property take no variable. - `start_call`, `inbound_call`, `outbound_call`, `recording_setup`, `tree`, `start_tree`, `end_tree` and `end`: no property takes a variable. - `condition_group` and `assignment`: only `value` takes a variable. - `webhook`: only the method, the URL, the body, the names and values of the headers and of the form fields, the basic-auth username and password, the bearer token, the proxy URL, and the `path` and `set_if_not_found` of a response mapping take a variable. - A property that names a variable to write, such as `variable` of a response mapping or of `increment`, is written to and not read. - The guide with examples: https://docs.aiva.apifonica.com/guides/build/variables/ - `audio` (object) - `v1` (array of object) - `audio_file` (object) - `v1` (array of object) - `audio_tts` (object) - `v1` (array of object) - `sms` (object) - `v1` (array of object) - `goal` (object) - `v1` (array of object) - `end_call` (object) - `v1` (array of object) - `assignment` (object) - `v1` (array of object) - `increment` (object) - `v1` (array of object) - `condition_group` (object) - `v1` (array of object) - `start_tree` (object) - `v1` (array of object) - `start_call` (object) - `v1` (array of object) - `v2` (array of object) - `outbound_call` (object) - `v1` (array of object) - `inbound_call` (object) - `v1` (array of object) - `end` (object) - `v1` (array of object) - `call_transfer` (object) - `v1` (array of object) - `question` (object) - `v1` (array of object) - `webhook` (object) - `v1` (array of object) - `data_mapping` (object) - `v1` (array of object) - `tree` (object) - `v1` (array of object) - `end_tree` (object) - `v1` (array of object) - `background_audio` (object) - `v1` (array of object) - `javascript` (object) - `v1` (array of object) - `warm_up_tts` (object) - `v1` (array of object) - `business_metric` (object) - `v1` (array of object) - `ai_agent` (object) - `v1` (array of object) - `send_dtmf` (object) - `v1` (array of object) - `recording_setup` (object) - `v1` (array of object) - `transcription` (object) - `v1` (array of object) - `forest` (object) - `trees` (array of object) - `description` (string) - `tree_id` (string) - `nodes` (array of object) - `properties` (object) - `engine_version` (enum(v3)): Any value sent is stored as v3. Responses: - `201`: Created - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `422`: Unprocessable Response body (`201`): Content type `application/json`: - `id` (string, required): Prefixed `sct_…`. - `name` (string, required) - `description` (string, required) - `constructor` (object, required) - `bricks` (object): Holds the properties of a brick, one key per brick type. Rules: - A text property reads a variable when it holds `{{name}}`, and a contact field when it holds `{{contact.}}`; the call puts the value in place when the brick runs. - A number, a boolean and an enum property take no variable. - `start_call`, `inbound_call`, `outbound_call`, `recording_setup`, `tree`, `start_tree`, `end_tree` and `end`: no property takes a variable. - `condition_group` and `assignment`: only `value` takes a variable. - `webhook`: only the method, the URL, the body, the names and values of the headers and of the form fields, the basic-auth username and password, the bearer token, the proxy URL, and the `path` and `set_if_not_found` of a response mapping take a variable. - A property that names a variable to write, such as `variable` of a response mapping or of `increment`, is written to and not read. - The guide with examples: https://docs.aiva.apifonica.com/guides/build/variables/ - `audio` (object) - `v1` (array of object) - `audio_file` (object) - `v1` (array of object) - `audio_tts` (object) - `v1` (array of object) - `sms` (object) - `v1` (array of object) - `goal` (object) - `v1` (array of object) - `end_call` (object) - `v1` (array of object) - `assignment` (object) - `v1` (array of object) - `increment` (object) - `v1` (array of object) - `condition_group` (object) - `v1` (array of object) - `start_tree` (object) - `v1` (array of object) - `start_call` (object) - `v1` (array of object) - `v2` (array of object) - `outbound_call` (object) - `v1` (array of object) - `inbound_call` (object) - `v1` (array of object) - `end` (object) - `v1` (array of object) - `call_transfer` (object) - `v1` (array of object) - `question` (object) - `v1` (array of object) - `webhook` (object) - `v1` (array of object) - `data_mapping` (object) - `v1` (array of object) - `tree` (object) - `v1` (array of object) - `end_tree` (object) - `v1` (array of object) - `background_audio` (object) - `v1` (array of object) - `javascript` (object) - `v1` (array of object) - `warm_up_tts` (object) - `v1` (array of object) - `business_metric` (object) - `v1` (array of object) - `ai_agent` (object) - `v1` (array of object) - `send_dtmf` (object) - `v1` (array of object) - `recording_setup` (object) - `v1` (array of object) - `transcription` (object) - `v1` (array of object) - `forest` (object) - `trees` (array of object) - `description` (string) - `tree_id` (string) - `nodes` (array of object) - `properties` (object) - `engine_version` (enum(v3)): Any value sent is stored as v3. - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) ### Get scenario template `GET /v1/t/scenario-template/{id}` Operation id: `GetTenantScenarioTemplate` One template of the caller's tenant, with `constructor`. Parameters: - `id` (path, string, required): The template's `id`. - `X-Tenant-Sid` (header, string): Names the target tenant. By principal: - A tenant-scoped principal may omit it. - A principal with no tenant of its own names one here. Refused when: - A tenant-scoped principal sends a value naming any other tenant. - A principal with no tenant of its own omits it. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found Response body (`200`): Content type `application/json`: - `id` (string, required): Prefixed `sct_…`. - `name` (string, required) - `description` (string, required) - `constructor` (object, required) - `bricks` (object): Holds the properties of a brick, one key per brick type. Rules: - A text property reads a variable when it holds `{{name}}`, and a contact field when it holds `{{contact.}}`; the call puts the value in place when the brick runs. - A number, a boolean and an enum property take no variable. - `start_call`, `inbound_call`, `outbound_call`, `recording_setup`, `tree`, `start_tree`, `end_tree` and `end`: no property takes a variable. - `condition_group` and `assignment`: only `value` takes a variable. - `webhook`: only the method, the URL, the body, the names and values of the headers and of the form fields, the basic-auth username and password, the bearer token, the proxy URL, and the `path` and `set_if_not_found` of a response mapping take a variable. - A property that names a variable to write, such as `variable` of a response mapping or of `increment`, is written to and not read. - The guide with examples: https://docs.aiva.apifonica.com/guides/build/variables/ - `audio` (object) - `v1` (array of object) - `audio_file` (object) - `v1` (array of object) - `audio_tts` (object) - `v1` (array of object) - `sms` (object) - `v1` (array of object) - `goal` (object) - `v1` (array of object) - `end_call` (object) - `v1` (array of object) - `assignment` (object) - `v1` (array of object) - `increment` (object) - `v1` (array of object) - `condition_group` (object) - `v1` (array of object) - `start_tree` (object) - `v1` (array of object) - `start_call` (object) - `v1` (array of object) - `v2` (array of object) - `outbound_call` (object) - `v1` (array of object) - `inbound_call` (object) - `v1` (array of object) - `end` (object) - `v1` (array of object) - `call_transfer` (object) - `v1` (array of object) - `question` (object) - `v1` (array of object) - `webhook` (object) - `v1` (array of object) - `data_mapping` (object) - `v1` (array of object) - `tree` (object) - `v1` (array of object) - `end_tree` (object) - `v1` (array of object) - `background_audio` (object) - `v1` (array of object) - `javascript` (object) - `v1` (array of object) - `warm_up_tts` (object) - `v1` (array of object) - `business_metric` (object) - `v1` (array of object) - `ai_agent` (object) - `v1` (array of object) - `send_dtmf` (object) - `v1` (array of object) - `recording_setup` (object) - `v1` (array of object) - `transcription` (object) - `v1` (array of object) - `forest` (object) - `trees` (array of object) - `description` (string) - `tree_id` (string) - `nodes` (array of object) - `properties` (object) - `engine_version` (enum(v3)): Any value sent is stored as v3. - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) ### Delete scenario template `DELETE /v1/t/scenario-template/{id}` Operation id: `DeleteScenarioTemplate` Soft-deletes the template. Rules: - The template is no longer listed and cannot be copied. Parameters: - `id` (path, string, required): The template's `id`. - `X-Tenant-Sid` (header, string): Names the target tenant. By principal: - A tenant-scoped principal may omit it. - A principal with no tenant of its own names one here. Refused when: - A tenant-scoped principal sends a value naming any other tenant. - A principal with no tenant of its own omits it. Responses: - `204`: No content - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found ### Update scenario template `PATCH /v1/t/scenario-template/{id}` Operation id: `PatchScenarioTemplate` Updates the template partially. Rules: - An omitted field preserves the current value. - The resources the constructor names belong to the tenant. Parameters: - `id` (path, string, required): The template's `id`. - `X-Tenant-Sid` (header, string): Names the target tenant. By principal: - A tenant-scoped principal may omit it. - A principal with no tenant of its own names one here. Refused when: - A tenant-scoped principal sends a value naming any other tenant. - A principal with no tenant of its own omits it. Request body: Content type `application/json`: - `name` (string) - `description` (string) - `constructor` (object) - `bricks` (object): Holds the properties of a brick, one key per brick type. Rules: - A text property reads a variable when it holds `{{name}}`, and a contact field when it holds `{{contact.}}`; the call puts the value in place when the brick runs. - A number, a boolean and an enum property take no variable. - `start_call`, `inbound_call`, `outbound_call`, `recording_setup`, `tree`, `start_tree`, `end_tree` and `end`: no property takes a variable. - `condition_group` and `assignment`: only `value` takes a variable. - `webhook`: only the method, the URL, the body, the names and values of the headers and of the form fields, the basic-auth username and password, the bearer token, the proxy URL, and the `path` and `set_if_not_found` of a response mapping take a variable. - A property that names a variable to write, such as `variable` of a response mapping or of `increment`, is written to and not read. - The guide with examples: https://docs.aiva.apifonica.com/guides/build/variables/ - `audio` (object) - `v1` (array of object) - `audio_file` (object) - `v1` (array of object) - `audio_tts` (object) - `v1` (array of object) - `sms` (object) - `v1` (array of object) - `goal` (object) - `v1` (array of object) - `end_call` (object) - `v1` (array of object) - `assignment` (object) - `v1` (array of object) - `increment` (object) - `v1` (array of object) - `condition_group` (object) - `v1` (array of object) - `start_tree` (object) - `v1` (array of object) - `start_call` (object) - `v1` (array of object) - `v2` (array of object) - `outbound_call` (object) - `v1` (array of object) - `inbound_call` (object) - `v1` (array of object) - `end` (object) - `v1` (array of object) - `call_transfer` (object) - `v1` (array of object) - `question` (object) - `v1` (array of object) - `webhook` (object) - `v1` (array of object) - `data_mapping` (object) - `v1` (array of object) - `tree` (object) - `v1` (array of object) - `end_tree` (object) - `v1` (array of object) - `background_audio` (object) - `v1` (array of object) - `javascript` (object) - `v1` (array of object) - `warm_up_tts` (object) - `v1` (array of object) - `business_metric` (object) - `v1` (array of object) - `ai_agent` (object) - `v1` (array of object) - `send_dtmf` (object) - `v1` (array of object) - `recording_setup` (object) - `v1` (array of object) - `transcription` (object) - `v1` (array of object) - `forest` (object) - `trees` (array of object) - `description` (string) - `tree_id` (string) - `nodes` (array of object) - `properties` (object) - `engine_version` (enum(v3)): Any value sent is stored as v3. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `422`: Unprocessable Response body (`200`): Content type `application/json`: - `id` (string, required): Prefixed `sct_…`. - `name` (string, required) - `description` (string, required) - `constructor` (object, required) - `bricks` (object): Holds the properties of a brick, one key per brick type. Rules: - A text property reads a variable when it holds `{{name}}`, and a contact field when it holds `{{contact.}}`; the call puts the value in place when the brick runs. - A number, a boolean and an enum property take no variable. - `start_call`, `inbound_call`, `outbound_call`, `recording_setup`, `tree`, `start_tree`, `end_tree` and `end`: no property takes a variable. - `condition_group` and `assignment`: only `value` takes a variable. - `webhook`: only the method, the URL, the body, the names and values of the headers and of the form fields, the basic-auth username and password, the bearer token, the proxy URL, and the `path` and `set_if_not_found` of a response mapping take a variable. - A property that names a variable to write, such as `variable` of a response mapping or of `increment`, is written to and not read. - The guide with examples: https://docs.aiva.apifonica.com/guides/build/variables/ - `audio` (object) - `v1` (array of object) - `audio_file` (object) - `v1` (array of object) - `audio_tts` (object) - `v1` (array of object) - `sms` (object) - `v1` (array of object) - `goal` (object) - `v1` (array of object) - `end_call` (object) - `v1` (array of object) - `assignment` (object) - `v1` (array of object) - `increment` (object) - `v1` (array of object) - `condition_group` (object) - `v1` (array of object) - `start_tree` (object) - `v1` (array of object) - `start_call` (object) - `v1` (array of object) - `v2` (array of object) - `outbound_call` (object) - `v1` (array of object) - `inbound_call` (object) - `v1` (array of object) - `end` (object) - `v1` (array of object) - `call_transfer` (object) - `v1` (array of object) - `question` (object) - `v1` (array of object) - `webhook` (object) - `v1` (array of object) - `data_mapping` (object) - `v1` (array of object) - `tree` (object) - `v1` (array of object) - `end_tree` (object) - `v1` (array of object) - `background_audio` (object) - `v1` (array of object) - `javascript` (object) - `v1` (array of object) - `warm_up_tts` (object) - `v1` (array of object) - `business_metric` (object) - `v1` (array of object) - `ai_agent` (object) - `v1` (array of object) - `send_dtmf` (object) - `v1` (array of object) - `recording_setup` (object) - `v1` (array of object) - `transcription` (object) - `v1` (array of object) - `forest` (object) - `trees` (array of object) - `description` (string) - `tree_id` (string) - `nodes` (array of object) - `properties` (object) - `engine_version` (enum(v3)): Any value sent is stored as v3. - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) ### Upload an audio file of the tenant's scenario templates `POST /v1/t/audio` Operation id: `UploadTenantAudio` Stores a file for the bricks of the tenant's scenario templates to play. Rules: - The part's own content type is preserved, and `audio/wav` is used when it carries none. - The client filename is kept as provenance. Parameters: - `X-Tenant-Sid` (header, string): Names the target tenant. By principal: - A tenant-scoped principal may omit it. - A principal with no tenant of its own names one here. Refused when: - A tenant-scoped principal sends a value naming any other tenant. - A principal with no tenant of its own omits it. Request body: Content type `multipart/form-data`: - `file` (string (binary), required) Responses: - `201`: Created - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `413`: Request body exceeds the 32 MiB upload limit - `500`: Internal server error Response body (`201`): Content type `application/json`: - `id` (string, required) - `location` (string, required): Serves the file over the API. It never expires, and fetching it needs the same credentials and account scope as the rest of the API, which makes it the reference for API consumers and authoring preview. - `filename` (string, required): Names the stored file: aud_.wav. - `content_type` (string, required): Declares the content type the file is stored and served with. - `url` (string, required): Points at the stored object by its permanent canonical storage URI (e.g. gs:///) — the reference a scenario brick embeds, read straight from storage by the call runtime. - `provider` (string, required): Names the storage provider holding the object (e.g. gcs); discriminates the url scheme. ### Get an audio file of the tenant's scenario templates `GET /v1/t/audio/{filename}` Operation id: `GetTenantAudio` Serves a stored file of the tenant's scenario templates. By mode: - The default: the bytes stream back with the content type they were stored under. - `mode=url`: the answer is a time-bounded presigned link instead. Parameters: - `filename` (path, string, required): Stored audio basename, `aud_.wav`; anything else is not found. - `mode` (query, string): Sets how the audio is served. Values: - `url`: returns a presigned download link. - Every other value, including the default, streams the audio through athena. - `expire` (query, integer): Sets the presigned link lifetime in seconds. Rules: - It applies in url mode only. - The default is 3600 (1h). - Anything outside 1 to 604800 (7d) is refused. - `X-Tenant-Sid` (header, string): Names the target tenant. By principal: - A tenant-scoped principal may omit it. - A principal with no tenant of its own names one here. Refused when: - A tenant-scoped principal sends a value naming any other tenant. - A principal with no tenant of its own omits it. Responses: - `200`: Returns what the mode asks for. By mode: - `url`: returns a presigned link. - Any other mode: returns the raw audio bytes. - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `500`: Internal server error Response body (`200`): Content type `application/json`: - `signed_url` (string, required) - `expires_at` (string (date-time), required) ### Get a function version by slug and version `GET /v1/t/adapters/edge/functions/{slug}/{version}` Operation id: `TenantAdapterEdgeGetFunctionsSlugVersion` Parameters: - `slug` (path, string, required) - `version` (path, integer, required) - `X-Tenant-Sid` (header, string): Names the target tenant. By principal: - A tenant-scoped principal may omit it. - A principal with no tenant of its own names one here. Refused when: - A tenant-scoped principal sends a value naming any other tenant. - A principal with no tenant of its own omits it. Responses: - `200`: The version - `400`: Domain error. A failed bundle comes as `400` with `err_code: INTERNAL_SERVER_ERROR`. On a run route a bundle that could not be rebuilt is this `400` too. - `401`: Unauthorized - `403`: Forbidden - `404`: No version with these keys in the account - `422`: The body, query or path params did not pass the zod schema - `500`: Unexpected error, for example a database or a disk failure. The body has `err_code: INTERNAL_SERVER_ERROR`. - `502`: Bad gateway (upstream adapter error) Response body (`200`): Content type `application/json`: - `ok` (enum(true), required) - `edgeFunction` (object, required) - `slug` (string, required) - `version` (integer, required) - `original_code` (string, required) ### Run a function version by slug and version `POST /v1/t/adapters/edge/functions/{slug}/{version}` Operation id: `TenantAdapterEdgePostFunctionsSlugVersion` Same behaviour and response as `POST /api/functions/by-id/{id}`. Parameters: - `slug` (path, string, required) - `version` (path, integer, required) - `X-Tenant-Sid` (header, string): Names the target tenant. By principal: - A tenant-scoped principal may omit it. - A principal with no tenant of its own names one here. Refused when: - A tenant-scoped principal sends a value naming any other tenant. - A principal with no tenant of its own omits it. Request body: Content type `application/json`: - `variables` (object): Scenario variables. Read in the code with `storage.get(key)` and passed to the handler as the second argument. - `args` (object): Passed to the handler as the first argument. Iris sends `{}`. Responses: - `200`: The run finished. `ok: true` when the handler returned, `ok: false` with `error` when it threw or the sandbox stopped it. - `400`: Domain error. A failed bundle comes as `400` with `err_code: INTERNAL_SERVER_ERROR`. On a run route a bundle that could not be rebuilt is this `400` too. - `401`: Unauthorized - `403`: Forbidden - `404`: No version with these keys in the account - `422`: The body, query or path params did not pass the zod schema - `500`: Unexpected error, for example a database or a disk failure. The body has `err_code: INTERNAL_SERVER_ERROR`. - `502`: Bad gateway (upstream adapter error) Response body (`200`): Content type `application/json`: - `ok` (boolean, required) - `return` (string, required): What the handler returned. A string as is, an object or array as JSON, `null` and `undefined` as an empty string, the rest via `String()`. - `variables` (object, required): Only the keys the run wrote with `storage.set`, every value as a string (objects as JSON, `null` and `undefined` as an empty string). Iris writes them back into the scenario variables. - `stdout` (string, required): `console.log` lines, cut at 1 KiB with `... [truncated]` - `stderr` (string, required): `console.error` lines plus the thrown message, cut at 1 KiB - `error` (string): Present only when `ok` is false - `execution_time` (integer, required): Milliseconds, including the bundle download ### Delete a function version `DELETE /v1/t/adapters/edge/functions/{slug}/{version}` Operation id: `TenantAdapterEdgeDeleteFunctionsSlugVersion` Deletes the row, then removes the bundle from the bucket and the local version folder. A run after that gets `404` and cannot rebuild the bundle. If the removal fails, the call is `500` and goes to Sentry with both paths; the row is already gone. A missing local folder is fine, the cache cron may have removed it. Deleting the latest version does not make an older one latest. Parameters: - `slug` (path, string, required) - `version` (path, integer, required) - `X-Tenant-Sid` (header, string): Names the target tenant. By principal: - A tenant-scoped principal may omit it. - A principal with no tenant of its own names one here. Refused when: - A tenant-scoped principal sends a value naming any other tenant. - A principal with no tenant of its own omits it. Responses: - `200`: Deleted - `400`: Domain error. A failed bundle comes as `400` with `err_code: INTERNAL_SERVER_ERROR`. On a run route a bundle that could not be rebuilt is this `400` too. - `401`: Unauthorized - `403`: Forbidden - `404`: No version with these keys in the account - `422`: The body, query or path params did not pass the zod schema - `500`: Unexpected error, for example a database or a disk failure. The body has `err_code: INTERNAL_SERVER_ERROR`. - `502`: Bad gateway (upstream adapter error) Response body (`200`): Content type `application/json`: - `ok` (enum(true), required) - `deleted` (enum(true), required) ### List the latest version of every function `GET /v1/t/adapters/edge/functions` Operation id: `TenantAdapterEdgeGetFunctions` Only versions with `is_latest = true`, newest first by `created_at`. Parameters: - `offset` (query, integer) - `limit` (query, integer) - `X-Tenant-Sid` (header, string): Names the target tenant. By principal: - A tenant-scoped principal may omit it. - A principal with no tenant of its own names one here. Refused when: - A tenant-scoped principal sends a value naming any other tenant. - A principal with no tenant of its own omits it. Responses: - `200`: One page of functions - `400`: Domain error. A failed bundle comes as `400` with `err_code: INTERNAL_SERVER_ERROR`. On a run route a bundle that could not be rebuilt is this `400` too. - `401`: Unauthorized - `403`: Forbidden - `422`: The body, query or path params did not pass the zod schema - `500`: Unexpected error, for example a database or a disk failure. The body has `err_code: INTERNAL_SERVER_ERROR`. - `502`: Bad gateway (upstream adapter error) Response body (`200`): Content type `application/json`: - `ok` (enum(true), required) - `total` (integer, required) - `hasMore` (boolean, required) - `results` (array of object, required) - `slug` (string, required) - `version` (integer, required) - `original_code` (string, required) ### Create a function version `POST /v1/t/adapters/edge/functions` Operation id: `TenantAdapterEdgePostFunctions` Validates the code, bundles it and stores a new version of `slug`. If the latest version of `slug` has exactly the same `code`, nothing is bundled: the existing version is returned. Otherwise the version is the latest one plus 1 (the first one is 1) and it becomes the latest. Validation runs inside the request and can take seconds: forbidden lexemes, `deno check` against the runtime globals, ESLint. Bundling (`deno install` + `deno bundle`) runs inside the request too. Parameters: - `X-Tenant-Sid` (header, string): Names the target tenant. By principal: - A tenant-scoped principal may omit it. - A principal with no tenant of its own names one here. Refused when: - A tenant-scoped principal sends a value naming any other tenant. - A principal with no tenant of its own omits it. Request body: Content type `application/json`: - `slug` (string, required): Function name inside the account. Needs at least one `[A-Za-z0-9_]` character and must not be `by-id`. Other characters are not rejected. - `code` (string, required): TypeScript or JavaScript module with a default export (or a `handler` export). Rejected with `422` when it has a forbidden lexeme, fails `deno check` against the runtime globals, or fails ESLint. See FLOW.md for the lists. Responses: - `200`: Version created, or the latest one reused - `400`: Domain error. A failed bundle comes as `400` with `err_code: INTERNAL_SERVER_ERROR`. On a run route a bundle that could not be rebuilt is this `400` too. - `401`: Unauthorized - `403`: Forbidden - `422`: The body, query or path params did not pass the zod schema - `500`: Unexpected error, for example a database or a disk failure. The body has `err_code: INTERNAL_SERVER_ERROR`. - `502`: Bad gateway (upstream adapter error) Response body (`200`): Content type `application/json`: - `ok` (enum(true), required) - `id` (string (uuid), required) - `version` (integer, required) - `storage_reads` (array of string, required): Keys found in the code as string literals of `storage.get` / `storage.unpack` (reads) or `storage.set` (writes). Keys built at runtime are not found. - `storage_writes` (array of string, required): Keys found in the code as string literals of `storage.get` / `storage.unpack` (reads) or `storage.set` (writes). Keys built at runtime are not found. ### Get a function version by id `GET /v1/t/adapters/edge/functions/by-id/{id}` Operation id: `TenantAdapterEdgeGetFunctionsByIdId` Parameters: - `id` (path, string (uuid), required): Version id, a UUID - `X-Tenant-Sid` (header, string): Names the target tenant. By principal: - A tenant-scoped principal may omit it. - A principal with no tenant of its own names one here. Refused when: - A tenant-scoped principal sends a value naming any other tenant. - A principal with no tenant of its own omits it. Responses: - `200`: The version - `400`: Domain error. A failed bundle comes as `400` with `err_code: INTERNAL_SERVER_ERROR`. On a run route a bundle that could not be rebuilt is this `400` too. - `401`: Unauthorized - `403`: Forbidden - `404`: No version with these keys in the account - `422`: The body, query or path params did not pass the zod schema - `500`: Unexpected error, for example a database or a disk failure. The body has `err_code: INTERNAL_SERVER_ERROR`. - `502`: Bad gateway (upstream adapter error) Response body (`200`): Content type `application/json`: - `ok` (enum(true), required) - `edgeFunction` (object, required) - `slug` (string, required) - `version` (integer, required) - `original_code` (string, required) ### Run a function version by id `POST /v1/t/adapters/edge/functions/by-id/{id}` Operation id: `TenantAdapterEdgePostFunctionsByIdId` The route the Iris backend uses to run a brick. A failed run (the code throws, timeout, memory limit) is still `200` with `ok: false` and `error`. Only a missing version and a broken request get another status. Parameters: - `id` (path, string (uuid), required): Version id, a UUID - `X-Tenant-Sid` (header, string): Names the target tenant. By principal: - A tenant-scoped principal may omit it. - A principal with no tenant of its own names one here. Refused when: - A tenant-scoped principal sends a value naming any other tenant. - A principal with no tenant of its own omits it. Request body: Content type `application/json`: - `variables` (object): Scenario variables. Read in the code with `storage.get(key)` and passed to the handler as the second argument. - `args` (object): Passed to the handler as the first argument. Iris sends `{}`. Responses: - `200`: The run finished. `ok: true` when the handler returned, `ok: false` with `error` when it threw or the sandbox stopped it. - `400`: Domain error. A failed bundle comes as `400` with `err_code: INTERNAL_SERVER_ERROR`. On a run route a bundle that could not be rebuilt is this `400` too. - `401`: Unauthorized - `403`: Forbidden - `404`: No version with these keys in the account - `422`: The body, query or path params did not pass the zod schema - `500`: Unexpected error, for example a database or a disk failure. The body has `err_code: INTERNAL_SERVER_ERROR`. - `502`: Bad gateway (upstream adapter error) Response body (`200`): Content type `application/json`: - `ok` (boolean, required) - `return` (string, required): What the handler returned. A string as is, an object or array as JSON, `null` and `undefined` as an empty string, the rest via `String()`. - `variables` (object, required): Only the keys the run wrote with `storage.set`, every value as a string (objects as JSON, `null` and `undefined` as an empty string). Iris writes them back into the scenario variables. - `stdout` (string, required): `console.log` lines, cut at 1 KiB with `... [truncated]` - `stderr` (string, required): `console.error` lines plus the thrown message, cut at 1 KiB - `error` (string): Present only when `ok` is false - `execution_time` (integer, required): Milliseconds, including the bundle download ### List every version of a function `GET /v1/t/adapters/edge/functions/{slug}/versions` Operation id: `TenantAdapterEdgeGetFunctionsSlugVersions` Newest version first. An unknown slug gives an empty list, not 404. Parameters: - `slug` (path, string, required) - `X-Tenant-Sid` (header, string): Names the target tenant. By principal: - A tenant-scoped principal may omit it. - A principal with no tenant of its own names one here. Refused when: - A tenant-scoped principal sends a value naming any other tenant. - A principal with no tenant of its own omits it. Responses: - `200`: All versions of the slug - `400`: Domain error. A failed bundle comes as `400` with `err_code: INTERNAL_SERVER_ERROR`. On a run route a bundle that could not be rebuilt is this `400` too. - `401`: Unauthorized - `403`: Forbidden - `422`: The body, query or path params did not pass the zod schema - `500`: Unexpected error, for example a database or a disk failure. The body has `err_code: INTERNAL_SERVER_ERROR`. - `502`: Bad gateway (upstream adapter error) Response body (`200`): Content type `application/json`: - `ok` (enum(true), required) - `versions` (array of object, required) - `id` (string (uuid), required) - `version` (integer, required) - `status` (enum(deployed, error, pending, expired, cleaning, archived), required): See the status lifecycle in FLOW.md - `created_at` (string (date-time), required) - `updated_at` (string (date-time), required) - `original_code` (string, required) - `is_latest` (boolean, required) - `storage_reads` (array of string, required): Keys found in the code as string literals of `storage.get` / `storage.unpack` (reads) or `storage.set` (writes). Keys built at runtime are not found. - `storage_writes` (array of string, required): Keys found in the code as string literals of `storage.get` / `storage.unpack` (reads) or `storage.set` (writes). Keys built at runtime are not found. ### Put the bundle of a version into the local cache `POST /v1/t/adapters/edge/functions/{slug}/{version}/warmup` Operation id: `TenantAdapterEdgePostFunctionsSlugVersionWarmup` Makes the next run skip the bundle download. Does nothing when the bundle is already on the local disk. Otherwise downloads it from the bucket or rebuilds it from `original_code`. Parameters: - `slug` (path, string, required) - `version` (path, integer, required) - `X-Tenant-Sid` (header, string): Names the target tenant. By principal: - A tenant-scoped principal may omit it. - A principal with no tenant of its own names one here. Refused when: - A tenant-scoped principal sends a value naming any other tenant. - A principal with no tenant of its own omits it. Responses: - `200`: The bundle is on the local disk - `400`: Domain error. A failed bundle comes as `400` with `err_code: INTERNAL_SERVER_ERROR`. On a run route a bundle that could not be rebuilt is this `400` too. - `401`: Unauthorized - `403`: Forbidden - `404`: No version with these keys in the account - `422`: The body, query or path params did not pass the zod schema - `500`: Unexpected error, for example a database or a disk failure. The body has `err_code: INTERNAL_SERVER_ERROR`. - `502`: Bad gateway (upstream adapter error) Response body (`200`): Content type `application/json`: - `ok` (enum(true), required) - `warmed_up` (enum(true), required) - `version` (integer, required) ### Save classifier content `PUT /v1/t/adapters/ids/classifier/{id}` Operation id: `TenantAdapterIdsPutClassifierId` Records the supplied training-relevant content as the next version of the classifier and queues training for it (`201`). Content identical to a version the classifier already holds resolves to that version instead and trains nothing (`200`), which is what keeps a publish from triggering a mass retrain. Recorded versions are immutable, so this never alters an existing one. Queueing is never refused, however much an account already has waiting: training capacity is shared out when a run starts, not here. Parameters: - `id` (path, string (uuid), required): Classifier id (UUID). - `X-Tenant-Sid` (header, string): Names the target tenant. By principal: - A tenant-scoped principal may omit it. - A principal with no tenant of its own names one here. Refused when: - A tenant-scoped principal sends a value naming any other tenant. - A principal with no tenant of its own omits it. Request body: Content type `application/json`: - `model_id` (string (uuid), required) - `description` (string) - `intent` (object, required) - `intents` (array of object, required) - `id` (string, required) - `description` (string) - `phrase` (object, required) - `phrases` (array of string, required) Responses: - `200`: Content resolved to a version the classifier already holds - `201`: Version recorded and queued for training - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `409`: Concurrent writers kept taking the version this save was going to record. The save is safe to repeat. - `500`: Internal server error - `502`: Bad gateway (upstream adapter error) Response body (`200`): Content type `application/json`: - `id` (string, required) - `version` (integer, required): Version number. `0` is an ordinary version like any other — the first one a classifier gets, and the one existing scenario bricks name. - `account_sid` (string, required) - `model_id` (string, required) - `description` (string, required) - `intent` (object, required) - `intents` (array of object, required) - `id` (string, required) - `description` (string) - `phrase` (object, required) - `phrases` (array of string, required) - `content_hash` (string, required): Identity of this version's training-relevant content. Two versions of one classifier can never carry the same value; it is what lets identical content resolve to an existing version instead of training again. - `state` (enum(new, training, fail, success, unknown), required) - `training` (object): Why the last training run of this version ended as it did. Present on a single-version read; absent from list entries. - `error` (string): Why the last training run failed. Absent unless it failed. - `created_at` (string (date-time)): When the training run was queued. Absent if none was ever queued. - `updated_at` (string (date-time)): When the training run last changed state. Absent if none was ever queued. ### Delete a classifier `DELETE /v1/t/adapters/ids/classifier/{id}` Operation id: `TenantAdapterIdsDeleteClassifierId` Soft-deletes the classifier and every version of it: the records stay in the database but disappear from reads, are never trained again, and never satisfy content dedupe. Version history is kept so past calls remain explainable. Physical removal happens only when the owning account is purged. Parameters: - `id` (path, string (uuid), required): Classifier id (UUID). - `X-Tenant-Sid` (header, string): Names the target tenant. By principal: - A tenant-scoped principal may omit it. - A principal with no tenant of its own names one here. Refused when: - A tenant-scoped principal sends a value naming any other tenant. - A principal with no tenant of its own omits it. Responses: - `204`: Deleted - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `500`: Internal server error - `502`: Bad gateway (upstream adapter error) ### List an account's classifier versions `GET /v1/t/adapters/ids/classifier` Operation id: `TenantAdapterIdsGetClassifier` Every live version the account owns, each as its own entry: a version is the addressable thing, so several entries can share a classifier id and differ only by version. Parameters: - `X-Tenant-Sid` (header, string): Names the target tenant. By principal: - A tenant-scoped principal may omit it. - A principal with no tenant of its own names one here. Refused when: - A tenant-scoped principal sends a value naming any other tenant. - A principal with no tenant of its own omits it. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `500`: Internal server error - `502`: Bad gateway (upstream adapter error) Response body (`200`): Content type `application/json`: - `id` (string, required) - `version` (integer, required): Version number. `0` is an ordinary version like any other — the first one a classifier gets, and the one existing scenario bricks name. - `account_sid` (string, required) - `model_id` (string, required) - `description` (string, required) - `intent` (object, required) - `intents` (array of object, required) - `id` (string, required) - `description` (string) - `phrase` (object, required) - `phrases` (array of string, required) - `content_hash` (string, required): Identity of this version's training-relevant content. Two versions of one classifier can never carry the same value; it is what lets identical content resolve to an existing version instead of training again. - `state` (enum(new, training, fail, success, unknown), required) - `training` (object): Why the last training run of this version ended as it did. Present on a single-version read; absent from list entries. - `error` (string): Why the last training run failed. Absent unless it failed. - `created_at` (string (date-time)): When the training run was queued. Absent if none was ever queued. - `updated_at` (string (date-time)): When the training run last changed state. Absent if none was ever queued. ### Create a classifier `POST /v1/t/adapters/ids/classifier` Operation id: `TenantAdapterIdsPostClassifier` Records a new classifier at its first version (`0`) owned by the account, and queues its training. Later content changes are saved with `PUT /v1/classifier/{id}/account/{account_sid}`, which records the next version rather than altering this one. Parameters: - `X-Tenant-Sid` (header, string): Names the target tenant. By principal: - A tenant-scoped principal may omit it. - A principal with no tenant of its own names one here. Refused when: - A tenant-scoped principal sends a value naming any other tenant. - A principal with no tenant of its own omits it. Request body: Content type `application/json`: - `model_id` (string (uuid), required) - `description` (string) - `intent` (object, required) - `intents` (array of object, required) - `id` (string, required) - `description` (string) - `phrase` (object, required) - `phrases` (array of string, required) Responses: - `201`: Created - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `500`: Internal server error - `502`: Bad gateway (upstream adapter error) Response body (`201`): Content type `application/json`: - `id` (string, required) - `version` (integer, required): Version number. `0` is an ordinary version like any other — the first one a classifier gets, and the one existing scenario bricks name. - `account_sid` (string, required) - `model_id` (string, required) - `description` (string, required) - `intent` (object, required) - `intents` (array of object, required) - `id` (string, required) - `description` (string) - `phrase` (object, required) - `phrases` (array of string, required) - `content_hash` (string, required): Identity of this version's training-relevant content. Two versions of one classifier can never carry the same value; it is what lets identical content resolve to an existing version instead of training again. - `state` (enum(new, training, fail, success, unknown), required) - `training` (object): Why the last training run of this version ended as it did. Present on a single-version read; absent from list entries. - `error` (string): Why the last training run failed. Absent unless it failed. - `created_at` (string (date-time)): When the training run was queued. Absent if none was ever queued. - `updated_at` (string (date-time)): When the training run last changed state. Absent if none was ever queued. ### Get one version `GET /v1/t/adapters/ids/classifier/{id}/version/{version}` Operation id: `TenantAdapterIdsGetClassifierIdVersionVersion` Returns the recorded content of one version together with its training state — including why the last training run failed, and when it was queued and last changed. A version's content never changes once recorded, so a consumer that pinned this version always resolves exactly what it pinned. Parameters: - `id` (path, string (uuid), required): Classifier id (UUID). - `version` (path, integer, required): Classifier version. Version 0 is the one every classifier created before versioning occupies. - `X-Tenant-Sid` (header, string): Names the target tenant. By principal: - A tenant-scoped principal may omit it. - A principal with no tenant of its own names one here. Refused when: - A tenant-scoped principal sends a value naming any other tenant. - A principal with no tenant of its own omits it. Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `500`: Internal server error - `502`: Bad gateway (upstream adapter error) Response body (`200`): Content type `application/json`: - `id` (string, required) - `version` (integer, required): Version number. `0` is an ordinary version like any other — the first one a classifier gets, and the one existing scenario bricks name. - `account_sid` (string, required) - `model_id` (string, required) - `description` (string, required) - `intent` (object, required) - `intents` (array of object, required) - `id` (string, required) - `description` (string) - `phrase` (object, required) - `phrases` (array of string, required) - `content_hash` (string, required): Identity of this version's training-relevant content. Two versions of one classifier can never carry the same value; it is what lets identical content resolve to an existing version instead of training again. - `state` (enum(new, training, fail, success, unknown), required) - `training` (object): Why the last training run of this version ended as it did. Present on a single-version read; absent from list entries. - `error` (string): Why the last training run failed. Absent unless it failed. - `created_at` (string (date-time)): When the training run was queued. Absent if none was ever queued. - `updated_at` (string (date-time)): When the training run last changed state. Absent if none was ever queued. ### Classify a phrase against one version `POST /v1/t/adapters/ids/classifier/{id}/version/{version}/classify` Operation id: `TenantAdapterIdsPostClassifierIdVersionVersionClassify` Classifies a phrase using the trained artefact of the addressed version, so a caller that pinned a version keeps getting that version's behavior while another version is being trained. Classification is bound to a short deadline; exceeding it yields 504, a client cancellation 499. Parameters: - `id` (path, string (uuid), required): Classifier id (UUID). - `version` (path, integer, required): Classifier version. Version 0 is the one every classifier created before versioning occupies. - `X-Tenant-Sid` (header, string): Names the target tenant. By principal: - A tenant-scoped principal may omit it. - A principal with no tenant of its own names one here. Refused when: - A tenant-scoped principal sends a value naming any other tenant. - A principal with no tenant of its own omits it. Request body: Content type `application/json`: - `phrase` (string, required) Responses: - `200`: OK - `400`: Bad request - `401`: Unauthorized - `403`: Forbidden - `404`: Not found - `500`: Internal server error - `502`: Bad gateway (upstream adapter error) - `504`: Classification deadline exceeded Response body (`200`): Content type `application/json`: - `intents` (object, required) ### Download a RAG document file `GET /v1/t/adapters/llm/rag/document/{id}` Operation id: `TenantAdapterLlmGetRagDocumentId` Parameters: - `id` (path, string, required): RAG document id. - `X-Tenant-Sid` (header, string): Names the target tenant. By principal: - A tenant-scoped principal may omit it. - A principal with no tenant of its own names one here. Refused when: - A tenant-scoped principal sends a value naming any other tenant. - A principal with no tenant of its own omits it. Responses: - `200`: Document file stream - `400`: Invalid request body or parameters - `401`: Unauthorized - `403`: Forbidden - `404`: Resource does not exist - `500`: Internal server error - `502`: Bad gateway (upstream adapter error) Response body (`200`): Content type `application/octet-stream`: ### Upload a RAG document for an account `PUT /v1/t/adapters/llm/rag/document/{id}` Operation id: `TenantAdapterLlmPutRagDocumentId` Accepts either a JSON text body or a multipart file upload, selected by Content-Type. Parameters: - `id` (path, string, required): RAG document id. - `mode` (query, string): Document split mode. - `index_type` (query, enum(vector, fulltext)) - `chunk_size` (query, integer) - `X-Tenant-Sid` (header, string): Names the target tenant. By principal: - A tenant-scoped principal may omit it. - A principal with no tenant of its own names one here. Refused when: - A tenant-scoped principal sends a value naming any other tenant. - A principal with no tenant of its own omits it. Request body: Content type `application/json`: - `content` (string, required) - `type` (enum(txt, csv), required) Content type `multipart/form-data`: - `document` (string (binary), required) Responses: - `202`: Accepted - `400`: Invalid request body or parameters - `401`: Unauthorized - `403`: Forbidden - `409`: Resource busy - `502`: Bad gateway (upstream adapter error) Response body (`202`): Content type `application/json`: - `message` (string) ### Delete a RAG document for an account `DELETE /v1/t/adapters/llm/rag/document/{id}` Operation id: `TenantAdapterLlmDeleteRagDocumentId` Parameters: - `id` (path, string, required): RAG document id. - `X-Tenant-Sid` (header, string): Names the target tenant. By principal: - A tenant-scoped principal may omit it. - A principal with no tenant of its own names one here. Refused when: - A tenant-scoped principal sends a value naming any other tenant. - A principal with no tenant of its own omits it. Responses: - `204`: Deleted - `400`: Invalid request body or parameters - `401`: Unauthorized - `403`: Forbidden - `502`: Bad gateway (upstream adapter error) Response body (`204`): Content type `application/json`: - `message` (string) ### List RAG documents for an account `GET /v1/t/adapters/llm/rag/document/list` Operation id: `TenantAdapterLlmGetRagDocumentList` Returns one page of the account's documents, newest first. Parameters: - `limit` (query, integer): Page size. A value above 500 is reduced to 500. - `offset` (query, integer): Number of documents to skip. A negative value is read as 0. - `X-Tenant-Sid` (header, string): Names the target tenant. By principal: - A tenant-scoped principal may omit it. - A principal with no tenant of its own names one here. Refused when: - A tenant-scoped principal sends a value naming any other tenant. - A principal with no tenant of its own omits it. Responses: - `200`: OK - `400`: Invalid request body or parameters - `401`: Unauthorized - `403`: Forbidden - `500`: Internal server error - `502`: Bad gateway (upstream adapter error) Response body (`200`): Content type `application/json`: - `documents` (array of object, required) - `id` (string (uuid), required) - `name` (string, required) - `size` (integer (int64), required): Size of the uploaded file in bytes. - `status` (enum(pending, processed, error), required) - `error` (string): The reason of the failure. Present only when status is error. - `content_type` (string, required) - `mode` (enum(chunk, lines), required) - `index_type` (enum(fulltext, vector), required) - `chunk_size` (integer, required) - `embedding_model` (string) - `embedding_provider` (string) - `uploaded_at` (string (date-time), required) - `total` (integer (int64), required): Number of the account's documents. - `limit` (integer, required): The page size applied. - `offset` (integer, required): The offset applied. - `has_more` (boolean, required): True when more documents follow this page. ### Semantic search over an account's RAG documents `GET /v1/t/adapters/llm/rag/document/search` Operation id: `TenantAdapterLlmGetRagDocumentSearch` Parameters: - `query` (query, string, required) - `document_id` (query, array of string) - `top_k` (query, integer) - `threshold` (query, number (float)) - `X-Tenant-Sid` (header, string): Names the target tenant. By principal: - A tenant-scoped principal may omit it. - A principal with no tenant of its own names one here. Refused when: - A tenant-scoped principal sends a value naming any other tenant. - A principal with no tenant of its own omits it. Responses: - `200`: OK - `400`: Invalid request body or parameters - `401`: Unauthorized - `403`: Forbidden - `500`: Internal server error - `502`: Bad gateway (upstream adapter error) Response body (`200`): Content type `application/json`: - `chunks` (array of object) ### Tenant API document `GET /v1/t/openapi.yaml` Operation id: `GetTenantOpenAPIDocument` The OpenAPI 3.0 document of the Tenant API, byte-identical to the committed bundle this deployment was built from. Served without a credential; generate clients from it. Responses: - `200`: The Tenant API document, as `application/yaml`. - `500`: Internal server error Response body (`200`): Content type `application/yaml`: ### Changelog `GET /v1/changelog.md` Operation id: `GetChangelog` The release notes of the Account API and the Tenant API up to the version this deployment was built from, newest version first, as one Markdown document. Each version lists its changes under Added, Changed, Deprecated, Removed and Fixed. Served without a credential. Responses: - `200`: The changelog, as `text/markdown`. - `500`: Internal server error Response body (`200`): Content type `text/markdown`: