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.
中文简介正在准备中。当前显示原文说明。
Send WhatsApp messages, manage templates, WABAs, and phone numbers via the Telnyx WhatsApp Business API.
中文简介正在准备中。当前显示原文说明。
查看安装方法安装前可以查看交给 AI 代理的指令内容。
pip install telnyx
import os
from telnyx import Telnyx
client = Telnyx(
api_key=os.environ.get("TELNYX_API_KEY"),
)
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.messages.send_whatsapp(
from_="+19452940762",
to="+18005551234",
type_="WHATSAPP",
whatsapp_message={
"type": "text",
"text": {"body": "Hello from Telnyx!"}
},
)
except telnyx.APIError as e:
print(f"API error: {e.status_code} - {e.message}")
except telnyx.AuthenticationError:
print("Invalid API key")
except telnyx.RateLimitError:
print("Rate limited - retry with backoff")
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.template_id) instead of name + language. When template_id is provided, name and language are resolved automatically.for item in response.auto_paging_iter().APPROVED status before they can be used for sending.order_confirmation). No spaces, hyphens, or uppercase.AUTHENTICATION templates get special pricing but must contain an OTP. UTILITY is for transactional messages. MARKETING for promotional content.Do not invent Telnyx parameters, enums, response fields, or webhook fields.
## Additional Operations, read the optional-parameters section and the response-schemas section.Send a pre-approved template message. Templates can be sent anytime — no 24-hour window restriction.
client.messages.send_whatsapp() — POST /messages/whatsapp
| Parameter | Type | Required | Description |
|---|---|---|---|
from_ | string (E.164) | Yes | WhatsApp-enabled phone number in +E.164 format |
to | string (E.164) | Yes | Recipient phone number in +E.164 format |
type_ | string | No | Must be WHATSAPP |
whatsapp_message | object | Yes | WhatsApp message object |
messaging_profile_id | string (UUID) | No | Messaging profile to use |
webhook_url | string (URL) | No | Callback URL for delivery status updates |
# Send by template name + language
response = client.messages.send_whatsapp(
from_="+19452940762",
to="+18005551234",
type_="WHATSAPP",
whatsapp_message={
"type": "template",
"template": {
"name": "order_confirmation",
"language": {"code": "en_US"},
"components": [
{
"type": "body",
"parameters": [
{"type": "text", "text": "ORD-12345"},
{"type": "text", "text": "March 15, 2026"},
],
}
],
},
},
)
print(response.data.id)
# Send by Telnyx template_id (no name/language needed)
response = client.messages.send_whatsapp(
from_="+19452940762",
to="+18005551234",
type_="WHATSAPP",
whatsapp_message={
"type": "template",
"template": {
"template_id": "019cd44b-3a1c-781b-956e-bd33e9fd2ac6",
"components": [
{
"type": "body",
"parameters": [{"type": "text", "text": "483291"}],
}
],
},
},
)
Primary response fields:
response.data.id — Message UUIDresponse.data.to[0].status — queued, sent, delivered, failedresponse.data.from_.phone_numberresponse.data.type — WHATSAPPSend a text message within the 24-hour customer service window.
client.messages.send_whatsapp() — POST /messages/whatsapp
response = client.messages.send_whatsapp(
from_="+19452940762",
to="+18005551234",
type_="WHATSAPP",
whatsapp_message={
"type": "text",
"text": {"body": "Your order has shipped!"},
},
)
client.whatsapp.business_accounts.list() — GET /v2/whatsapp/business_accounts
response = client.whatsapp.business_accounts.list()
for waba in response.data:
print(f"{waba.id}: {waba.name} ({waba.status})")
Primary response fields:
waba.id — Telnyx WABA UUIDwaba.waba_id — Meta WABA IDwaba.name — Business namewaba.status — Account statuswaba.country — WABA countryclient.whatsapp.templates.list() — GET /v2/whatsapp/message_templates
| Parameter | Type | Required | Description |
|---|---|---|---|
waba_id | string (UUID) | No | Filter by Telnyx WABA UUID (query parameter) |
category | string | No | Filter: AUTHENTICATION, MARKETING, UTILITY |
status | string | No | Filter: APPROVED, PENDING, REJECTED, DISABLED |
response = client.whatsapp.templates.list(
waba_id="019c1ff0-5c30-7f36-8436-730b1d0b0e56",
status="APPROVED",
)
for tmpl in response.data:
print(f"{tmpl.id}: {tmpl.name} ({tmpl.category}) - {tmpl.status}")
Primary response fields:
tmpl.id — Telnyx template UUID (use as template_id when sending)tmpl.name — Template nametmpl.category — AUTHENTICATION, MARKETING, or UTILITYtmpl.language — Language codetmpl.status — APPROVED, PENDING, REJECTED, DISABLEDtmpl.components — Template componentsclient.whatsapp.templates.create() — POST /v2/whatsapp/message_templates
response = client.whatsapp.templates.create(
waba_id="019c1ff0-5c30-7f36-8436-730b1d0b0e56",
name="order_shipped",
category="UTILITY",
language="en_US",
components=[
{
"type": "BODY",
"text": "Your order {{1}} has been shipped and will arrive by {{2}}.",
"example": {
"body_text": [["ORD-12345", "March 20, 2026"]]
},
}
],
)
print(f"Template created: {response.data.id} (status: {response.data.status})")
client.whatsapp.phone_numbers.list() — GET /v2/whatsapp/phone_numbers
response = client.whatsapp.phone_numbers.list(
waba_id="019c1ff0-5c30-7f36-8436-730b1d0b0e56",
)
for pn in response.data:
print(f"{pn.phone_number} - quality: {pn.quality_rating}")
Telnyx signs webhooks with Ed25519. Always verify signatures in production:
from telnyx.webhooks import Webhook
event = Webhook.construct_event(
payload=request.body,
sig_header=request.headers["telnyx-signature-ed25519"],
timestamp=request.headers["telnyx-timestamp"],
public_key=TELNYX_PUBLIC_KEY,
)
These webhook payload fields are inline because they are part of the primary integration path.
| Field | Type | Description |
|---|---|---|
data.event_type | enum: message.sent, message.finalized | Delivery status event |
data.payload.id | uuid | Message ID |
data.payload.to[0].status | string | queued, sent, delivered, read, failed |
data.payload.template_id | string | Telnyx template UUID (if template message) |
data.payload.template_name | string | Template name (if template message) |
| Field | Type | Description |
|---|---|---|
event_type | string | whatsapp.template.approved, whatsapp.template.rejected, whatsapp.template.disabled |
payload.template_id | string | Telnyx template UUID |
payload.template_name | string | Template name |
payload.status | string | New template status |
payload.reason | string | Rejection/disable reason |
appointment_reminder, not msg1).example field — Meta reviewers check these.AUTHENTICATION — OTP/verification codes only. Gets special pricing.UTILITY — Transactional (order updates, shipping, account alerts).MARKETING — Promotional content, offers, newsletters.{{1}}, {{2}}, etc. for variable content. Always provide the correct number of parameters when sending.| Operation | SDK Method | Use Case |
|---|---|---|
| Get template details | client.whatsapp_message_templates.retrieve() | Check template status |
| Get business profile | client.whatsapp.phone_numbers.profile.retrieve() | View business profile |
| Update WABA settings | client.whatsapp.business_accounts.settings.update() | Configure webhook URL and events |
| Operation | SDK Method | Endpoint | Required Params |
|---|---|---|---|
| Send WhatsApp message | client.messages.send_whatsapp() | POST /messages/whatsapp | from_, to, whatsapp_message |
| List WABAs | client.whatsapp.business_accounts.list() | GET /v2/whatsapp/business_accounts | — |
| Get WABA | client.whatsapp.business_accounts.retrieve() | GET /v2/whatsapp/business_accounts/{id} | waba_id |
| List templates | client.whatsapp.templates.list() | GET /v2/whatsapp/message_templates | — |
| Get template | client.whatsapp_message_templates.retrieve() | GET /v2/whatsapp_message_templates/{id} | template_id |
| Create template | client.whatsapp.templates.create() | POST /v2/whatsapp/message_templates | waba_id, name, category, language, components |
| List phone numbers | client.whatsapp.phone_numbers.list() | GET /v2/whatsapp/phone_numbers | — |
| Get WABA settings | client.whatsapp.business_accounts.settings.retrieve() | GET /v2/whatsapp/business_accounts/{id}/settings | waba_id |
| Update WABA settings | client.whatsapp.business_accounts.settings.update() | PATCH /v2/whatsapp/business_accounts/{id}/settings | waba_id |
还没有评价。欢迎分享你的使用感受。
无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。
还没有评论。来写第一条吧。
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.
中文简介正在准备中。当前显示原文说明。