Ai telnyx-whatsapp-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-whatsapp-curl" ~/.claude/skills/team-telnyx-ai-telnyx-whatsapp-curl-778015 && rm -rf "$T"
providers/cursor/plugin/skills/telnyx-whatsapp-curl/SKILL.mdTelnyx WhatsApp Business API - 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:
curl \ -X POST \ -H "Authorization: Bearer $TELNYX_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "from": "+19452940762", "to": "+18005551234", "type": "WHATSAPP", "whatsapp_message": { "type": "text", "text": { "body": "Hello from Telnyx!" } } }' \ "https://api.telnyx.com/v2/messages/whatsapp"
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).
WhatsApp-Specific Errors
- 40008 — Meta catch-all error. Check template parameters, phone number formatting, and 24-hour window rules.
- 131047 — Message failed to send during the 24-hour window. The customer hasn't messaged you first (for non-template messages).
- 131026 — Recipient phone number is not a WhatsApp user.
- 132000 — Template parameter count mismatch. Ensure the number of parameters matches the template definition.
- 132015 — Template paused or disabled by Meta due to quality issues.
Important Notes
- Phone numbers must be in E.164 format (e.g.,
). Include the+13125550001
prefix and country code.+ - Template messages can be sent anytime. Free-form (session) messages can only be sent within a 24-hour window after the customer last messaged you.
- Template IDs: You can reference templates by Telnyx UUID (
) instead oftemplate_id
+name
. Whenlanguage
is provided, name and language are resolved automatically.template_id - Billing types: Template messages are billed as
,whatsapp_marketing
,whatsapp_utility
, orwhatsapp_authentication
based on category and destination.whatsapp_authentication_international
Operational Caveats
- The sending phone number must be registered with a WhatsApp Business Account (WABA) and associated with a messaging profile.
- Templates must be in
status before they can be used for sending.APPROVED - Template names must be lowercase with underscores only (e.g.,
). No spaces, hyphens, or uppercase.order_confirmation - When creating templates, provide realistic sample values for body parameters — Meta reviewers check these during approval.
- Category selection matters for billing:
templates get special pricing but must contain an OTP.AUTHENTICATION
is for transactional messages.UTILITY
for promotional content.MARKETING - Meta may reclassify your template category (e.g., UTILITY to MARKETING) which affects billing.
Reference Use Rules
Do not invent Telnyx parameters, enums, response fields, or webhook fields.
- If the parameter, enum, or response field you need is not shown inline in this skill, read references/api-details.md before writing code.
- Before using any operation in
, read the optional-parameters section and the response-schemas section.## Additional Operations - Before reading or matching webhook fields beyond the inline examples, read the webhook payload reference.
Core Tasks
Send a WhatsApp template message
Send a pre-approved template message. Templates can be sent anytime — no 24-hour window restriction.
POST /messages/whatsapp
| Parameter | Type | Required | Description |
|---|---|---|---|
| string (E.164) | Yes | WhatsApp-enabled phone number in +E.164 format |
| string (E.164) | Yes | Recipient phone number in +E.164 format |
| string | No | Must be |
| string | Yes | Must be |
| string | Yes* | Template name (e.g., ) |
| string | Yes* | Language code (e.g., ) |
| string (UUID) | No | Telnyx template UUID. If provided, and are resolved from DB |
| array | No | Template parameter values |
| string (UUID) | No | Messaging profile to use |
| string (URL) | No | Callback URL for delivery status updates |
*Required unless
template_id is provided.
# Send by template name + language curl \ -X POST \ -H "Authorization: Bearer $TELNYX_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "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" } ] } ] } } }' \ "https://api.telnyx.com/v2/messages/whatsapp"
# Send by Telnyx template_id (no name/language needed) curl \ -X POST \ -H "Authorization: Bearer $TELNYX_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "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" } ] } ] } } }' \ "https://api.telnyx.com/v2/messages/whatsapp"
Primary response fields:
— Message UUID.data.id
—.data.to[0].status
,queued
,sent
,deliveredfailed.data.from.phone_number
—.data.typeWHATSAPP
Send a free-form WhatsApp text message
Send a text message within the 24-hour customer service window (customer must have messaged you first).
POST /messages/whatsapp
| Parameter | Type | Required | Description |
|---|---|---|---|
| string (E.164) | Yes | WhatsApp-enabled phone number |
| string (E.164) | Yes | Recipient phone number |
| string | Yes | |
| string | Yes | Message content |
curl \ -X POST \ -H "Authorization: Bearer $TELNYX_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "from": "+19452940762", "to": "+18005551234", "type": "WHATSAPP", "whatsapp_message": { "type": "text", "text": { "body": "Your order has shipped!" } } }' \ "https://api.telnyx.com/v2/messages/whatsapp"
List WhatsApp Business Accounts
Retrieve all WABAs associated with your Telnyx account.
GET /v2/whatsapp/business_accounts
| Parameter | Type | Required | Description |
|---|---|---|---|
| integer | No | Page number (default: 1) |
| integer | No | Page size (default: 20) |
curl \ -H "Authorization: Bearer $TELNYX_API_KEY" \ "https://api.telnyx.com/v2/whatsapp/business_accounts"
Primary response fields:
— Telnyx WABA UUID.data[].id
— Meta WABA ID.data[].waba_id
— Business name.data[].name
— Account status.data[].status
— WABA country.data[].country
List templates
Retrieve message templates, optionally filtered by WABA.
GET /v2/whatsapp/message_templates
| Parameter | Type | Required | Description |
|---|---|---|---|
| string (UUID) | No | Filter by Telnyx WABA UUID (query parameter) |
| string | No | Filter by category: , , |
| string | No | Filter by status: , , , |
| integer | No | Page number |
| integer | No | Page size |
curl \ -H "Authorization: Bearer $TELNYX_API_KEY" \ "https://api.telnyx.com/v2/whatsapp/message_templates?waba_id=019c1ff0-5c30-7f36-8436-730b1d0b0e56&status=APPROVED"
Primary response fields:
— Telnyx template UUID (use this as.data[].id
when sending)template_id
— Template name.data[].name
—.data[].category
,AUTHENTICATION
, orMARKETINGUTILITY
— Language code (e.g.,.data[].language
)en_US
—.data[].status
,APPROVED
,PENDING
,REJECTEDDISABLED
— Template components (header, body, footer, buttons).data[].components
Create a message template
Submit a new template for Meta review. Templates typically take minutes to hours for approval.
POST /v2/whatsapp/message_templates
| Parameter | Type | Required | Description |
|---|---|---|---|
| string (UUID) | Yes | Telnyx WABA UUID (body parameter) |
| string | Yes | Lowercase with underscores only (e.g., ) |
| string | Yes | , , or |
| string | Yes | Language code (e.g., ) |
| array | Yes | Template components |
curl \ -X POST \ -H "Authorization: Bearer $TELNYX_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "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"]] } } ] }' \ "https://api.telnyx.com/v2/whatsapp/message_templates"
Primary response fields:
— Telnyx template UUID.data.id
— Template name.data.name
— Initially.data.status
until Meta approvesPENDING
List phone numbers
GET /v2/whatsapp/phone_numbers
| Parameter | Type | Required | Description |
|---|---|---|---|
| string (UUID) | No | Filter by Telnyx WABA UUID (query parameter) |
curl \ -H "Authorization: Bearer $TELNYX_API_KEY" \ "https://api.telnyx.com/v2/whatsapp/phone_numbers?waba_id=019c1ff0-5c30-7f36-8436-730b1d0b0e56"
Primary response fields:
— Phone number in E.164 format.data[].phone_number
— Meta phone number ID.data[].number_id
—.data[].quality_rating
,GREEN
, orYELLOWRED
— Current messaging tier.data[].messaging_limit_tier
Webhook Verification
Telnyx signs webhooks with Ed25519. Each request includes
telnyx-signature-ed25519
and telnyx-timestamp headers. Always verify signatures in production.
Webhooks
These webhook payload fields are inline because they are part of the primary integration path.
Message Delivery Update
| Field | Type | Description |
|---|---|---|
| enum: message.sent, message.finalized | Delivery status event |
| uuid | Message ID |
| string | , , , , |
| string | Telnyx template UUID (if template message) |
| string | Template name (if template message) |
| object | Cost information |
| array | Error details if failed |
Template Status Change
Configure webhook events on your WABA to receive template lifecycle notifications.
| Field | Type | Description |
|---|---|---|
| string | , , |
| string | Telnyx template UUID |
| string | Template name |
| string | New template status |
| string | Rejection/disable reason (if applicable) |
| string | WABA ID |
Phone Number Quality Change
| Field | Type | Description |
|---|---|---|
| string | |
| string | Phone number in E.164 format |
| string | Previous rating (GREEN, YELLOW, RED) |
| string | New rating |
Template Best Practices
- Naming: Use lowercase with underscores. Be descriptive (e.g.,
, notappointment_reminder
).msg1 - Sample values: Provide realistic examples in the
field — Meta reviewers check these.example - Category selection:
— OTP/verification codes only. Gets special pricing.AUTHENTICATION
— Transactional (order updates, shipping, account alerts).UTILITY
— Promotional content, offers, newsletters.MARKETING
- Keep it concise: Meta prefers shorter templates. Avoid unnecessary formatting.
- Avoid prohibited content: No misleading claims, prohibited products, or URL shorteners in template body.
- Parameters: Use
,{{1}}
, etc. for variable content. Always provide the correct number of parameters when sending.{{2}}
Important Supporting Operations
| Operation | Endpoint | Use Case |
|---|---|---|
| Get template details | | Check template status, view components |
| Get business profile | | View business display name, photo, description |
| Configure WABA settings | | Subscribe to template/account events |
Additional Operations
| Operation | Method | Endpoint | Use Case | Required Params |
|---|---|---|---|---|
| Send WhatsApp message | POST | | Send template or free-form message | , , |
| List WABAs | GET | | List all business accounts | — |
| Get WABA | GET | | Get WABA details | |
| List templates | GET | | List templates with filtering | — |
| Get template | GET | | Get template details | |
| Create template | POST | | Create new template | , , , , |
| List phone numbers | GET | | List WABA phone numbers | — |
| Get business profile | GET | | View profile info | |
| Update business profile | PATCH | | Update profile info | |
| Get WABA settings | GET | | View WABA settings/webhook config | |
| Update WABA settings | PATCH | | Set webhook URL and events | |