CumulusDocs
Open Studio
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 use path).
  • MCP tool: sdk_client_call with operationId: "trunks.create" (path arguments use input.path). Legacy alias: trunks_create. Connect to your authenticated /mcp endpoint 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
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

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.

  1. Store the SIP password with secrets_put, using kind: "sip_auth".
  2. Pass auth_secret: {id, version: current_version} to connect the trunk.
  3. For Twilio, set termination_uri to the Termination host (<name>.pstn.twilio.com) and enable Secure Trunking. Calls use TLS and SRTP.
  4. For incoming calls, set inbound: true and configure the returned inbound_sip_uri as Twilio’s Origination URI with secure trunking enabled.
  5. 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

FieldType or valuesRequiredDescription and limits
trunk_idstringRequiredminLength: 1. maxLength: 128. pattern: ^[a-z0-9][a-z0-9_-]*$.
namestringRequiredminLength: 1. maxLength: 256.
provider"twilio_elastic_sip" · "generic_sip"Required—
termination_uristringRequiredminLength: 1. maxLength: 253. pattern: ^a-z0-9?$.
auth_usernamestringRequiredminLength: 1. maxLength: 256.
auth_secretobjectRequired—
auth_secret.idstringRequiredminLength: 1. maxLength: 128.
auth_secret.versionstringRequiredminLength: 1. maxLength: 128.
inboundbooleanOptionalDefault: false.
transfer_caller_id"from-transferee" · "from-transferor"OptionalDeclared 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
OpenAPI JSON
{
  "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

FieldType or valuesRequiredDescription and limits
trunk_idstringRequiredminLength: 1. maxLength: 128. pattern: ^[a-z0-9][a-z0-9_-]*$.
namestringRequiredminLength: 1. maxLength: 256.
provider"twilio_elastic_sip" · "generic_sip"Required—
termination_uristringRequiredminLength: 1. maxLength: 253. pattern: ^a-z0-9?$.
auth_usernamestring or nullRequiredminLength: 1. maxLength: 256.
auth_secretobject or nullRequired—
auth_secret.idstringRequired in a non-null parentminLength: 1. maxLength: 128.
auth_secret.versionstringRequired in a non-null parentminLength: 1. maxLength: 128.
inboundbooleanRequired—
transfer_caller_id"from-transferee" · "from-transferor"OptionalDeclared 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_uristring or nullOptionalmaxLength: 1024.
created_atstring (date-time)Requiredpattern: ^(?:(?:\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_atstring (date-time)Requiredpattern: ^(?:(?:\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

HTTPDescription
4XXTyped error (ApiError)
5XXTyped error (ApiError)

Errors use the shared error envelope. Inspect error.code, retryable, outcome and details before retrying.

Complete OpenAPI schema
OpenAPI JSON
{
  "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
OpenAPI JSON
{
  "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.

Content version 837829f6Customer SDKMarkdown source
Connect a SIP trunk · Cumulus developer docs