Skip to navigation

Configure call transfers

Summary

This guide configures named destinations for the built-in transfer tool and confirms any carrier setup needed to use them. It also publishes the policy and reads transfer outcomes. It does not configure SIP trunks; see Connect a SIP trunk.

Facts

ItemValue
OperationsgetTelephonyConnection, setTelephonyConnectionTransferFlow, getAgentDraft, updateAgentDraft, publishAgent, getCall
Connection pathsGET /telephony/connections/{connection_id}, PUT /telephony/connections/{connection_id}/transfer-flow
Agent pathsGET, PATCH /agents/{agent_id}/draft; POST /agents/{agent_id}/publish
Result pathGET /calls/{call_id}
Capabilitiesnumbers.assign for connections, config.read for draft reads, agents.write for draft edits, agents.publish for publication, calls.read for results
HeadersAuthorization on every request; Idempotency-Key and If-Match on the mutations shown here
Destination list1 to 10 destinations when enabled; writing destinations replaces the whole list
Targetse164; trunk_extension on SIP trunk numbers; sip_uri on SIP trunk numbers in global
Ring timeoutring_timeout_s: 10 to 60 seconds, default 30
EnvironmentRASEN_API_BASE (ending in /v1), RASEN_API_KEY, CONNECTION_ID, AGENT_ID, CALL_ID, CONNECTION_ETAG, DRAFT_ETAG
Python3.10 or later, with httpx
TypeScriptNode.js 22 or later, with built-in fetch

Steps

Set CONNECTION_ID to a connection’s id from listTelephonyConnections. Set AGENT_ID to an agent’s id from listAgents or createAgent. Set CALL_ID to a call’s id from listCalls after the published agent handles a call.

1. Read the connection’s transfer requirements

curl --fail-with-body -sS -i "$RASEN_API_BASE/telephony/connections/$CONNECTION_ID" \
-H "Authorization: Bearer $RASEN_API_KEY"

Read transfer.open, mechanism, setup_required, setup_confirmed and setup_action. If setup_required is true, complete the step described by setup_action in your carrier’s dashboard. For Exotel, this means the flow applets after the Voicebot applet. Set CONNECTION_ETAG to the connection’s returned revision; the connection response has no ETag header.

2. Confirm the carrier’s transfer flow when required

Skip this request when setup_required is false: a carrier needing no setup step returns invalid_request.

curl --fail-with-body -sS -i -X PUT "$RASEN_API_BASE/telephony/connections/$CONNECTION_ID/transfer-flow" \
-H "Authorization: Bearer $RASEN_API_KEY" -H "Idempotency-Key: $(uuidgen)" -H "If-Match: $CONNECTION_ETAG" \
-H "Content-Type: application/json" -d '{"confirmed":true}'

This records confirmation without calling the carrier. Send confirmed: false to withdraw it after reading the connection again. Calls on this connection’s numbers offer transfer only after required setup is confirmed.

3. Read the agent draft

curl --fail-with-body -sS -i "$RASEN_API_BASE/agents/$AGENT_ID/draft" \
-H "Authorization: Bearer $RASEN_API_KEY"

Set DRAFT_ETAG to this draft’s ETag header before editing. It is a different token from CONNECTION_ETAG; do not send one resource’s token to the other.

4. Enable a named destination

Replace the illustrative phone number with a number you control. This sample replaces the entire destination list with one E.164 destination.

curl --fail-with-body -sS -i -X PATCH "$RASEN_API_BASE/agents/$AGENT_ID/draft" \
-H "Authorization: Bearer $RASEN_API_KEY" -H "Idempotency-Key: $(uuidgen)" -H "If-Match: $DRAFT_ETAG" \
-H "Content-Type: application/json" \
-d '{"default_tools":{"transfer":{"enabled":true,"destinations":[{"label":"Support team","when_to_use":"The caller asks to speak to support.","target":{"kind":"e164","e164":"+12025550123"},"ring_timeout_s":30}]}}}'

Keep the server-generated destination id when editing that destination; omit id to add a new one. The model sees id, label and when_to_use, but never the target. The optional handoff_message is spoken before transfer; null uses the default text. Set DRAFT_ETAG to the updated draft’s ETag header before publication.

5. Publish the policy

Ensure the rest of the draft is ready before publishing; publication freezes the complete draft configuration.

curl --fail-with-body -sS -i -X POST "$RASEN_API_BASE/agents/$AGENT_ID/publish" \
-H "Authorization: Bearer $RASEN_API_KEY" -H "Idempotency-Key: $(uuidgen)" -H "If-Match: $DRAFT_ETAG"

New calls use the published policy; running calls keep their original version. At call time, the carrier and region determine which destinations the transfer tool can offer. A destination that the call cannot use is omitted from the tool.

Rules

  • MUST supply at least one destination when transfer is enabled.
  • MUST preserve each existing destination’s id when editing it.
  • MUST include every destination you want to keep when replacing destinations.
  • MUST NOT write destinations and destination_number in the same body.
  • MUST NOT confirm carrier setup before completing the carrier’s step.
  • MUST publish after changing the draft policy to use it on new calls.

destination_number remains supported for a single E.164 destination. Writing it alone replaces the list with that destination. On reads, it is an alias of the first E.164 destination, or null when there is none. Disabling transfer can retain the destinations for later use.

A trunk_extension target contains trunk_id and a 1 to 8 digit extension. A sip_uri target contains uri, for example sip:support@pbx.example.com. These targets require eligible SIP trunk numbers; a SIP URI also requires the global region.

Verify

curl --fail-with-body -sS "$RASEN_API_BASE/calls/$CALL_ID" \
-H "Authorization: Bearer $RASEN_API_KEY"

end_reason says why a call ended. A call that the agent ended, with its end_call tool or its goodbye, reports agent_hangup. An answered call whose line failed reports line_dropped, and a call that reached a voicemail reports voicemail_detected. completed means that the call ended and nothing says who ended it. Keep an end_reason value you do not know. Inspect transfer_destination_label after a call ends in a transfer: it has a value only when the call ended transferred or transfer_failed. It identifies the last destination by label, without exposing its number or address. transfer_duration_ms is the carrier-reported time connected to the destination. It is null when no transfer connected or when the time has not been reported. These fields also appear in call list and search results and in webhook payloads containing a Call.

Errors

CodeCauseFix
invalid_requestBoth destination shapes were written, the policy is invalid, or this carrier needs no transfer-flow confirmation.Send one valid destination shape; confirm only when setup_required is true.
conflict (stale_revision)The connection changed after your read.Read the connection again and reconcile before confirming.
draft_conflictThe agent publication token is stale.Read the draft again and reconcile before editing or publishing.
revision_requiredA mutation omitted If-Match.Read the resource and send its ETag.
telephony_not_connectedThe carrier connection is unavailable.Read and restore the connection before confirming setup.
invalid_request on publicationThe draft cannot be published as supplied.Validate the draft and resolve the reported reasons.