Sending Commands

A Call Control command is sent with a call_control_id. The call_control_id allows a user to communicate to Telnyx the call_leg the user wants to control. It also helps Telnyx route the call to the location where the call is being managed, resulting in the lowest possible latency for Call Control interactions.

Authentication

To send a Call Control command from your application, you must authenticate your request by sending the Authorization header with a value of a key:secret pair. A key and secret can be retrieved from Auth in the Mission Control Portal under the tab Auth v1, or via the Telnyx API.

Credential Type HTTP Header Format
Key + Secret Authorization: Basic base64("<key>:<secret>")

Example: Sending Commands With a Key + Secret

To answer the call, send a POST request to the /actions/answer endpoint as shown in the example below.

Copy
Copied
curl -X POST \
  -u <key>:<secret> \
  https://api.telnyx.com/calls/428c31b6-7af4-4bcb-b7f5-5013ef9657c1/actions/answer

Note: After pasting the above content, Kindly check and remove any new line added

Available Commands and their Expected Webhooks

Telnyx offers a broad range of commands to enable granular control of your call flows. Below are a list of those commands, and the webhooks the Telnyx Call Control platform will always send in response. When multiple webhooks are listed, you can expect to often, though not always, receive webhooks in the order provided.

Command Expected Webhooks
Answer call Call_answered
Bridge call Call_bridged for Leg A
Copy
Copied
    Call_bridged for Leg B
  </td>
</tr>
<tr>
  <td>Dial</td>
  <td>
    Call_initiated

    You will receive either a Call_answered webhook or a Call_hangup webhook.
  </td>
</tr>
<tr>
  <td>Forking start</td>
  <td>There are no webhooks associated with this command.</td>
</tr>
<tr>
  <td>Forking stop</td>
  <td>There are no webhooks associated with this command.</td>
</tr>
<tr>
  <td>Gather using audio</td>
  <td>
  Playback_started

  Playback_ended

  DTMF (you may receive many of these webhooks)

  Gather ended
  </td>
</tr>
<tr>
  <td>Gather using speak</td>
  <td>
  DTMF (you may receive many of these webhooks)

  Gather ended
  </td>
</tr>
<tr>
  <td>Hangup</td>
  <td>Call hangup

    Recording saved (Only applies if the call is being recorded)</td>
 <tr>
  <td>Play audio url       </td>
  <td>
  Playback_started

  Playback_ended</td>
</tr>
<tr>
  <td>Playback stop command</td>
  <td> You will either receive a Playback_ended webhook or a Speak ended webhook</td>
</tr>
<tr>
  <td>Recording start         </td>
  <td>There are no webhooks associated with this command.</td>
</tr>
<tr>
  <td>Recording stop            </td>
  <td>Recording saved</td>
</tr>
<tr>
  <td>Reject call</td>
  <td>Call hangup</td>
</tr>
<tr>
  <td>Send DTMF</td>
  <td>There are no webhooks associated with this command.</td>
</tr>
<tr>
  <td>Speak text</td>
  <td>
  Speak started

  Speak ended</td>
</tr>
<tr>
  <td>Transfer call</td>
  <td>
    Call initiated

    Call_bridged for Leg B

   You will receive either a Call_answered webhook or a Call_hangup webhook.
  </td>
</tr>

Response when Sending Commands

When you send a Call Control Command, you will immediately receive an http response. Responses include, but are not limited to:

HTTP Status Code Message Description
200 OK The request succeeded.
403 Forbidden The request was valid, however the user is not authorized to perform this action.
404 Not Found The requested resource could not be found.
422 Invalid Parameters The request has invalid parameters or the call is no longer active.