Skip to main content
A trunk is the SIP connection that carries calls between Anyreach and a carrier. Most organizations use Anyreach-managed trunks and never touch this configuration. This page covers two advanced, API-only workflows: bringing your own carrier (BYOC) with a customer-owned trunk, and deploying an agent as a dialable SIP endpoint.
These features are advanced and have no dashboard UI. Configure them through the API at https://api.anyreach.ai. Managed trunks are provisioned for you and cannot be edited or deleted through the API.

Managed vs customer-owned trunks

Every trunk belongs to one organization. A trunk with a managed_account_id is provisioned and operated by Anyreach (for example a managed Twilio account) and is read-only over the API. A trunk with no managed_account_id is customer-owned: you control its inbound and outbound configuration. This is the BYOC path.
Managed trunkCustomer-owned (BYOC) trunk
managed_account_idsetnull
Editable via APINo (PUT and DELETE return 400)Yes
Inbound/outbound configManaged by AnyreachYou set it
When to use BYOC: choose a customer-owned trunk when you must route calls through your own carrier or PBX rather than an Anyreach-managed account. Otherwise use a managed trunk.

Trunk CRUD

All trunk endpoints live under /core/trunks and require the trunks:read or trunks:manage scope. Reads accept either scope; writes require trunks:manage.
MethodPathScopeNotes
GET/core/trunkstrunks:read or trunks:manageList trunks. Supports name, created_after, created_before, updated_after, updated_before, limit, cursor.
GET/core/trunks/{id}trunks:read or trunks:manageGet one trunk. 404 if not found.
POST/core/trunkstrunks:manageCreate a customer-owned trunk.
PUT/core/trunks/{id}trunks:manageUpdate name and config. 400 if the trunk is managed.
DELETE/core/trunks/{id}trunks:manageDelete the trunk. 400 if the trunk is managed. Returns 204.
The create body takes a name and optional inbound_config and outbound_config. The organization is taken from your token, so you do not send organization_id.
curl -X POST https://api.anyreach.ai/core/trunks \
  -H "Authorization: Bearer <token>" \
  -H "X-Anyreach-Org: <organization_id>" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "My carrier trunk",
    "inbound_config": {
      "enable_noise_cancellation": false,
      "media_encryption": "SIP_MEDIA_ENCRYPT_DISABLE",
      "allowed_addresses": ["203.0.113.10"]
    },
    "outbound_config": {
      "address": "sip.mycarrier.example.com",
      "auth_username": "anyreach",
      "auth_password": "<secret>",
      "transport": "SIP_TRANSPORT_UDP",
      "media_encryption": "SIP_MEDIA_ENCRYPT_DISABLE"
    }
  }'
The X-Anyreach-Org header is required only for user personal access tokens (pat_). Organization API keys (ak_) carry their organization implicitly.

Inbound config

inbound_config governs calls arriving from your carrier.
FieldTypeDefaultDescription
enable_noise_cancellationbooleanfalseApply noise cancellation to inbound audio.
media_encryptionenumSIP_MEDIA_ENCRYPT_DISABLEMedia encryption policy. See below.
allowed_addressesarray of stringsnullSource addresses permitted to send calls. Empty strings are stripped; an empty list becomes null (no restriction).

Outbound config

outbound_config defines how Anyreach connects to your carrier to place calls. address, auth_username, and auth_password are required when you supply an outbound config.
FieldTypeDefaultDescription
addressstringCarrier SIP host or domain. Required, non-empty.
auth_usernamestringSIP auth username. Required, non-empty.
auth_passwordstringSIP auth password. Required, non-empty.
transportenumSIP_TRANSPORT_UDPTransport protocol. See below.
media_encryptionenumSIP_MEDIA_ENCRYPT_DISABLEMedia encryption policy. See below.

Enum values

EnumAllowed values
media_encryptionSIP_MEDIA_ENCRYPT_DISABLE (none), SIP_MEDIA_ENCRYPT_ALLOW, SIP_MEDIA_ENCRYPT_REQUIRE
transportSIP_TRANSPORT_UDP, SIP_TRANSPORT_TCP, SIP_TRANSPORT_TLS

Deploy an agent as a SIP endpoint

Instead of (or in addition to) attaching a phone number, you can expose a published agent as a dialable SIP URI. The agent then answers calls placed directly to its SIP address. The URI has the form:
sip:<agent-uuid>@<host>
1

Publish the agent

The agent must have at least one published version. Deploying an agent with no published version returns 409.
2

Deploy as SIP

Call POST /core/agents/{id}/deploy-as-sip with the agents:manage scope. The response returns the SIP URI and deployed: true. The operation is idempotent.
curl -X POST https://api.anyreach.ai/core/agents/<agent-id>/deploy-as-sip \
  -H "Authorization: Bearer <token>" \
  -H "X-Anyreach-Org: <organization_id>"
{
  "uri": "sip:<agent-id>@<host>",
  "deployed": true
}
3

Dial the endpoint

Route calls to the returned uri from your SIP infrastructure to reach the agent.
4

Undeploy when done

Call DELETE /core/agents/{id}/deploy-as-sip (scope agents:manage) to remove the endpoint. Returns 204 and is idempotent.

SIP endpoint state on the agent

The agent GET response includes a sip_endpoint object reflecting current state, or null when state cannot be resolved.
FieldTypeDescription
uristringThe agent’s SIP URI.
deployedbooleanWhether the agent is currently reachable at that URI.

Errors

StatusCause
404Agent not found.
409Deploy attempted before the agent has a published version.

Telephony overview

How phone numbers, trunks, and agents fit together.

Telephony API reference

Full endpoint reference for telephony resources.