Call Commands

Answer an incoming call. You must issue this command before executing subsequent commands on an incoming call.

To answer with an AI assistant, include assistant.id and any per-call overrides in the assistant object. Telnyx attempts to warm up the assistant before answering the call, then starts the assistant automatically when the call is answered. Do not also send ai_assistant_start for this flow. The HTTP success response can arrive before the call is answered; use the call.answered webhook to track the answer. If warm-up fails, Telnyx falls back to starting the assistant after answering.

When assistant.id is supplied, obtain the conversation ID from data.payload.conversation_id in the call.conversation.created webhook and correlate it using data.payload.call_control_id. The answer HTTP response does not include conversation_id. The created event is emitted during assistant startup and does not indicate that the assistant is ready to speak.

Set the assistant voice with assistant.voice_settings.voice and speech-to-text settings with assistant.transcription. You can reuse one stored assistant with different per-call settings. Warm-up prepares assistant configuration and dependencies; it does not wait for the greeting audio to be ready or guarantee zero silence after answer. A plain answer followed by ai_assistant_start performs assistant startup after the call has already been answered.

Expected Webhooks:

  • call.answered
  • call.conversation.created when the requested assistant conversation is created
  • call.hold and call.unhold if the call is held/unheld
  • call.deepfake_detection.result if deepfake_detection was enabled
  • call.deepfake_detection.error if deepfake_detection was enabled and an error occurred
  • streaming.started, streaming.stopped or streaming.failed if stream_url was set

When the record parameter is set to record-from-answer, the response will include a recording_id field.

post/calls/{call_control_id}/actions/answer

Request

  • Base URL: https://api.telnyx.com/v2
  • URL: https://api.telnyx.com/v2/calls/{call_control_id}/actions/answer
  • Auth: HTTP bearer

Path parameters

call_control_idstring required

Unique identifier and token for controlling the call

Request body

billing_group_idstring uuid

Use this field to set the Billing Group ID for the call. Must be a valid and existing Billing Group ID.

client_statestring

Use this field to add state to every subsequent webhook. It must be a valid Base-64 encoded string.

command_idstring

Use this field to avoid duplicate commands. Telnyx will ignore any command with the same command_id for the same call_control_id.

preferred_codecs'G722,PCMU,PCMA,G729,OPUS,VP8,H264'

The list of comma-separated codecs in a preferred order for the forked media to be received.

stream_urlstring

The destination WebSocket address where the stream is going to be delivered.

stream_track'inbound_track' | 'outbound_track' | 'both_tracks'

Specifies which track should be streamed.

stream_codec'PCMU' | 'PCMA' | 'G722' | 'OPUS' | 'AMR-WB' | 'L16' | 'default'

Specifies the codec to be used for the streamed audio. When set to 'default' or when transcoding is not possible, the codec from the call will be used.

stream_bidirectional_mode'mp3' | 'rtp'

Configures method of bidirectional streaming (mp3, rtp).

stream_bidirectional_codec'PCMU' | 'PCMA' | 'G722' | 'OPUS' | 'AMR-WB' | 'L16'

Indicates codec for bidirectional streaming RTP payloads. Used only with stream_bidirectional_mode=rtp. Case sensitive.

stream_bidirectional_target_legs'both' | 'self' | 'opposite'

Specifies which call legs should receive the bidirectional stream audio.

send_silence_when_idleboolean

Generate silence RTP packets when no transmission available.

webhook_urlstring

Use this field to override the URL for which Telnyx will send subsequent webhooks to for this call.

webhook_url_method'POST' | 'GET'

HTTP request type used for webhook_url.

transcriptionboolean

Enable standalone call transcription upon call answer. The default value is false. Configure this feature with transcription_config. To configure speech recognition for an AI assistant, use assistant.transcription instead.

record'record-from-answer'

Start recording automatically after an event. Disabled by default.

record_channels'single' | 'dual'

Defines which channel should be recorded ('single' or 'dual') when record is specified.

record_format'wav' | 'mp3'

Defines the format of the recording ('wav' or 'mp3') when record is specified.

record_max_lengthinteger

Defines the maximum length for the recording in seconds when record is specified. The minimum value is 0. The maximum value is 43200. The default value is 0 (infinite).

record_timeout_secsinteger

The number of seconds that Telnyx will wait for the recording to be stopped if silence is detected when record is specified. The timer only starts when the speech is detected. Please note that call transcription is used to detect silence and the related charge will be applied. The minimum value is 0. The default value is 0 (infinite).

record_track'both' | 'inbound' | 'outbound'

The audio track to be recorded. Can be either both, inbound or outbound. If only single track is specified (inbound, outbound), channels configuration is ignored and it will be recorded as mono (single channel).

record_trim'trim-silence'

When set to trim-silence, silence will be removed from the beginning and end of the recording.

record_custom_file_namestring

The custom recording file name to be used instead of the default call_leg_id. Telnyx will still add a Unix timestamp suffix.

webhook_urlsobject

A map of event types to arrays of webhook URLs. When an event of the specified type occurs, the webhook URLs associated with that event type will be called instead of webhook_url. Events not mapped here will use the default webhook_url.

webhook_urls_method'POST' | 'GET'

HTTP request method to invoke webhook_urls.

webhook_retries_policiesobject

A map of event types to retry policies. Each retry policy contains an array of retries_ms specifying the delays between retry attempts in milliseconds. Maximum 5 retries, total delay cannot exceed 60 seconds.

Example request

{
  "assistant": {
    "id": "asst_123"
  },
  "client_state": "aGF2ZSBhIG5pY2UgZGF5ID1d",
  "command_id": "891510ac-f3e4-11e8-af5b-de00688a4901",
  "webhook_url": "https://www.example.com/server-b/",
  "webhook_url_method": "POST",
  "send_silence_when_idle": true,
  "deepfake_detection": {
    "enabled": true,
    "timeout": 15,
    "rtp_timeout": 30
  }
}

Response

Successful response upon making a call control command that includes recording_id.

Example response

{
  "data": {
    "result": "ok",
    "recording_id": "d7e9c1d4-8b2a-4b8f-b3a7-9a671c9e9b0a"
  }
}

Changes

    • info

      added the new ar enum value to the request property ///

    • info

      added the new be enum value to the request property ///

    • info

      added the new bg enum value to the request property ///

    • info

      added the new bn enum value to the request property ///

    • info

      added the new ca enum value to the request property ///

    • info

      added the new cmn enum value to the request property ///

    • info

      added the new cmn-Hans enum value to the request property ///

    • info

      added the new cmn-Hant enum value to the request property ///

    • info

      added the new cs enum value to the request property ///

    • info

      added the new da enum value to the request property ///

    • info

      added the new de enum value to the request property ///

    • info

      added the new el enum value to the request property ///

    • info

      added the new en-AU enum value to the request property ///

    • info

      added the new en-GB enum value to the request property ///

    • info

      added the new en-US enum value to the request property ///

    • info

      added the new eo enum value to the request property ///

    • info

      added the new es enum value to the request property ///

    • info

      added the new et enum value to the request property ///

    • info

      added the new fa enum value to the request property ///

    • info

      added the new fi enum value to the request property ///

    • info

      added the new fr enum value to the request property ///

    • info

      added the new he enum value to the request property ///

    • info

      added the new hi enum value to the request property ///

    • info

      added the new hr enum value to the request property ///

    • info

      added the new hu enum value to the request property ///

    • info

      added the new ia enum value to the request property ///

    • info

      added the new id enum value to the request property ///

    • info

      added the new it enum value to the request property ///

    • info

      added the new ja enum value to the request property ///

    • info

      added the new ko enum value to the request property ///

    • info

      added the new lt enum value to the request property ///

    • info

      added the new lv enum value to the request property ///

    • info

      added the new mr enum value to the request property ///

    • info

      added the new ms enum value to the request property ///

    • info

      added the new nl enum value to the request property ///

    • info

      added the new no enum value to the request property ///

    • info

      added the new pl enum value to the request property ///

    • info

      added the new pt enum value to the request property ///

    • info

      added the new ro enum value to the request property ///

    • info

      added the new ru enum value to the request property ///

    • info

      added the new sk enum value to the request property ///

    • info

      added the new sl enum value to the request property ///

    • info

      added the new speechmatics/linden-1 enum value to the request property //

    • info

      added the new speechmatics/linden-1 enum value to the request property ///

    • info

      added the new sv enum value to the request property ///

    • info

      added the new ta enum value to the request property ///

    • info

      added the new th enum value to the request property ///

    • info

      added the new tr enum value to the request property ///

    • info

      added the new uk enum value to the request property ///

    • info

      added the new ur enum value to the request property ///

    • info

      added the new vi enum value to the request property ///

    • info

      added the new yue enum value to the request property ///

    • info

      added deepgram/nova-2-medical deepgram/nova-2-phonecall deepgram/nova-3-medical deepgram/flux deepgram/flux-multi discriminator mapping keys to the ///// request property

    • info

      added to the ///// request property oneOf list