Phone numbers API
List the numbers of your workspace, bring in a number you already own, and choose which agent answers each one.
This API works with phone numbers your workspace already has. You can list them, import a number you own at your own carrier, and point a number at an agent or take it off one. It cannot buy, search for or release a number; for those, use the dashboard.
Scopes
numbers:readforGETnumbers:writefor import, attach and detach
The phone number object
| Field | Type | Notes |
|---|---|---|
id | string (UUID) | Set by Dhvanee. Use it in the attach and detach paths. |
phone_number | string | In international format, for example +14155550134. |
label | string or null | Your own name for the number. |
provider | string | The carrier the number is on: twilio or exotel. |
byo | boolean | true for a number you imported from your own carrier account. |
bound | boolean | true when the carrier has been set up to send this number's calls to Dhvanee. |
agent_id | string (UUID) or null | The agent that answers calls to this number. null when none is chosen. |
created_at | string or null | ISO 8601. |
bind_message | string or null | Only in the import, attach and detach responses: a note from the carrier set-up, when there is one. |
{"id": "e937600f-a705-46c7-8c9f-250ad670fc94", "phone_number": "+14155550134", "label": "US patients line", "provider": "twilio", "byo": true, "bound": true, "agent_id": null, "created_at": "2026-11-22T09:09:40+00:00"}List numbers
Oldest first. The response holds every number in the workspace; there is no paging.
curl -sS -X GET "https://api.stage.dhvanee.com/v1/phone-numbers" \
-H "Authorization: Bearer dhvanee_live_YOUR_KEY"{"items": [{"id": "13f9f9a2-...", "phone_number": "+918045678101", "label": "Main clinic line", "provider": "exotel", "byo": false, "bound": true, "agent_id": "60ebc27a-...", "created_at": "2026-11-07T09:09:40+00:00"}]}Import a number you own
Brings in a number from your own carrier account. Dhvanee checks the details with the carrier and sets the number up to send its calls to your workspace, so this call can take a moment and fails if the carrier refuses. Returns 201 with the number.
curl -sS -X POST "https://api.stage.dhvanee.com/v1/phone-numbers/import" \
-H "Authorization: Bearer dhvanee_live_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"provider":"twilio","phone_number":"+14155550134","account_sid":"ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","auth_token":"YOUR_CARRIER_AUTH_TOKEN","label":"Support"}'| Field | Required | Rules |
|---|---|---|
provider | yes | twilio or exotel. |
phone_number | yes | 5 to 32 characters. Twilio: any country, written with + and the country code. Exotel: an Indian number (+91). |
account_sid | yes | Your account id at the carrier, up to 64 characters. Twilio: AC followed by 32 hexadecimal characters. |
auth_token | Twilio | Up to 128 characters. |
api_key, api_token, subdomain, app_id | Exotel | All four are required. subdomain must be the carrier's API host, for example api.in.exotel.com. account_sid and app_id may contain only letters, digits, - and _. |
label | no | Up to 128 characters. |
workspace_agent_id | no | An agent of this workspace to answer the number straight away. Note the name: attach and detach use agent_id, import uses workspace_agent_id. |
- A number can belong to one workspace only. Importing a number that is already in any workspace answers
409, however it is written (+1 (415) 555-0134and+14155550134are the same number). - Your carrier credentials are stored sealed and are never returned in any response.
- If setting up the carrier fails, nothing is saved and the carrier's reason comes back as a
400, for example that the number was not found in that account.
Attach a number to an agent
Makes the agent answer calls to the number. If another agent was set, it is replaced.
curl -sS -X POST "https://api.stage.dhvanee.com/v1/phone-numbers/NUMBER_ID/attach" \
-H "Authorization: Bearer dhvanee_live_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"agent_id":"AGENT_ID"}'Detach a number from its agent
Leaves the number with no agent. The number stays in the workspace and stays set up with the carrier; it just has no agent to answer.
curl -sS -X POST "https://api.stage.dhvanee.com/v1/phone-numbers/NUMBER_ID/detach" \
-H "Authorization: Bearer dhvanee_live_YOUR_KEY"- Both return
200with the updated number. - Attach and detach only change which agent is chosen. They do not contact the carrier and do not change
bound. - Campaigns that dial from the number are not checked or changed here; check them before you detach a number they use.
Buying and searching
POST /v1/phone-numbers exists only to refuse. A body that asks to buy or search (it contains a key such as buy, purchase, search, shop, area_code, country_code, quantity or order) answers 422, and any other body answers 404 pointing you to import or attach.
Errors
| Status | When |
|---|---|
400 | Import: Enter the number in international format, starting with + and the country code., Exotel numbers must be from IN (+91)., or the carrier refused the set-up (its reason is the message). |
401 | No key, or an unknown or revoked key (Valid API key is required). |
403 | The key lacks the scope (API key needs numbers:write scope). |
404 | Phone number not found or Agent not found (also on import with an unknown workspace_agent_id). |
409 | Import: Phone number already mapped to a workspace. |
422 (import) | A missing field, Twilio Account SID must look like AC followed by 32 hex characters, Missing required field(s): auth_token (or the missing Exotel fields), Subdomain must be an Exotel API host such as api.in.exotel.com, a provider that is not twilio or exotel, or an id that is not a UUID. |
422 (buy or search) | POST /v1/phone-numbers with a buy or search key: Buying and searching numbers is not available on the public API. List owned numbers, attach one to an agent, or import a number you already own. |
429 | Too many requests. See Rate limits. |
Agents are managed through the Agents API. Limits and keys: Authentication, Rate limits.