Test VoIP push notifications for Telnyx WebRTC iOS (APNs) and Android (FCM) apps. Use when debugging push notification delivery, validating certificate/credential setup, or testing that a device receives VoIP pushes correctly.
中文简介正在准备中。当前显示原文说明。
Programmatic call control: make/receive calls, transfer, bridge, gather DTMF, stream audio. Real-time call events via webhooks.
中文简介正在准备中。当前显示原文说明。
查看安装方法安装前可以查看交给 AI 代理的指令内容。
pip install telnyx
import os
from telnyx import Telnyx
client = Telnyx(
api_key=os.environ.get("TELNYX_API_KEY"), # This is the default and can be omitted
public_key=os.environ.get("TELNYX_PUBLIC_KEY"), # Required for client.webhooks.unwrap() (webhook verification)
)
All examples below assume client is already initialized as shown above.
All API calls can fail with network errors, rate limits (429), validation errors (422), or authentication errors (401). Always handle errors in production code:
import telnyx
try:
response = client.calls.dial(
connection_id="7267xxxxxxxxxxxxxx",
from_="+18005550101",
to="+18005550100",
)
except telnyx.APIConnectionError:
print("Network error — check connectivity and retry")
raise
except telnyx.RateLimitError:
# 429: rate limited — wait, then retry the request (bounded exponential backoff)
import time
time.sleep(1) # Check Retry-After header for actual delay
# ...retry the call here (give up after a few attempts); otherwise re-raise:
raise
except telnyx.APIStatusError as e:
print(f"API error {e.status_code}: {e.message}")
if e.status_code == 422:
print("Validation error — check required fields and formats")
raise # A failed request must never look like success to the caller
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).
+13125550001). Include the + prefix and country code. No spaces, dashes, or parentheses.for item in page_result: to iterate through all pages automatically.dial() or an inbound webhook, issue follow-up commands from webhook handlers using the call_control_id in the event payload.dial(), while inbound calls must be answered from the incoming webhook before other commands run.Do not invent Telnyx parameters, enums, response fields, or webhook fields.
## Additional Operations, read the optional-parameters section and the response-schemas section.Primary voice entrypoint. Agents need the async call-control identifiers returned here.
client.calls.dial() — POST /calls
| Parameter | Type | Required | Description |
|---|---|---|---|
to | string (E.164) | Yes | The DID or SIP URI to dial out to. |
from_ | string (E.164) | Yes | The from number to be used as the caller id presented to t... |
connection_id | string (UUID) | Yes | The ID of the Call Control App (formerly ID of the connectio... |
timeout_secs | integer | No | The number of seconds that Telnyx will wait for the call to ... |
billing_group_id | string (UUID) | No | Use this field to set the Billing Group ID for the call. |
client_state | string | No | Use this field to add state to every subsequent webhook. |
| ... | +59 optional params in references/api-details.md |
response = client.calls.dial(
connection_id="7267xxxxxxxxxxxxxx",
from_="+18005550101",
to="+18005550100",
)
print(response.data)
Primary response fields:
response.data.call_control_idresponse.data.call_leg_idresponse.data.call_session_idresponse.data.is_aliveresponse.data.recording_idresponse.data.call_durationPrimary inbound call-control command.
client.calls.actions.answer() — POST /calls/{call_control_id}/actions/answer
| Parameter | Type | Required | Description |
|---|---|---|---|
call_control_id | string (UUID) | Yes | Unique identifier and token for controlling the call |
billing_group_id | string (UUID) | No | Use this field to set the Billing Group ID for the call. |
client_state | string | No | Use this field to add state to every subsequent webhook. |
webhook_url | string (URL) | No | Use this field to override the URL for which Telnyx will sen... |
| ... | +29 optional params in references/api-details.md |
response = client.calls.actions.answer(
call_control_id="550e8400-e29b-41d4-a716-446655440000",
)
print(response.data)
Primary response fields:
response.data.resultresponse.data.recording_idCommon post-answer control path with downstream webhook implications.
client.calls.actions.transfer() — POST /calls/{call_control_id}/actions/transfer
| Parameter | Type | Required | Description |
|---|---|---|---|
to | string (E.164) | Yes | The DID or SIP URI to dial out to. |
call_control_id | string (UUID) | Yes | Unique identifier and token for controlling the call |
timeout_secs | integer | No | The number of seconds that Telnyx will wait for the call to ... |
client_state | string | No | Use this field to add state to every subsequent webhook. |
webhook_url | string (URL) | No | Use this field to override the URL for which Telnyx will sen... |
| ... | +37 optional params in references/api-details.md |
response = client.calls.actions.transfer(
call_control_id="550e8400-e29b-41d4-a716-446655440000",
to="+18005550100",
)
print(response.data)
Primary response fields:
response.data.resultTelnyx signs webhooks with Ed25519. Each request includes telnyx-signature-ed25519
and telnyx-timestamp headers. Always verify signatures in production:
Verification needs your account's public key (Mission Control Portal → API Keys → Public Key).
The SDK reads it from TELNYX_PUBLIC_KEY (the ## Setup block above passes it explicitly);
without it every valid webhook fails verification and the handler below returns 400.
# In your webhook handler (e.g., Flask — use raw body, not parsed JSON):
@app.route("/webhooks", methods=["POST"])
def handle_webhook():
payload = request.get_data(as_text=True) # raw body as string
headers = dict(request.headers)
try:
event = client.webhooks.unwrap(payload, headers=headers)
except Exception as e:
print(f"Webhook verification failed: {e}")
return "Invalid signature", 400
# Signature valid — event is the parsed webhook payload
print(f"Received event: {event.data.event_type}")
return "OK", 200
These webhook payload fields are inline because they are part of the primary integration path.
| Field | Type | Description |
|---|---|---|
data.record_type | enum: event | Identifies the type of the resource. |
data.event_type | enum: call.answered | The type of event being delivered. |
data.id | uuid | Identifies the type of resource. |
data.occurred_at | date-time | ISO 8601 datetime of when the event occurred. |
data.payload.call_control_id | string | Call ID used to issue commands via Call Control API. |
data.payload.connection_id | string | Call Control App ID (formerly Telnyx connection ID) used in the call. |
data.payload.call_leg_id | string | ID that is unique to the call and can be used to correlate webhook events. |
data.payload.call_session_id | string | ID that is unique to the call session and can be used to correlate webhook ev... |
| Field | Type | Description |
|---|---|---|
data.record_type | enum: event | Identifies the type of the resource. |
data.event_type | enum: call.hangup | The type of event being delivered. |
data.id | uuid | Identifies the type of resource. |
data.occurred_at | date-time | ISO 8601 datetime of when the event occurred. |
data.payload.call_control_id | string | Call ID used to issue commands via Call Control API. |
data.payload.connection_id | string | Call Control App ID (formerly Telnyx connection ID) used in the call. |
data.payload.call_leg_id | string | ID that is unique to the call and can be used to correlate webhook events. |
data.payload.call_session_id | string | ID that is unique to the call session and can be used to correlate webhook ev... |
| Field | Type | Description |
|---|---|---|
data.record_type | enum: event | Identifies the type of the resource. |
data.event_type | enum: call.initiated | The type of event being delivered. |
data.id | uuid | Identifies the type of resource. |
data.occurred_at | date-time | ISO 8601 datetime of when the event occurred. |
data.payload.call_control_id | string | Call ID used to issue commands via Call Control API. |
data.payload.connection_id | string | Call Control App ID (formerly Telnyx connection ID) used in the call. |
data.payload.connection_codecs | string | The list of comma-separated codecs enabled for the connection. |
data.payload.offered_codecs | string | The list of comma-separated codecs offered by caller. |
If you need webhook fields that are not listed inline here, read the webhook payload reference before writing the handler.
Use these when the core tasks above are close to your flow, but you need a common variation or follow-up step.
End a live call from your webhook-driven control flow.
client.calls.actions.hangup() — POST /calls/{call_control_id}/actions/hangup
| Parameter | Type | Required | Description |
|---|---|---|---|
call_control_id | string (UUID) | Yes | Unique identifier and token for controlling the call |
client_state | string | No | Use this field to add state to every subsequent webhook. |
command_id | string (UUID) | No | Use this field to avoid duplicate commands. |
custom_headers | array[object] | No | Custom headers to be added to the SIP BYE message. |
| ... | +1 optional params in references/api-details.md |
response = client.calls.actions.hangup(
call_control_id="550e8400-e29b-41d4-a716-446655440000",
)
print(response.data)
Primary response fields:
response.data.resultTrigger a follow-up action in an existing workflow rather than creating a new top-level resource.
client.calls.actions.bridge() — POST /calls/{call_control_id}/actions/bridge
| Parameter | Type | Required | Description |
|---|---|---|---|
call_control_id_to_bridge | string (UUID) | Yes | The Call Control ID of the call you want to bridge with, can... |
call_control_id | string (UUID) | Yes | Unique identifier and token for controlling the call |
client_state | string | No | Use this field to add state to every subsequent webhook. |
command_id | string (UUID) | No | Use this field to avoid duplicate commands. |
video_room_id | string (UUID) | No | The ID of the video room you want to bridge with, can't be u... |
| ... | +16 optional params in references/api-details.md |
response = client.calls.actions.bridge(
call_control_id_to_bridge="call_control_id",
call_control_id_to_bridge_with="v3:MdI91X4lWFEs7IgbBEOT9M4AigoY08M0WWZFISt1Yw2axZ_IiE4pqg",
)
print(response.data)
Primary response fields:
response.data.resultTrigger a follow-up action in an existing workflow rather than creating a new top-level resource.
client.calls.actions.reject() — POST /calls/{call_control_id}/actions/reject
| Parameter | Type | Required | Description |
|---|---|---|---|
cause | enum (CALL_REJECTED, NOT_FOUND, TEMPORARILY_UNAVAILABLE, USER_BUSY) | Yes | Cause for call rejection. |
call_control_id | string (UUID) | Yes | Unique identifier and token for controlling the call |
client_state | string | No | Use this field to add state to every subsequent webhook. |
command_id | string (UUID) | No | Use this field to avoid duplicate commands. |
response = client.calls.actions.reject(
call_control_id="550e8400-e29b-41d4-a716-446655440000",
cause="USER_BUSY",
)
print(response.data)
Primary response fields:
response.data.resultFetch the current state before updating, deleting, or making control-flow decisions.
client.calls.retrieve_status() — GET /calls/{call_control_id}
| Parameter | Type | Required | Description |
|---|---|---|---|
call_control_id | string (UUID) | Yes | Unique identifier and token for controlling the call |
response = client.calls.retrieve_status("v3:550e8400-e29b-41d4-a716-446655440000_gRU1OGRkYQ",
)
print(response.data)
Primary response fields:
response.data.call_control_idresponse.data.call_durationresponse.data.call_leg_idresponse.data.call_session_idresponse.data.client_stateresponse.data.end_timeFetch the current state before updating, deleting, or making control-flow decisions.
client.connections.list_active_calls() — GET /connections/{connection_id}/active_calls
| Parameter | Type | Required | Description |
|---|---|---|---|
connection_id | string (UUID) | Yes | Telnyx connection id |
page | object | No | Consolidated page parameter (deepObject style). |
page = client.connections.list_active_calls(
connection_id="1293384261075731461",
)
page = page.data[0]
print(page.call_control_id)
Response wrapper:
page.datapage.metaPrimary item fields:
call_control_idcall_durationcall_leg_idcall_session_idclient_staterecord_typeInspect available resources or choose an existing resource before mutating it.
client.call_control_applications.list() — GET /call_control_applications
| Parameter | Type | Required | Description |
|---|---|---|---|
sort | enum (created_at, connection_name, active) | No | Specifies the sort order for results. |
filter | object | No | Consolidated filter parameter (deepObject style). |
page | object | No | Consolidated page parameter (deepObject style). |
page = client.call_control_applications.list()
page = page.data[0]
print(page.id)
Response wrapper:
page.datapage.metaPrimary item fields:
idcreated_atupdated_atactiveanchorsite_overrideapplication_nameUse the core tasks above first. The operations below are indexed here with exact SDK methods and required params; use references/api-details.md for full optional params, response schemas, and lower-frequency webhook payloads. Before using any operation below, read the optional-parameters section and the response-schemas section so you do not guess missing fields.
| Operation | SDK method | Endpoint | Use when | Required params |
|---|---|---|---|---|
| Create a call control application | client.call_control_applications.create() | POST /call_control_applications | Create or provision an additional resource when the core tasks do not cover this flow. | application_name, webhook_event_url |
| Retrieve a call control application | client.call_control_applications.retrieve() | GET /call_control_applications/{id} | Fetch the current state before updating, deleting, or making control-flow decisions. | id |
| Update a call control application | client.call_control_applications.update() | PATCH /call_control_applications/{id} | Modify an existing resource without recreating it. | application_name, webhook_event_url, id |
| Delete a call control application | client.call_control_applications.delete() | DELETE /call_control_applications/{id} | Remove, detach, or clean up an existing resource. | id |
| SIP Refer a call | client.calls.actions.refer() | POST /calls/{call_control_id}/actions/refer | Trigger a follow-up action in an existing workflow rather than creating a new top-level resource. | sip_address, call_control_id |
| Send SIP info | client.calls.actions.send_sip_info() | POST /calls/{call_control_id}/actions/send_sip_info | Trigger a follow-up action in an existing workflow rather than creating a new top-level resource. | content_type, body, call_control_id |
| List dial metrics | client.dial_metrics.list() | GET /dial_metrics | Inspect available resources or choose an existing resource before mutating it. | None |
| Event | data.event_type | Description |
|---|---|---|
callBridged | call.bridged | Call Bridged |
For exhaustive optional parameters, full response schemas, and complete webhook payloads, see references/api-details.md.
还没有评价。欢迎分享你的使用感受。
无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。
还没有评论。来写第一条吧。
Test VoIP push notifications for Telnyx WebRTC iOS (APNs) and Android (FCM) apps. Use when debugging push notification delivery, validating certificate/credential setup, or testing that a device receives VoIP pushes correctly.
中文简介正在准备中。当前显示原文说明。
10DLC brand and campaign registration for US A2P messaging compliance. Assign phone numbers to campaigns.
中文简介正在准备中。当前显示原文说明。
10DLC brand and campaign registration for US A2P messaging compliance. Assign phone numbers to campaigns.
中文简介正在准备中。当前显示原文说明。
10DLC brand and campaign registration for US A2P messaging compliance. Assign phone numbers to campaigns.
中文简介正在准备中。当前显示原文说明。
10DLC brand and campaign registration for US A2P messaging compliance. Assign phone numbers to campaigns.
中文简介正在准备中。当前显示原文说明。
10DLC brand and campaign registration for US A2P messaging compliance. Assign phone numbers to campaigns.
中文简介正在准备中。当前显示原文说明。