All pages

API reference

Point a phone number at an agent

PATCH /v1/phone-numbers/{phone_number_id}

View as Markdown

Choose the agent a number belongs to: the one that answers when it is called, or — for a number that only places calls — the outbound agent that calls from it. null leaves it with no agent. The agent must be in the number's project. It takes effect on the next call. A test key cannot do this, because a phone number is real. Needs phone_numbers:write.

Parameters

Name In Type Required Description
phone_number_id path string (uuid) Yes

Body

Sent as JSON. A field this operation does not take is refused, so a typo fails loudly.

Field Type Required Description
agent_id string (uuid) or null Yes The agent the number belongs to, in the number's project — or null for none. Required: leaving it out is not the same as null.

Answer

200 with PhoneNumber.

Errors

Every error is a problem document with a stable code.

Status When
401 The key is missing, mistyped, unknown, revoked or expired.
403 A test key, or a number another agent holds that this key does not reach.
404 This key reaches no such number, or no such agent in the number's project.
409 The number and the agent want different things, or the project is frozen.
422 Validation Error
429 Too many requests for this key or its organization; see Retry-After.
500 Something went wrong on our side. Quote the request_id to support.
501 This deployment has no telephony.

Examples

Point a number at an agent
#!/bin/sh
# Point a number at an agent. With a live key: a phone number is real.
curl -sS --fail-with-body -X PATCH "https://api.aigently.ai/v1/phone-numbers/7a9c1e3f-5b7d-4f9a-8c2e-4d6f8a0c2e4a" \
  -H "Authorization: Bearer $AIGENTLY_API_KEY" \
  --json '{
  "agent_id": "3c7d9e1f-5a2b-4c6d-8e0f-1a3b5c7d9e2f"
}'

Try it

Sends this request to the API from your browser, with a test key. Nothing it does rings a phone.