Skip to main content
POST
Attach Agent Phone Number
Changes state - verify before retry Attach an agent phone number to route calls through that agent. Choose inbound so the number rings the agent, or outbound so the agent can call from it. The link belongs to the agent, not to a version: every version uses it, inbound calls run on the latest published version, and calls and batches pick the version they dial with.

Before you begin

Limits

Attach agent phone number request

Verify the result

A 201 response returns the new link in data, with linked_at set and unlinked_at null. Call List Agent Phone Numbers to confirm the number appears under the chosen direction. Once an agent has two or more outbound numbers, Create Call and Create Batch Call need phone_number_id to choose one.

Errors and recovery

Refusals carry a code in data.code. If a request times out, list the agent’s numbers before retrying. A repeat of a request that succeeded returns 409 PHONE_NUMBER_ALREADY_LINKED and changes nothing.

Move a number from another agent

Add "move": true to the attach request to move the number in the chosen direction. The old agent loses that direction and the new agent receives it in one transaction. The opposite direction stays unchanged. The old link is closed with unlink_reason: "manual". Live calls on the number block either direction with 409 PHONE_NUMBER_HAS_LIVE_CALLS. For an outbound move, unfinished batches return NUMBER_USED_BY_BATCH and active workflows return PHONE_NUMBER_USED_IN_ACTIVE_WORKFLOWS. Change the affected batches’ number or cancel them, pause the affected workflows, and wait for calls to finish before retrying. If the request times out, check both agents’ number lists and link history before sending it again.

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

agentId
string
required

Agent ID from List Agents.

Example:

"agent_2g7Xy3tY53gRlp"

Body

application/json
phone_number_id
string
required

Organization phone number to attach

Example:

"phn_2g7Xy3tY53gRlp"

direction
enum<string>
required
Available options:
inbound,
outbound
move
boolean
default:false

Move the number here when another agent holds it in this direction. That agent loses it in the same request, under the same rules as detaching it there.

Response

Successful response.

success
boolean
required
error
boolean
required
statusCode
integer
required
message
string
required
data
object
required
timestamp
string<date-time>
required