Create a phone number

Updated

Registers a phone number, its SIP trunk, and its inbound routing in your project.

Preview documentation

You're reading the Conversational AI Platform (Preview) docs. Switch to Main.
POST
https://preview.ai.agora.io/conversational-ai/v1/projects/{appid}/numbers

Use this endpoint to import a number that your carrier assigned to you. Importing a number doesn't purchase one. Outbound sessions and campaigns can use the number as their caller ID, and inbound chooses the agent that answers calls to it.

Path Parameters

appidstring
Required

The App ID of your project.

Request Body

numberstring
Required

The phone number in E.164 format, for example +14155550100.

descriptionstring

A description of the number's purpose. It's separate from sip_trunk.name, which names the carrier connection.

sip_trunkobject
Required

The carrier connection for this number.

namestring

A name for the carrier connection that helps you identify it.

hostnamestring
Required

The carrier's SIP hostname, without a scheme or port. For example, acme.pstn.example.com.

portinteger

The SIP signaling port. Defaults to 5061 when transport is tls, and 5060 when it's udp or tcp.

transportstring

The transport protocol for the carrier connection.

authobject

The credentials for your SIP trunk. They are write-only and are never returned.

allowed_ipsarray<string>

The addresses allowed to send inbound SIP traffic to this number. Each entry is an IPv4 address, such as 54.172.60.1, or an IPv4 CIDR range, such as 54.172.60.0/23. IPv6 addresses and hostnames aren't accepted. If you omit it, inbound SIP traffic is accepted from any address, so set it to your carrier's signaling addresses.

inboundobject

What happens when someone calls this number. If you omit it, inbound calls are rejected. call_policy is required when agent isn't null.

Response Body

The number was created. The response body contains the saved number.

Response Headers

Agora-Request-Idstring

A unique ID for the request. Include it when you contact Agora support.

ETagstring

The current version of the resource. Pass this value in the If-Match header of your next update or delete request for this resource.

number_idstring

The ID of the phone number, a UUID.

numberstring

The phone number in E.164 format.

descriptionstring

A description of the number's purpose. It's separate from sip_trunk.name, which names the carrier connection.

sip_trunkobject
inboundobject

What happens when someone calls this number. If you omit it, inbound calls are rejected. call_policy is required when agent isn't null.

create_tsinteger

The time the number was added, as a Unix timestamp in seconds.

Authorization

This endpoint requires authentication.

Request examples

Example Request
curl -X POST 'https://preview.ai.agora.io/conversational-ai/v1/projects/string/numbers' \  -H 'Content-Type: application/json' \  -d '{  "number": "+14155550100",  "description": "Primary customer support line for North America.",  "sip_trunk": {    "name": "support-line",    "hostname": "acme.pstn.example.com",    "transport": "tls",    "auth": {      "username": "acme",      "password": "<your_sip_password>"    }  },  "inbound": {    "agent": "3f6c2a9e-8d1b-4e7a-9c55-0b2f7d1e4a10",    "call_policy": {      "max_call_duration_seconds": 1800,      "max_silence_duration_ms": 60000,      "end_call": {        "on_user_request": true      }    }  }}'

Response example

Example Response
{  "number_id": "92e68758-3d3a-4f27-8b93-3fd8d834467c",  "number": "+14155550100",  "description": "Primary customer support line for North America.",  "sip_trunk": {    "name": "support-line",    "hostname": "acme.pstn.example.com",    "port": 5061,    "transport": "tls"  },  "inbound": {    "agent": "3f6c2a9e-8d1b-4e7a-9c55-0b2f7d1e4a10",    "call_policy": {      "max_call_duration_seconds": 1800,      "max_silence_duration_ms": 60000,      "end_call": {        "on_user_request": true      }    }  },  "create_ts": 1787223852}