Skip to navigation

Phone numbers

Assign agents to the numbers your workspace has already connected.

Use numbers already imported into the workspace. You can connect carrier accounts and import numbers through the Telephony management API, or in the Rasen app. Importing a number does not buy it from a carrier.

Each number has an ETag, equal to the body’s revision. Every change sends it in If-Match.

export RASEN_API_BASE="https://api.rasen.ai/v1"
export RASEN_API_KEY="<your key>"
AUTH="Authorization: Bearer $RASEN_API_KEY"
curl -sS "$RASEN_API_BASE/phone-numbers?number=%2B12025550123" -H "$AUTH"
curl -sS -i "$RASEN_API_BASE/phone-numbers/num_…" -H "$AUTH" # the ETag header equals "revision"

Outbound: let an agent call from a number

curl -sS -X PUT "$RASEN_API_BASE/phone-numbers/num_…/outbound-agents/agent_…" \
-H "$AUTH" -H "Idempotency-Key: $(uuidgen)" -H 'If-Match: "<revision from the read>"'

The answer is the number with its new revision and outbound_agent_ids. Adding a pair that is already there, or removing one that is not, changes nothing and keeps the revision. Other agents on the number are never touched. DELETE on the same path removes the agent.

AnswerMeaningWhat to do
428 revision_requiredNo If-Match.Read the number and send its revision.
409 conflict, reason: stale_revisionThe number changed since your read.Read it again and retry with the new ETag.
409 conflict, reason: active_callOn removal: a call still holds the pair. A running outbound call holds its number and agent; a running inbound call holds the inbound assignment.Wait for it to end, then retry.
409 agent_not_published or agent_not_liveThe agent cannot take calls.Publish the agent, or choose another.

Inbound: answer a number with an agent

A number answers inbound calls with at most one agent, across every workspace.

curl -sS -X PUT "$RASEN_API_BASE/phone-numbers/num_…/assignments/inbound" \
-H "$AUTH" -H "Idempotency-Key: $(uuidgen)" -H 'If-Match: "<revision>"' \
-H "Content-Type: application/json" -d '{"agent_id": "agent_…", "configure_inbound": true}'
{"number": {"id": "num_…", "inbound_agent_id": "agent_…", "inbound_setup": "ready", "…": "…"},
"assignment_saved": true, "setup_state": "ready", "next_action": null}

The assignment is saved first. With configure_inbound: true the platform then asks the carrier to route the number, and setup_state says what happened:

setup_stateMeaningnext_action
readyThis workspace’s last carrier setup of the number succeeded. It is not a live read of the carrier: a change made in the carrier’s dashboard is not seen.none
needs_provisioningSaved; carrier routing was not requested (configure_inbound: false).POST …/provision
failedSaved; the carrier refused the setup.Check the carrier account, then POST …/provision with a new key.
manual_action_requiredThis carrier needs a dashboard step.The step, in words.
not_requiredReturned when you remove the inbound agent: no carrier change is made.A note that the carrier may still route the number to the platform, which no longer answers it.

setup_state is an open list: treat a value you do not know as unknown, never as success. The setup can also be refused outright with 409 carrier_action_required or 409 carrier_capability_unsupported (details.carrier and details.capability).

  • 409 conflict with reason: connected_elsewhere means another workspace answers this number inbound. Nothing about that workspace is disclosed. The number can still be used for outbound calls.
  • Removing the inbound agent (DELETE …/assignments/inbound) stops the platform answering. It does not change the carrier: the answer is setup_state: not_required, and next_action says the carrier may still route the number.
  • POST /phone-numbers/{number_id}/provision is an explicit new setup attempt for a number that has an inbound agent. It never creates a second carrier application. Without an inbound agent it answers 409 conflict with reason: inbound_agent_required.

Retries and visibility

  • Every assignment and provisioning change stores its full answer. A replay with the same key returns that answer with its original ETag, and it is answered before the current revision is checked.
  • Use a new key for each new provisioning attempt; GET /phone-numbers/{number_id} shows the current setup state.
  • A number of another workspace, a removed number and a malformed number ID all answer 404 not_found. Carrier references and credentials never appear in an answer.