CumulusDocs
Open Studio
On this page

Import a phone number

Import a number from a connected carrier trunk. Wait for the number to become ready before using it as caller ID.

Operation ID: numbers.import.

Request

POST /api/v1/telephony/numbers

  • TypeScript SDK: client.numbers.import (path arguments use path).
  • MCP tool: sdk_client_call with operationId: "numbers.import" (path arguments use input.path). Legacy alias: numbers_import. 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

The number must belong to your connected carrier trunk. Use your own number and a published phone agent.

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/numbers" \
  -H "Authorization: Bearer $CUMULUS_API_KEY" \
  -H "Idempotency-Key: $IDEMPOTENCY_KEY" \
  -H "Content-Type: application/json" \
  --data '{
  "e164": "+14155550100",
  "trunk_id": "demo-trunk",
  "nickname": "Support line",
  "outbound_agent_id": "support-phone"
}'

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.numbers.import({
  "body": {
    "e164": "+14155550100",
    "trunk_id": "demo-trunk",
    "nickname": "Support line",
    "outbound_agent_id": "support-phone"
  },
  idempotencyKey,
});

Integration notes

Use an admin key and a connected trunk. For Twilio, e164 must be a number on that trunk.

Wait for state: "ready" before using the number as from in a run or in agent.telephony. If provisioning is pending, repeat the import with the same body and idempotency key.

An inbound_agent_id assignment requires an inbound-enabled trunk and 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
e164stringRequiredpattern: ^+[1-9][0-9]{6,14}$.
trunk_idstringRequiredminLength: 1. maxLength: 128. pattern: ^[a-z0-9][a-z0-9_-]*$.
nicknamestringOptionalmaxLength: 256.
inbound_agent_idstring or nullOptionalminLength: 1. maxLength: 256. pattern: ^[A-Za-z0-9][A-Za-z0-9_.:-]*$.
outbound_agent_idstring or nullOptionalminLength: 1. maxLength: 256. pattern: ^[A-Za-z0-9][A-Za-z0-9_.:-]*$.
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/NumbersImportRequest"
        }
      }
    }
  }
}

Responses

HTTP 201

Import a phone number from a connected trunk

application/json

FieldType or valuesRequiredDescription and limits
number_idstring (uuid)Requiredpattern: ^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$.
e164stringRequiredpattern: ^+[1-9][0-9]{6,14}$.
trunk_idstringRequiredminLength: 1. maxLength: 128. pattern: ^[a-z0-9][a-z0-9_-]*$.
nicknamestring or nullRequiredmaxLength: 256.
inbound_agent_idstring or nullRequiredminLength: 1. maxLength: 256. pattern: ^[A-Za-z0-9][A-Za-z0-9_.:-]*$.
outbound_agent_idstring or nullRequiredminLength: 1. maxLength: 256. pattern: ^[A-Za-z0-9][A-Za-z0-9_.:-]*$.
inbound_agent_versioninteger or nullRequiredStored inbound publication pin, including legacy version 0; null when unassigned. Publishing a newer head does not change it. At least 0. At most 9007199254740991.
outbound_agent_versioninteger or nullRequiredStored outbound publication version; null when unassigned. At least 0. At most 9007199254740991.
state"pending" · "ready"Required—
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))$.

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": "Import a phone number from a connected trunk",
    "content": {
      "application/json": {
        "schema": {
          "$ref": "#/components/schemas/ByocNumber"
        }
      }
    }
  },
  "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": {
      "NumbersImportRequest": {
        "type": "object",
        "properties": {
          "e164": {
            "type": "string",
            "pattern": "^\\+[1-9][0-9]{6,14}$"
          },
          "trunk_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128,
            "pattern": "^[a-z0-9][a-z0-9_-]*$"
          },
          "nickname": {
            "type": "string",
            "maxLength": 256
          },
          "inbound_agent_id": {
            "nullable": true,
            "type": "string",
            "minLength": 1,
            "maxLength": 256,
            "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]*$"
          },
          "outbound_agent_id": {
            "nullable": true,
            "type": "string",
            "minLength": 1,
            "maxLength": 256,
            "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]*$"
          }
        },
        "required": [
          "e164",
          "trunk_id"
        ],
        "additionalProperties": false
      },
      "ByocNumber": {
        "type": "object",
        "properties": {
          "number_id": {
            "type": "string",
            "format": "uuid",
            "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$"
          },
          "e164": {
            "type": "string",
            "pattern": "^\\+[1-9][0-9]{6,14}$"
          },
          "trunk_id": {
            "type": "string",
            "minLength": 1,
            "maxLength": 128,
            "pattern": "^[a-z0-9][a-z0-9_-]*$"
          },
          "nickname": {
            "nullable": true,
            "type": "string",
            "maxLength": 256
          },
          "inbound_agent_id": {
            "nullable": true,
            "type": "string",
            "minLength": 1,
            "maxLength": 256,
            "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]*$"
          },
          "outbound_agent_id": {
            "nullable": true,
            "type": "string",
            "minLength": 1,
            "maxLength": 256,
            "pattern": "^[A-Za-z0-9][A-Za-z0-9_.:-]*$"
          },
          "inbound_agent_version": {
            "nullable": true,
            "description": "Stored inbound publication pin, including legacy version 0; null when unassigned. Publishing a newer head does not change it.",
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "outbound_agent_version": {
            "nullable": true,
            "description": "Stored outbound publication version; null when unassigned.",
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          "state": {
            "type": "string",
            "enum": [
              "pending",
              "ready"
            ]
          },
          "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))$"
          }
        },
        "required": [
          "number_id",
          "e164",
          "trunk_id",
          "nickname",
          "inbound_agent_id",
          "outbound_agent_id",
          "inbound_agent_version",
          "outbound_agent_version",
          "state",
          "created_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 1ebe510cCustomer SDKMarkdown source
Import a phone number · Cumulus developer docs