Answer an incoming call. You must issue this command before executing other subsequent commands on an incoming call.
Expected Webhooks:
{- "client_state": "aGF2ZSBhIG5pY2UgZGF5ID1d",
- "command_id": "891510ac-f3e4-11e8-af5b-de00688a4901"
}
{- "result": "ok"
}
Bridge two call control calls.
Expected Webhooks:
{- "call_control_id": "c8ac9611-25c3-494a-b8b4-2f036a18a6b2",
- "client_state": "aGF2ZSBhIG5pY2UgZGF5ID1d",
- "command_id": "891510ac-f3e4-11e8-af5b-de00688a4901",
- "park_after_unbridge": "self"
}
{- "result": "ok"
}
Call forking allows you to stream the media from a call to a specific target in realtime. This stream can be used to enable realtime audio analysis in support of a variety of use cases, including fraud detection, or the creation of AI-generated audio responses. Requests must specify either the "target" attribute or the "rx" and "tx" attributes.
Expected Webhooks:
There are currently no webhooks associated with the Forking start command.
Simple Telnyx RTP Encapsulation Protocol (STREP)
Note: This header/encapsulation is not used when the "rx" and "tx" parameters have been specified; it only applies when media is forked using the "target" attribute.
If the destination for forked media is specified using the "target"
attribute, the RTP will be encapsulated in an extra Telnyx protocol,
which adds a 24 byte header to the RTP payload in each packet. The STREP
header includes the Call Control call_leg_id
for stream
identification, along with bits that represent the direction (inbound or
outbound) of the media. This 24-byte header sits between the UDP header
and the RTP header.
The STREP header makes it possible to fork RTP for multiple calls (or two RTP streams for the same call) to the same IP:port, where the streams can be demultiplexed by your application using the information in the header. Of course, it's still possible to ignore this header completely, for example, if sending forked media for different calls to different ports or IP addresses. In this case, simply strip 24 bytes (or use the second byte to find the header length) from the received UDP payload to get the RTP (RTP header and payload).
STREP Specification
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|1 1|Version|L|D| HeaderLen | reserved (2 bytes) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| reserved (4 bytes, for UDP ports or anything else) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| The call_leg_id |
| from Call Control |
| (128 bits / 16 bytes) |
| (this is binary data) |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
11
Static bits 11, always set to 11, so that we humans can easily
visually distinguish forked media from RTP (10) and T.38 media (usually 00)
and SIP (which begins with a capital letter, so begins with bits 01)
This is a magic number.
Version
Four bits to indicate the version number of the protocol, starting at 0001.
L
One bit to represent the leg of the call (A or B).
0 represents the A (first) leg of the call.
1 represents the B (second) leg of the call.
D
One bit to represent the direction of this RTP stream.
0 represents media received by Telnyx.
1 represents media transmitted by Telnyx.
HeaderLen (1 byte)
The length of the header in bytes.
Note that this value does not include the length of the payload. The total
size of the RTP can be calculated by subtracting the HeaderLen from the UDP
length (minus 8 for the UDP header).
In version 1, this value will always be 24.
Reserved (6 bytes)
Reserved for future use and to make sure that the header is a multiple of 32 bits
Call Leg ID
A 128-bit identifier for the call leg.
This is the call_leg_id from Call Control.
target | string The network target, udp:ip_address:port, where the call's RTP media packets should be forwarded. Both incoming and outgoing media packets will be delivered to the specified target, and information about the stream will be included in the encapsulation protocol header, including the direction (0 = inbound; 1 = outbound), leg (0 = A-leg; 1 = B-leg), and call_leg_id. |
rx | string The network target, udp:ip_address:port, where the call's incoming RTP media packets should be forwarded. |
tx | string The network target, udp:ip_address:port, where the call's outgoing RTP media packets should be forwarded. |
stream_type | string Default: "raw" Optionally specify a media type to stream. If |
client_state | string Use this field to add state to every subsequent webhook. It must be a valid Base-64 encoded string. |
command_id | string Use this field to avoid duplicate commands. Telnyx will ignore commands with the same "command_id". |
{- "target": "udp:186.52.113.6:9000",
- "rx": "186.52.113.6:9000",
- "tx": "186.52.113.6:9001",
- "stream_type": "decrypted",
- "client_state": "aGF2ZSBhIG5pY2UgZGF5ID1d",
- "command_id": "891510ac-f3e4-11e8-af5b-de00688a4901"
}
{- "result": "ok"
}
Stop forking a call.
Expected Webhooks:
There are currently no webhooks associated with the Forking start command.
{- "client_state": "aGF2ZSBhIG5pY2UgZGF5ID1d",
- "command_id": "891510ac-f3e4-11e8-af5b-de00688a4901"
}
{- "result": "ok"
}
Play an audio file on the call until the required DTMF signals are gathered to build interactive menus.
You can pass a list of valid digits along with an 'invalid_audio_url', which will be played back at the beginning of each prompt. Playback will be interrupted when a DTMF signal is received. The Answer command must be issued before the gather_using_audio
command.
Expected Webhooks:
{- "min": 1,
- "max": 10,
- "tries": 3,
- "timeout": 60000,
- "terminating_digit": "#",
- "valid_digits": "123",
- "inter_digit_timeout": 10000,
- "client_state": "aGF2ZSBhIG5pY2UgZGF5ID1d",
- "command_id": "891510ac-f3e4-11e8-af5b-de00688a4901"
}
{- "result": "ok"
}
Convert text to speech and play it on the call until the required DTMF signals are gathered to build interactive menus.
You can pass a list of valid digits along with an 'invalid_payload', which will be played back at the beginning of each prompt. Speech will be interrupted when a DTMF signal is received. The Answer command must be issued before the gather_using_speak
command.
Expected Webhooks:
{- "payload": "Say this on the call",
- "invalid_payload": "Say this on the call",
- "payload_type": "ssml",
- "service_level": "premium",
- "voice": "female",
- "language": "en-US",
- "min": 1,
- "max": 10,
- "tries": 3,
- "timeout": 60000,
- "terminating_digit": "#",
- "valid_digits": "123",
- "inter_digit_timeout": 10000,
- "client_state": "aGF2ZSBhIG5pY2UgZGF5ID1d",
- "command_id": "891510ac-f3e4-11e8-af5b-de00688a4901"
}
{- "result": "ok"
}
Stops previously started gather
Expected Webhooks:
{- "client_state": "aGF2ZSBhIG5pY2UgZGF5ID1d",
- "command_id": "891510ac-f3e4-11e8-af5b-de00688a4901"
}
{- "result": "ok"
}
Expected Webhooks:
{- "client_state": "aGF2ZSBhIG5pY2UgZGF5ID1d",
- "command_id": "891510ac-f3e4-11e8-af5b-de00688a4901"
}
{- "result": "ok"
}
Reject an incoming call
Expected Webhooks:
{- "client_state": "aGF2ZSBhIG5pY2UgZGF5ID1d",
- "command_id": "891510ac-f3e4-11e8-af5b-de00688a4901",
- "cause": "USER_BUSY"
}
{- "result": "ok"
}
Play an audio file on the call. If multiple play audio commands are consecutively issued, the audio files will be placed in a queue awaiting playback.
Notes:
Expected Webhooks:
{- "loop": "infinity",
- "overlay": "true",
- "stop": "current",
- "target_legs": "self",
- "client_state": "aGF2ZSBhIG5pY2UgZGF5ID1d",
- "command_id": "891510ac-f3e4-11e8-af5b-de00688a4901"
}
{- "result": "ok"
}
Stops audio being played on the call.
Expected Webhooks:
{- "stop": "current",
- "client_state": "aGF2ZSBhIG5pY2UgZGF5ID1d",
- "command_id": "891510ac-f3e4-11e8-af5b-de00688a4901"
}
{- "result": "ok"
}
Start recording the call. Recording will stop on call hang-up, or can be initiated via the Stop Recording command.
Expected Webhooks: There are no webhooks associated with this Command.
{- "format": "mp3",
- "channels": "single",
- "client_state": "aGF2ZSBhIG5pY2UgZGF5ID1d",
- "command_id": "891510ac-f3e4-11e8-af5b-de00688a4901",
- "play_beep": true
}
{- "result": "ok"
}
Stop recording the call.
Expected Webhooks:
{- "client_state": "aGF2ZSBhIG5pY2UgZGF5ID1d",
- "command_id": "891510ac-f3e4-11e8-af5b-de00688a4901"
}
{- "result": "ok"
}
Sends DTMF tones from this leg. DTMF tones will be heard by the other end of the call.
Expected Webhooks:
There are no webhooks associated with this command.
{- "digits": "1www2WABCDw9",
- "duration": 500,
- "client_state": "aGF2ZSBhIG5pY2UgZGF5ID1d",
- "command_id": "891510ac-f3e4-11e8-af5b-de00688a4901"
}
{- "result": "ok"
}
Convert text to speech and play it back on the call. If multiple speak text commands are issued consecutively, the audio files will be placed in a queue awaiting playback.
Expected Webhooks:
{- "payload": "Say this on the call",
- "payload_type": "ssml",
- "service_level": "premium",
- "stop": "current",
- "voice": "female",
- "language": "en-US",
- "client_state": "aGF2ZSBhIG5pY2UgZGF5ID1d",
- "command_id": "891510ac-f3e4-11e8-af5b-de00688a4901"
}
{- "result": "ok"
}
Transfer a call to a new destination. If the transfer is unsuccessful, a 'call_hangup' webhook will be sent indicating that the transfer could not be completed. The original call will remain active and may be issued additional commands, potentially transfering the call to an alternate destination.
Expected Webhooks:
answering_machine_detection
set to detect
, greeting_end
or detect_words
.answering_machine_detection
set to greeting_end
or detect_words
and machine
detected initially.{- "from": "+35319605860",
- "timeout": 60,
- "time_limit": 600,
- "answering_machine_detection": "detect",
- "answering_machine_detection_config": {
- "total_analysis_time_millis": 5000,
- "after_greeting_silence_millis": 1000,
- "between_words_silence_millis": 100,
- "greeting_duration_millis": 1500,
- "initial_silence_millis": 1800,
- "maximum_number_of_words": 3,
- "maximum_word_length_millis": 2000,
- "silence_threshold": 512,
- "greeting_total_analysis_time_millis": 7500,
- "greeting_silence_duration_millis": 2000
}, - "custom_headers": [
- {
- "name": "head_1",
- "value": "val_1"
}, - {
- "name": "head_2",
- "value": "val_2"
}
], - "client_state": "aGF2ZSBhIG5pY2UgZGF5ID1d",
- "target_leg_client_state": "aGF2ZSBhIG5pY2UgZGF5ID1d",
- "command_id": "891510ac-f3e4-11e8-af5b-de00688a4901",
- "sip_auth_username": "string",
- "sip_auth_password": "string"
}
{- "result": "ok"
}
Dial a number from a given connection. A successful response will include a call_leg_id
which can be used to correlate the command with subsequent webhooks.
Expected Webhooks:
answering_machine_detection
set to detect
, greeting_end
or detect_words
.answering_machine_detection
set to greeting_end
or detect_words
and machine
detected initially.{- "from": "+35319605860",
- "connection_id": "string",
- "timeout": 60,
- "time_limit": 600,
- "answering_machine_detection": "detect",
- "answering_machine_detection_config": {
- "total_analysis_time_millis": 5000,
- "after_greeting_silence_millis": 1000,
- "between_words_silence_millis": 100,
- "greeting_duration_millis": 1500,
- "initial_silence_millis": 1800,
- "maximum_number_of_words": 3,
- "maximum_word_length_millis": 2000,
- "silence_threshold": 512,
- "greeting_total_analysis_time_millis": 7500,
- "greeting_silence_duration_millis": 2000
}, - "custom_headers": [
- {
- "name": "head_1",
- "value": "val_1"
}, - {
- "name": "head_2",
- "value": "val_2"
}
], - "client_state": "aGF2ZSBhIG5pY2UgZGF5ID1d",
- "command_id": "891510ac-f3e4-11e8-af5b-de00688a4901",
- "link_to": "ilditnZK_eVysupV21KzmzN_sM29ygfauQojpm4BgFtfX5hXAcjotg==",
- "sip_auth_username": "string",
- "sip_auth_password": "string"
}
{- "result": "ok"
}