On this page
Connect a SIP trunk
Connect your carrier’s SIP trunk using a versioned credential secret. Enable inbound routing if the trunk will receive calls.
Operation ID: trunks.create.
Request
POST /api/v1/telephony/trunks
- TypeScript SDK:
client.trunks.create(path arguments usepath). - MCP tool:
sdk_client_callwithoperationId: "trunks.create"(path arguments useinput.path). Legacy alias:trunks_create. Connect to your authenticated/mcpendpoint with an API key for the same environment. - Minimum API key role: admin.
- Idempotency: Required. Send
Idempotency-Key(TypeScript SDK:idempotencyKey) and keep it for retries.
Read resource IDs from earlier responses and use a key for the same environment.
Request example
Use the termination hostname and username supplied by your carrier, without a sip: prefix. First save its password with secrets.put kind sip_auth and copy the returned ID/current_version. These synthetic carrier values do not establish a working trunk.
Set CUMULUS_BASE_URL to your workspace API URL and CUMULUS_API_KEY to a key for that environment. Set IDEMPOTENCY_KEY to a new UUID for this action and keep it for retries. Example values are synthetic.
cURL
curl --fail-with-body -sS -X POST "${CUMULUS_BASE_URL%/}/api/v1/telephony/trunks" \
-H "Authorization: Bearer $CUMULUS_API_KEY" \
-H "Idempotency-Key: $IDEMPOTENCY_KEY" \
-H "Content-Type: application/json" \
--data '{
"trunk_id": "service-desk",
"name": "Service desk carrier",
"provider": "generic_sip",
"termination_uri": "sip.example.com",
"auth_username": "service-desk",
"auth_secret": {
"id": "77777777-7777-4777-8777-777777777777",
"version": "88888888-8888-4888-8888-888888888888"
},
"inbound": false
}'
TypeScript
import { Cumulus } from "@cumulus/sdk";
const baseUrl = process.env.CUMULUS_BASE_URL;
const apiKey = process.env.CUMULUS_API_KEY;
if (!baseUrl || !apiKey) throw new Error("Set CUMULUS_BASE_URL and CUMULUS_API_KEY");
const client = new Cumulus({ baseUrl, apiKey });
const idempotencyKey = process.env.IDEMPOTENCY_KEY;
if (!idempotencyKey) throw new Error("Set IDEMPOTENCY_KEY for this request");
const response = await client.trunks.create({
"body": {
"trunk_id": "service-desk",
"name": "Service desk carrier",
"provider": "generic_sip",
"termination_uri": "sip.example.com",
"auth_username": "service-desk",
"auth_secret": {
"id": "77777777-7777-4777-8777-777777777777",
"version": "88888888-8888-4888-8888-888888888888"
},
"inbound": false
},
idempotencyKey,
});
Integration notes
Use an admin key and configure call capacity with Cumulus first. tenant_not_configured means that setup is missing.
- Store the SIP password with
secrets_put, usingkind: "sip_auth". - Pass
auth_secret: {id, version: current_version}to connect the trunk. - For Twilio, set
termination_urito the Termination host (<name>.pstn.twilio.com) and enable Secure Trunking. Calls use TLS and SRTP. - For incoming calls, set
inbound: trueand configure the returnedinbound_sip_urias Twilio’s Origination URI with secure trunking enabled. - Import the numbers and assign a published phone agent.
Input schema
Path, query and header parameters
Idempotency-Key
header parameter · Required.
Type: string. minLength: 1. maxLength: 256.
JSON request body
| Field | Type or values | Required | Description and limits |
|---|---|---|---|
trunk_id | string | Required | minLength: 1. maxLength: 128. pattern: ^[a-z0-9][a-z0-9_-]*$. |
name | string | Required | minLength: 1. maxLength: 256. |
provider | "twilio_elastic_sip" · "generic_sip" | Required | — |
termination_uri | string | Required | minLength: 1. maxLength: 253. pattern: ^a-z0-9?$. |
auth_username | string | Required | minLength: 1. maxLength: 256. |
auth_secret | object | Required | — |
auth_secret.id | string | Required | minLength: 1. maxLength: 128. |
auth_secret.version | string | Required | minLength: 1. maxLength: 128. |
inbound | boolean | Optional | Default: false. |
transfer_caller_id | "from-transferee" · "from-transferor" | Optional | Declared Twilio trunk transfer caller ID. Configure the same mode in Twilio before saving; this API does not update Twilio. Transfer nodes must agree. Change only after draining voice calls. |
Complete OpenAPI schema
{
"parameters": [
{
"name": "Idempotency-Key",
"in": "header",
"required": true,
"schema": {
"type": "string",
"minLength": 1,
"maxLength": 256
}
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/TrunksCreateRequest"
}
}
}
}
}
Responses
HTTP 201
Connect a BYOC SIP trunk
application/json
| Field | Type or values | Required | Description and limits |
|---|---|---|---|
trunk_id | string | Required | minLength: 1. maxLength: 128. pattern: ^[a-z0-9][a-z0-9_-]*$. |
name | string | Required | minLength: 1. maxLength: 256. |
provider | "twilio_elastic_sip" · "generic_sip" | Required | — |
termination_uri | string | Required | minLength: 1. maxLength: 253. pattern: ^a-z0-9?$. |
auth_username | string or null | Required | minLength: 1. maxLength: 256. |
auth_secret | object or null | Required | — |
auth_secret.id | string | Required in a non-null parent | minLength: 1. maxLength: 128. |
auth_secret.version | string | Required in a non-null parent | minLength: 1. maxLength: 128. |
inbound | boolean | Required | — |
transfer_caller_id | "from-transferee" · "from-transferor" | Optional | Declared Twilio trunk transfer caller ID. Configure the same mode in Twilio before saving; this API does not update Twilio. Transfer nodes must agree. Change only after draining voice calls. |
inbound_sip_uri | string or null | Optional | maxLength: 1024. |
created_at | string (date-time) | Required | pattern: ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:.\d+)?(?:Z))$. |
updated_at | string (date-time) | Required | pattern: ^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:.\d+)?(?:Z))$. |
Error responses
| HTTP | Description |
|---|---|
| 4XX | Typed error (ApiError) |
| 5XX | Typed error (ApiError) |
Errors use the shared error envelope. Inspect error.code, retryable, outcome and details before retrying.
Complete OpenAPI schema
{
"201": {
"description": "Connect a BYOC SIP trunk",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ByocTrunk"
}
}
}
},
"4XX": {
"description": "Typed error (ApiError)",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ApiError"
}
}
}
},
"5XX": {
"description": "Typed error (ApiError)",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ApiError"
}
}
}
}
}
Referenced schemas
Expand the complete OpenAPI definitions for integrations that generate their own clients.
Complete OpenAPI schema
{
"components": {
"schemas": {
"TrunksCreateRequest": {
"type": "object",
"properties": {
"trunk_id": {
"type": "string",
"minLength": 1,
"maxLength": 128,
"pattern": "^[a-z0-9][a-z0-9_-]*$"
},
"name": {
"type": "string",
"minLength": 1,
"maxLength": 256
},
"provider": {
"type": "string",
"enum": [
"twilio_elastic_sip",
"generic_sip"
]
},
"termination_uri": {
"type": "string",
"minLength": 1,
"maxLength": 253,
"pattern": "^[a-z0-9](?:[a-z0-9.-]{0,251}[a-z0-9])?$"
},
"auth_username": {
"type": "string",
"minLength": 1,
"maxLength": 256
},
"auth_secret": {
"type": "object",
"properties": {
"id": {
"type": "string",
"minLength": 1,
"maxLength": 128
},
"version": {
"type": "string",
"minLength": 1,
"maxLength": 128
}
},
"required": [
"id",
"version"
],
"additionalProperties": false
},
"inbound": {
"default": false,
"type": "boolean"
},
"transfer_caller_id": {
"type": "string",
"enum": [
"from-transferee",
"from-transferor"
],
"description": "Declared Twilio trunk transfer caller ID. Configure the same mode in Twilio before saving; this API does not update Twilio. Transfer nodes must agree. Change only after draining voice calls."
}
},
"required": [
"trunk_id",
"name",
"provider",
"termination_uri",
"auth_username",
"auth_secret"
],
"additionalProperties": false
},
"ByocTrunk": {
"type": "object",
"properties": {
"trunk_id": {
"type": "string",
"minLength": 1,
"maxLength": 128,
"pattern": "^[a-z0-9][a-z0-9_-]*$"
},
"name": {
"type": "string",
"minLength": 1,
"maxLength": 256
},
"provider": {
"type": "string",
"enum": [
"twilio_elastic_sip",
"generic_sip"
]
},
"termination_uri": {
"type": "string",
"minLength": 1,
"maxLength": 253,
"pattern": "^[a-z0-9](?:[a-z0-9.-]{0,251}[a-z0-9])?$"
},
"auth_username": {
"nullable": true,
"type": "string",
"minLength": 1,
"maxLength": 256
},
"auth_secret": {
"nullable": true,
"type": "object",
"properties": {
"id": {
"type": "string",
"minLength": 1,
"maxLength": 128
},
"version": {
"type": "string",
"minLength": 1,
"maxLength": 128
}
},
"required": [
"id",
"version"
],
"additionalProperties": false
},
"inbound": {
"type": "boolean"
},
"transfer_caller_id": {
"type": "string",
"enum": [
"from-transferee",
"from-transferor"
],
"description": "Declared Twilio trunk transfer caller ID. Configure the same mode in Twilio before saving; this API does not update Twilio. Transfer nodes must agree. Change only after draining voice calls."
},
"inbound_sip_uri": {
"nullable": true,
"type": "string",
"maxLength": 1024
},
"created_at": {
"type": "string",
"format": "date-time",
"pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
},
"updated_at": {
"type": "string",
"format": "date-time",
"pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
}
},
"required": [
"trunk_id",
"name",
"provider",
"termination_uri",
"auth_username",
"auth_secret",
"inbound",
"created_at",
"updated_at"
],
"additionalProperties": false
},
"ApiError": {
"type": "object",
"properties": {
"error": {
"type": "object",
"properties": {
"code": {
"type": "string",
"enum": [
"unauthenticated",
"forbidden",
"not_found",
"conflict",
"invalid_request",
"idempotency_conflict",
"policy_denied",
"capability_unavailable",
"provider_unavailable",
"knowledge_unavailable",
"publication_invalid",
"run_not_active",
"rate_limited",
"outcome_unknown",
"internal"
]
},
"message": {
"type": "string"
},
"retryable": {
"type": "boolean"
},
"outcome": {
"type": "string",
"enum": [
"none",
"unknown"
]
},
"details": {
"type": "object",
"additionalProperties": {}
}
},
"required": [
"code",
"message",
"retryable",
"outcome"
],
"additionalProperties": false
}
},
"required": [
"error"
],
"additionalProperties": false
}
}
}
}
Errors and recovery
See API error handling and Troubleshooting.