$npx -y skills add team-telnyx/ai --skill telnyx-messaging-curlSend and receive SMS/MMS, handle opt-outs and delivery webhooks. Use for notifications, 2FA, or messaging apps.
| 1 | <!-- Auto-generated from Telnyx OpenAPI specs. Do not edit. --> |
| 2 | |
| 3 | # Telnyx Messaging - curl |
| 4 | |
| 5 | ## Installation |
| 6 | |
| 7 | ```text |
| 8 | # curl is pre-installed on macOS, Linux, and Windows 10+ |
| 9 | ``` |
| 10 | |
| 11 | ## Setup |
| 12 | |
| 13 | ```bash |
| 14 | export TELNYX_API_KEY="YOUR_API_KEY_HERE" |
| 15 | ``` |
| 16 | |
| 17 | All examples below use `$TELNYX_API_KEY` for authentication. |
| 18 | |
| 19 | ## Error Handling |
| 20 | |
| 21 | All API calls can fail with network errors, rate limits (429), validation errors (422), |
| 22 | or authentication errors (401). Always handle errors in production code: |
| 23 | |
| 24 | ```bash |
| 25 | curl \ |
| 26 | -X POST \ |
| 27 | -H "Authorization: Bearer $TELNYX_API_KEY" \ |
| 28 | -H "Content-Type: application/json" \ |
| 29 | -d '{ |
| 30 | "to": "+13125550001", |
| 31 | "from": "+18005550101", |
| 32 | "text": "Hello from Telnyx!" |
| 33 | }' \ |
| 34 | "https://api.telnyx.com/v2/messages" |
| 35 | ``` |
| 36 | |
| 37 | Common error codes: `401` invalid API key, `403` insufficient permissions, |
| 38 | `404` resource not found, `422` validation error (check field formats), |
| 39 | `429` rate limited (retry with exponential backoff). |
| 40 | |
| 41 | ## Important Notes |
| 42 | |
| 43 | - **Phone numbers** must be in E.164 format (e.g., `+13125550001`). Include the `+` prefix and country code. No spaces, dashes, or parentheses. |
| 44 | - **Pagination:** List endpoints return paginated results. Use `page[number]` and `page[size]` query parameters to navigate pages. Check `meta.total_pages` in the response. |
| 45 | |
| 46 | ## Operational Caveats |
| 47 | |
| 48 | - The sending number must already be assigned to the correct messaging profile before you send traffic from it. |
| 49 | - US A2P long-code traffic must complete 10DLC registration before production sending or carriers will block or heavily filter messages. |
| 50 | - Delivery webhooks are asynchronous. Treat the send response as acceptance of the request, not final carrier delivery. |
| 51 | |
| 52 | ## Reference Use Rules |
| 53 | |
| 54 | Do not invent Telnyx parameters, enums, response fields, or webhook fields. |
| 55 | |
| 56 | - If the parameter, enum, or response field you need is not shown inline in this skill, read [references/api-details.md](references/api-details.md) before writing code. |
| 57 | - Before using any operation in `## Additional Operations`, read [the optional-parameters section](references/api-details.md#optional-parameters) and [the response-schemas section](references/api-details.md#response-schemas). |
| 58 | - Before reading or matching webhook fields beyond the inline examples, read [the webhook payload reference](references/api-details.md#webhook-payload-fields). |
| 59 | |
| 60 | ## Core Tasks |
| 61 | |
| 62 | ### Send an SMS |
| 63 | |
| 64 | Primary outbound messaging flow. Agents need exact request fields and delivery-related response fields. |
| 65 | |
| 66 | `POST /messages` |
| 67 | |
| 68 | | Parameter | Type | Required | Description | |
| 69 | |-----------|------|----------|-------------| |
| 70 | | `to` | string (E.164) | Yes | Receiving address (+E.164 formatted phone number or short co... | |
| 71 | | `from` | string (E.164) | Yes | Sending address (+E.164 formatted phone number, alphanumeric... | |
| 72 | | `text` | string | Yes | Message body (i.e., content) as a non-empty string. | |
| 73 | | `messaging_profile_id` | string (UUID) | No | Unique identifier for a messaging profile. | |
| 74 | | `media_urls` | array[string] | No | A list of media URLs. | |
| 75 | | `webhook_url` | string (URL) | No | The URL where webhooks related to this message will be sent. | |
| 76 | | ... | | | +7 optional params in [references/api-details.md](references/api-details.md) | |
| 77 | |
| 78 | ```bash |
| 79 | curl \ |
| 80 | -X POST \ |
| 81 | -H "Authorization: Bearer $TELNYX_API_KEY" \ |
| 82 | -H "Content-Type: application/json" \ |
| 83 | -d '{ |
| 84 | "to": "+13125550001", |
| 85 | "from": "+18005550101", |
| 86 | "text": "Hello from Telnyx!" |
| 87 | }' \ |
| 88 | "https://api.telnyx.com/v2/messages" |
| 89 | ``` |
| 90 | |
| 91 | Primary response fields: |
| 92 | - `.data.id` |
| 93 | - `.data.to` |
| 94 | - `.data.from` |
| 95 | - `.data.text` |
| 96 | - `.data.sent_at` |
| 97 | - `.data.errors` |
| 98 | |
| 99 | ### Send an SMS with an alphanumeric sender ID |
| 100 | |
| 101 | Common sender variant that requires different request shape. |
| 102 | |
| 103 | `POST /messages/alphanumeric_sender_id` |
| 104 | |
| 105 | | Parameter | Type | Required | Description | |
| 106 | |-----------|------|----------|-------------| |
| 107 | | `from` | string (E.164) | Yes | A valid alphanumeric sender ID on the user's account. | |
| 108 | | `to` | string (E.164) | Yes | Receiving address (+E.164 formatted phone number or short co... | |
| 109 | | `text` | string | Yes | The message body. | |
| 110 | | `messaging_profile_id` | string (UUID) | Yes | The messaging profile ID to use. | |
| 111 | | `webhook_url` | string (URL) | No | Callback URL for delivery status updates. | |
| 112 | | `webhook_failover_url` | string (URL) | No | Failover callback URL for delivery status updates. | |
| 113 | | `use_profile_webhooks` | boolean | No | If true, use the messaging profile's webhook settings. | |
| 114 | |
| 115 | ```bash |
| 116 | curl \ |
| 117 | -X POST \ |
| 118 | -H "Authorization: Bearer $TELNYX_API_KEY" \ |
| 119 | -H "Content-Type: application/json" \ |
| 120 | -d '{ |
| 121 | "from": "MyCompany", |
| 122 | "to": "+13125550001", |
| 123 | "text": "Hello from Telnyx!", |
| 124 | "messaging_profile_id": "550e8400-e29b-41d4-a716-4466 |