Skip to main content
A phone number routes calls to an agent only after you assign a published agent version to it. Each number has two independent slots — one for inbound calls and one for outbound calls — so the same number can answer with one agent and dial out with another, or use the same agent for both. Assignment is performed by the agent version publish endpoint. Publishing a version both marks it as live and deploys it onto the inbound and/or outbound slots of the numbers you name in the request.

The two-slot model

Every number stores two assignment slots:
SlotColumnApplies to
Inboundinbound_agent_version_idCalls placed to the number
Outboundoutbound_agent_version_idCalls placed from the number
The slots are independent. Setting one direction never touches the other unless you explicitly target both. An empty slot means no agent handles that direction for that number.
Only published versions are assignable. The publish endpoint sets the version’s published flag to true before it writes the assignment, so deploying a version always publishes it in the same call.

Assign a version

Call the publish endpoint with the version you want live, the numbers to deploy to, and the direction.
POST /core/agents/{id}/versions/{version}/publish
{
  "phone_numbers": ["+15551234567", "+15559876543"],
  "direction": "inbound"
}
FieldTypeDefaultDescription
phone_numbersarray of stringsnoneNumbers to deploy this version to. Omit to publish without changing assignments.
unassign_phone_numbersarray of stringsnoneNumbers to clear this agent from.
directioninbound | outbound | bothinboundWhich slot(s) to write or clear.
The endpoint requires the agents:manage scope and returns the list of updated PhoneNumber records.
curl -X POST https://api.anyreach.ai/core/agents/{id}/versions/2/publish \
  -H "Authorization: Bearer <token>" \
  -H "X-Anyreach-Org: <organization_id>" \
  -H "Content-Type: application/json" \
  -d '{"phone_numbers": ["+15551234567"], "direction": "both"}'
Publishing is blocked while a version’s instructions are being generated, and when the instructions are stale (dirty) and have not been manually edited — regenerate first. Both cases return 400.

Direction values

ValueInbound slotOutbound slot
inboundwrittenunchanged
outboundunchangedwritten
bothwrittenwritten
direction: both
                ┌──────────────────────────────┐
                │        +1 555 123 4567        │
   inbound  ───▶│  inbound_agent_version_id ◀── │  agent v2
   outbound ◀───│  outbound_agent_version_id ◀──│  agent v2
                └──────────────────────────────┘

Unassign a version

To remove an agent from a number, send the numbers under unassign_phone_numbers with the direction to clear. Only slots currently pointing at a version of this agent are cleared — slots holding a different agent are left untouched.
{
  "unassign_phone_numbers": ["+15551234567"],
  "direction": "outbound"
}
You can assign and unassign in the same request by including both phone_numbers and unassign_phone_numbers. The response combines both result sets, deduplicated by number.

Editing from the Phone Numbers page

The Phone Numbers page provides an edit dialog as an alternate entry point to the same flow. For each number you pick an agent and version per side (Inbound and Outbound), and selecting None clears that side. Behind the dialog, choosing a version calls the same publish endpoint, and clearing a side calls the same unassign path — so the result is identical to driving the API directly.

Creating an agent

Build and publish the agent version you assign to a number.

Telephony overview

How numbers, calls, and agents fit together.