Ai telnyx-voice-advanced-curl
git clone https://github.com/team-telnyx/ai
T=$(mktemp -d) && git clone --depth=1 https://github.com/team-telnyx/ai "$T" && mkdir -p ~/.claude/skills && cp -r "$T/providers/cursor/plugin/skills/telnyx-voice-advanced-curl" ~/.claude/skills/team-telnyx-ai-telnyx-voice-advanced-curl-87ac65 && rm -rf "$T"
providers/cursor/plugin/skills/telnyx-voice-advanced-curl/SKILL.mdTelnyx Voice Advanced - curl
Installation
# curl is pre-installed on macOS, Linux, and Windows 10+
Setup
export TELNYX_API_KEY="YOUR_API_KEY_HERE"
All examples below use
$TELNYX_API_KEY for authentication.
Error Handling
All API calls can fail with network errors, rate limits (429), validation errors (422), or authentication errors (401). Always handle errors in production code:
# Check HTTP status code in response response=$(curl -s -w "\n%{http_code}" \ -X POST "https://api.telnyx.com/v2/messages" \ -H "Authorization: Bearer $TELNYX_API_KEY" \ -H "Content-Type: application/json" \ -d '{"to": "+13125550001", "from": "+13125550002", "text": "Hello"}') http_code=$(echo "$response" | tail -1) body=$(echo "$response" | sed '$d') case $http_code in 2*) echo "Success: $body" ;; 422) echo "Validation error — check required fields and formats" ;; 429) echo "Rate limited — retry after delay"; sleep 1 ;; 401) echo "Authentication failed — check TELNYX_API_KEY" ;; *) echo "Error $http_code: $body" ;; esac
Common error codes:
401 invalid API key, 403 insufficient permissions,
404 resource not found, 422 validation error (check field formats),
429 rate limited (retry with exponential backoff).
Join AI Assistant Conversation
Add a participant to an existing AI assistant conversation. Use this command to bring an additional call leg into a running AI conversation.
POST /calls/{call_control_id}/actions/ai_assistant_join — Required: conversation_id, participant
Optional:
client_state (string), command_id (string)
curl \ -X POST \ -H "Authorization: Bearer $TELNYX_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "conversation_id": "v3:abc123", "participant": {} }' \ "https://api.telnyx.com/v2/calls/v3:550e8400-e29b-41d4-a716-446655440000_gRU1OGRkYQ/actions/ai_assistant_join"
Returns:
conversation_id (uuid), result (string)
Update client state
Updates client state
PUT /calls/{call_control_id}/actions/client_state_update — Required: client_state
curl \ -X PUT \ -H "Authorization: Bearer $TELNYX_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "client_state": "aGF2ZSBhIG5pY2UgZGF5ID1d" }' \ "https://api.telnyx.com/v2/calls/v3:550e8400-e29b-41d4-a716-446655440000_gRU1OGRkYQ/actions/client_state_update"
Returns:
result (string)
Send DTMF
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.
POST /calls/{call_control_id}/actions/send_dtmf — Required: digits
Optional:
client_state (string), command_id (string), duration_millis (int32)
curl \ -X POST \ -H "Authorization: Bearer $TELNYX_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "digits": "1www2WABCDw9" }' \ "https://api.telnyx.com/v2/calls/v3:550e8400-e29b-41d4-a716-446655440000_gRU1OGRkYQ/actions/send_dtmf"
Returns:
result (string)
SIPREC start
Start siprec session to configured in SIPREC connector SRS.
Expected Webhooks:
siprec.startedsiprec.stoppedsiprec.failed
POST /calls/{call_control_id}/actions/siprec_start
Optional:
client_state (string), connector_name (string), include_metadata_custom_headers (boolean), secure (boolean), session_timeout_secs (integer), sip_transport (enum: udp, tcp, tls), siprec_track (enum: inbound_track, outbound_track, both_tracks)
curl \ -X POST \ -H "Authorization: Bearer $TELNYX_API_KEY" \ -H "Content-Type: application/json" \ "https://api.telnyx.com/v2/calls/v3:550e8400-e29b-41d4-a716-446655440000_gRU1OGRkYQ/actions/siprec_start"
Returns:
result (string)
SIPREC stop
Stop SIPREC session. Expected Webhooks:
siprec.stopped
POST /calls/{call_control_id}/actions/siprec_stop
Optional:
client_state (string), command_id (string)
curl \ -X POST \ -H "Authorization: Bearer $TELNYX_API_KEY" \ -H "Content-Type: application/json" \ "https://api.telnyx.com/v2/calls/v3:550e8400-e29b-41d4-a716-446655440000_gRU1OGRkYQ/actions/siprec_stop"
Returns:
result (string)
Noise Suppression Start (BETA)
POST /calls/{call_control_id}/actions/suppression_start
Optional:
client_state (string), command_id (string), direction (enum: inbound, outbound, both), noise_suppression_engine (enum: Denoiser, DeepFilterNet, Krisp, AiCoustics), noise_suppression_engine_config (object)
curl \ -X POST \ -H "Authorization: Bearer $TELNYX_API_KEY" \ -H "Content-Type: application/json" \ "https://api.telnyx.com/v2/calls/v3:550e8400-e29b-41d4-a716-446655440000_gRU1OGRkYQ/actions/suppression_start"
Returns:
result (string)
Noise Suppression Stop (BETA)
POST /calls/{call_control_id}/actions/suppression_stop
Optional:
client_state (string), command_id (string)
curl \ -X POST \ -H "Authorization: Bearer $TELNYX_API_KEY" \ -H "Content-Type: application/json" \ "https://api.telnyx.com/v2/calls/v3:550e8400-e29b-41d4-a716-446655440000_gRU1OGRkYQ/actions/suppression_stop"
Returns:
result (string)
Switch supervisor role
Switch the supervisor role for a bridged call. This allows switching between different supervisor modes during an active call
POST /calls/{call_control_id}/actions/switch_supervisor_role — Required: role
curl \ -X POST \ -H "Authorization: Bearer $TELNYX_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "role": "barge" }' \ "https://api.telnyx.com/v2/calls/v3:550e8400-e29b-41d4-a716-446655440000_gRU1OGRkYQ/actions/switch_supervisor_role"
Returns:
result (string)
Webhooks
Webhook Verification
Telnyx signs webhooks with Ed25519. Each request includes
telnyx-signature-ed25519
and telnyx-timestamp headers. Always verify signatures in production:
# Telnyx signs webhooks with Ed25519 (asymmetric — NOT HMAC/Standard Webhooks). # Headers sent with each webhook: # telnyx-signature-ed25519: base64-encoded Ed25519 signature # telnyx-timestamp: Unix timestamp (reject if >5 minutes old for replay protection) # # Get your public key from: Telnyx Portal > Account Settings > Keys & Credentials # Use the Telnyx SDK in your language for verification (client.webhooks.unwrap). # Your endpoint MUST return 2xx within 2 seconds or Telnyx will retry (up to 3 attempts). # Configure a failover URL in Telnyx Portal for additional reliability.
The following webhook events are sent to your configured webhook URL. All webhooks include
telnyx-timestamp and telnyx-signature-ed25519 headers for Ed25519 signature verification. Use client.webhooks.unwrap() to verify.
| Event | Description |
|---|---|
| Call Conversation Ended |
| Call Conversation Insights Generated |
| Call Dtmf Received |
| Call Machine Detection Ended |
| Call Machine Greeting Ended |
| Call Machine Premium Detection Ended |
| Call Machine Premium Greeting Ended |
| Call Refer Completed |
| Call Refer Failed |
| Call Refer Started |
| Call Siprec Failed |
| Call Siprec Started |
| Call Siprec Stopped |
Webhook payload fields
callConversationEnded
| Field | Type | Description |
|---|---|---|
| enum: event | Identifies the type of the resource. |
| enum: call.conversation.ended | The type of event being delivered. |
| uuid | Unique identifier for the event. |
| date-time | ISO 8601 datetime of when the event occurred. |
| date-time | Timestamp when the event was created in the system. |
| string | Unique identifier of the assistant involved in the call. |
| string | Call ID used to issue commands via Call Control API. |
| string | Call Control App ID (formerly Telnyx connection ID) used in the call. |
| string | ID that is unique to the call leg. |
| string | ID that is unique to the call session (group of related call legs). |
| string | Base64-encoded state received from a command. |
| enum: pstn, sip | The type of calling party connection. |
| string | ID unique to the conversation or insight group generated for the call. |
| integer | Duration of the conversation in seconds. |
| string | The caller's number or identifier. |
| string | The callee's number or SIP address. |
| string | The large language model used during the conversation. |
| string | The speech-to-text model used in the conversation. |
| string | The text-to-speech provider used in the call. |
| string | The model ID used for text-to-speech synthesis. |
| string | Voice ID used for TTS. |
callConversationInsightsGenerated
| Field | Type | Description |
|---|---|---|
| enum: event | Identifies the type of the resource. |
| enum: call.conversation_insights.generated | The type of event being delivered. |
| uuid | Identifies the type of resource. |
| date-time | ISO 8601 datetime of when the event occurred. |
| string | Call ID used to issue commands via Call Control API. |
| string | Call Control App ID (formerly Telnyx connection ID) used in the call. |
| string | ID that is unique to the call and can be used to correlate webhook events. |
| string | ID that is unique to the call session and can be used to correlate webhook events. |
| string | State received from a command. |
| enum: pstn, sip | The type of calling party connection. |
| string | ID that is unique to the insight group being generated for the call. |
| array[object] | Array of insight results being generated for the call. |
callDtmfReceived
| Field | Type | Description |
|---|---|---|
| enum: event | Identifies the type of the resource. |
| enum: call.dtmf.received | The type of event being delivered. |
| uuid | Identifies the type of resource. |
| date-time | ISO 8601 datetime of when the event occurred. |
| string | Call ID used to issue commands via Call Control API. |
| string | Identifies the type of resource. |
| string | ID that is unique to the call and can be used to correlate webhook events. |
| string | ID that is unique to the call session and can be used to correlate webhook events. |
| string | State received from a command. |
| string | Number or SIP URI placing the call. |
| string | Destination number or SIP URI of the call. |
| string | The received DTMF digit or symbol. |
callMachineDetectionEnded
| Field | Type | Description |
|---|---|---|
| enum: event | Identifies the type of the resource. |
| enum: call.machine.detection.ended | The type of event being delivered. |
| uuid | Identifies the type of resource. |
| date-time | ISO 8601 datetime of when the event occurred. |
| string | Call ID used to issue commands via Call Control API. |
| string | Call Control App ID (formerly Telnyx connection ID) used in the call. |
| string | ID that is unique to the call and can be used to correlate webhook events. |
| string | ID that is unique to the call session and can be used to correlate webhook events. |
| string | State received from a command. |
| string | Number or SIP URI placing the call. |
| string | Destination number or SIP URI of the call. |
| enum: human, machine, not_sure | Answering machine detection result. |
callMachineGreetingEnded
| Field | Type | Description |
|---|---|---|
| enum: event | Identifies the type of the resource. |
| enum: call.machine.greeting.ended | The type of event being delivered. |
| uuid | Identifies the type of resource. |
| date-time | ISO 8601 datetime of when the event occurred. |
| string | Call ID used to issue commands via Call Control API. |
| string | Call Control App ID (formerly Telnyx connection ID) used in the call. |
| string | ID that is unique to the call and can be used to correlate webhook events. |
| string | ID that is unique to the call session and can be used to correlate webhook events. |
| string | State received from a command. |
| string | Number or SIP URI placing the call. |
| string | Destination number or SIP URI of the call. |
| enum: beep_detected, ended, not_sure | Answering machine greeting ended result. |
callMachinePremiumDetectionEnded
| Field | Type | Description |
|---|---|---|
| enum: event | Identifies the type of the resource. |
| enum: call.machine.premium.detection.ended | The type of event being delivered. |
| uuid | Identifies the type of resource. |
| date-time | ISO 8601 datetime of when the event occurred. |
| string | Call ID used to issue commands via Call Control API. |
| string | Call Control App ID (formerly Telnyx connection ID) used in the call. |
| string | ID that is unique to the call and can be used to correlate webhook events. |
| string | ID that is unique to the call session and can be used to correlate webhook events. |
| string | State received from a command. |
| string | Number or SIP URI placing the call. |
| string | Destination number or SIP URI of the call. |
| enum: human_residence, human_business, machine, silence, fax_detected, not_sure | Premium Answering Machine Detection result. |
callMachinePremiumGreetingEnded
| Field | Type | Description |
|---|---|---|
| enum: event | Identifies the type of the resource. |
| enum: call.machine.premium.greeting.ended | The type of event being delivered. |
| uuid | Identifies the type of resource. |
| date-time | ISO 8601 datetime of when the event occurred. |
| string | Call ID used to issue commands via Call Control API. |
| string | Call Control App ID (formerly Telnyx connection ID) used in the call. |
| string | ID that is unique to the call and can be used to correlate webhook events. |
| string | ID that is unique to the call session and can be used to correlate webhook events. |
| string | State received from a command. |
| string | Number or SIP URI placing the call. |
| string | Destination number or SIP URI of the call. |
| enum: beep_detected, no_beep_detected | Premium Answering Machine Greeting Ended result. |
callReferCompleted
| Field | Type | Description |
|---|---|---|
| enum: event | Identifies the type of the resource. |
| enum: call.refer.completed | The type of event being delivered. |
| uuid | Identifies the type of resource. |
| date-time | ISO 8601 datetime of when the event occurred. |
| string | Unique ID for controlling the call. |
| string | ID that is unique to the call and can be used to correlate webhook events. |
| string | ID that is unique to the call session and can be used to correlate webhook events. |
| string | Call Control App ID (formerly Telnyx connection ID) used in the call. |
| string | State received from a command. |
| string | Number or SIP URI placing the call. |
| integer | SIP NOTIFY event status for tracking the REFER attempt. |
| string | Destination number or SIP URI of the call. |
callReferFailed
| Field | Type | Description |
|---|---|---|
| enum: event | Identifies the type of the resource. |
| enum: call.refer.failed | The type of event being delivered. |
| uuid | Identifies the type of resource. |
| date-time | ISO 8601 datetime of when the event occurred. |
| string | Unique ID for controlling the call. |
| string | ID that is unique to the call and can be used to correlate webhook events. |
| string | ID that is unique to the call session and can be used to correlate webhook events. |
| string | Call Control App ID (formerly Telnyx connection ID) used in the call. |
| string | State received from a command. |
| string | Number or SIP URI placing the call. |
| integer | SIP NOTIFY event status for tracking the REFER attempt. |
| string | Destination number or SIP URI of the call. |
callReferStarted
| Field | Type | Description |
|---|---|---|
| enum: event | Identifies the type of the resource. |
| enum: call.refer.started | The type of event being delivered. |
| uuid | Identifies the type of resource. |
| date-time | ISO 8601 datetime of when the event occurred. |
| string | Unique ID for controlling the call. |
| string | ID that is unique to the call and can be used to correlate webhook events. |
| string | ID that is unique to the call session and can be used to correlate webhook events. |
| string | Call Control App ID (formerly Telnyx connection ID) used in the call. |
| string | State received from a command. |
| string | Number or SIP URI placing the call. |
| integer | SIP NOTIFY event status for tracking the REFER attempt. |
| string | Destination number or SIP URI of the call. |
callSiprecFailed
| Field | Type | Description |
|---|---|---|
| enum: event | Identifies the resource. |
| enum: siprec.failed | The type of event being delivered. |
| uuid | Identifies the type of resource. |
| date-time | ISO 8601 datetime of when the event occurred. |
| string | Call ID used to issue commands via Call Control API. |
| string | Call Control App ID (formerly Telnyx connection ID) used in the call. |
| string | ID that is unique to the call and can be used to correlate webhook events. |
| string | ID that is unique to the call session and can be used to correlate webhook events. |
| string | State received from a command. |
| string | Q850 reason why siprec session failed. |
callSiprecStarted
| Field | Type | Description |
|---|---|---|
| enum: event | Identifies the type of the resource. |
| enum: siprec.started | The type of event being delivered. |
| uuid | Identifies the type of resource. |
| date-time | ISO 8601 datetime of when the event occurred. |
| string | Call ID used to issue commands via Call Control API. |
| string | Call Control App ID (formerly Telnyx connection ID) used in the call. |
| string | ID that is unique to the call and can be used to correlate webhook events. |
| string | ID that is unique to the call session and can be used to correlate webhook events. |
| string | State received from a command. |
callSiprecStopped
| Field | Type | Description |
|---|---|---|
| enum: event | Identifies the type of the resource. |
| enum: siprec.stopped | The type of event being delivered. |
| uuid | Identifies the type of resource. |
| date-time | ISO 8601 datetime of when the event occurred. |
| string | Call ID used to issue commands via Call Control API. |
| string | Call Control App ID (formerly Telnyx connection ID) used in the call. |
| string | ID that is unique to the call and can be used to correlate webhook events. |
| string | ID that is unique to the call session and can be used to correlate webhook events. |
| string | State received from a command. |
| string | Q850 reason why the SIPREC session was stopped. |