$npx -y skills add team-telnyx/ai --skill telnyx-messaging-profiles-curlCreate and manage messaging profiles with number pools, sticky sender, and geomatch features. Configure short codes for high-volume messaging. This skill provides REST API (curl) examples.
| 1 | <!-- Auto-generated from Telnyx OpenAPI specs. Do not edit. --> |
| 2 | |
| 3 | # Telnyx Messaging Profiles - 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 | # Check HTTP status code in response |
| 26 | response=$(curl -s -w "\n%{http_code}" \ |
| 27 | -X POST "https://api.telnyx.com/v2/messages" \ |
| 28 | -H "Authorization: Bearer $TELNYX_API_KEY" \ |
| 29 | -H "Content-Type: application/json" \ |
| 30 | -d '{"to": "+13125550001", "from": "+13125550002", "text": "Hello"}') |
| 31 | |
| 32 | http_code=$(echo "$response" | tail -1) |
| 33 | body=$(echo "$response" | sed '$d') |
| 34 | |
| 35 | case $http_code in |
| 36 | 2*) echo "Success: $body" ;; |
| 37 | 422) echo "Validation error — check required fields and formats" ;; |
| 38 | 429) echo "Rate limited — retry after delay"; sleep 1 ;; |
| 39 | 401) echo "Authentication failed — check TELNYX_API_KEY" ;; |
| 40 | *) echo "Error $http_code: $body" ;; |
| 41 | esac |
| 42 | ``` |
| 43 | |
| 44 | Common error codes: `401` invalid API key, `403` insufficient permissions, |
| 45 | `404` resource not found, `422` validation error (check field formats), |
| 46 | `429` rate limited (retry with exponential backoff). |
| 47 | |
| 48 | ## Important Notes |
| 49 | |
| 50 | - **Pagination:** List endpoints return paginated results. Use `page[number]` and `page[size]` query parameters to navigate pages. Check `meta.total_pages` in the response. |
| 51 | |
| 52 | ## List messaging profiles |
| 53 | |
| 54 | `GET /messaging_profiles` |
| 55 | |
| 56 | ```bash |
| 57 | curl -H "Authorization: Bearer $TELNYX_API_KEY" "https://api.telnyx.com/v2/messaging_profiles" |
| 58 | ``` |
| 59 | |
| 60 | Returns: `ai_assistant_id` (string | null), `alpha_sender` (string | null), `created_at` (date-time), `daily_spend_limit` (string), `daily_spend_limit_enabled` (boolean), `enabled` (boolean), `health_webhook_url` (url), `id` (uuid), `mms_fall_back_to_sms` (boolean), `mms_transcoding` (boolean), `mobile_only` (boolean), `name` (string), `number_pool_settings` (object | null), `organization_id` (string), `record_type` (enum: messaging_profile), `redaction_enabled` (boolean), `redaction_level` (integer), `resource_group_id` (string | null), `smart_encoding` (boolean), `updated_at` (date-time), `url_shortener_settings` (object | null), `v1_secret` (string), `webhook_api_version` (enum: 1, 2, 2010-04-01), `webhook_failover_url` (url), `webhook_url` (url), `whitelisted_destinations` (array[string]) |
| 61 | |
| 62 | ## Create a messaging profile |
| 63 | |
| 64 | `POST /messaging_profiles` — Required: `name`, `whitelisted_destinations` |
| 65 | |
| 66 | Optional: `ai_assistant_id` (string | null), `alpha_sender` (string | null), `daily_spend_limit` (string), `daily_spend_limit_enabled` (boolean), `enabled` (boolean), `health_webhook_url` (url), `mms_fall_back_to_sms` (boolean), `mms_transcoding` (boolean), `mobile_only` (boolean), `number_pool_settings` (object | null), `resource_group_id` (string | null), `smart_encoding` (boolean), `url_shortener_settings` (object | null), `webhook_api_version` (enum: 1, 2, 2010-04-01), `webhook_failover_url` (url), `webhook_url` (url) |
| 67 | |
| 68 | ```bash |
| 69 | curl \ |
| 70 | -X POST \ |
| 71 | -H "Authorization: Bearer $TELNYX_API_KEY" \ |
| 72 | -H "Content-Type: application/json" \ |
| 73 | -d '{ |
| 74 | "name": "my-resource", |
| 75 | "whitelisted_destinations": [ |
| 76 | "US" |
| 77 | ] |
| 78 | }' \ |
| 79 | "https://api.telnyx.com/v2/messaging_profiles" |
| 80 | ``` |
| 81 | |
| 82 | Returns: `ai_assistant_id` (string | null), `alpha_sender` (string | null), `created_at` (date-time), `daily_spend_limit` (string), `daily_spend_limit_enabled` (boolean), `enabled` (boolean), `health_webhook_url` (url), `id` (uuid), `mms_fall_back_to_sms` (boolean), `mms_transcoding` (boolean), `mobile_only` (boolean), `name` (string), `number_pool_settings` (object | null), `organization_id` (string), `record_type` (enum: messaging_profile), `redaction_enabled` (boolean), `redaction_level` (integer), `resource_group_id` (string | null), `smart_encoding` (boolean), `updated_at` (date-time), `url_shortener_settings` (object | null), `v1_secret` (string), `webhook_api_version` (enum: 1, 2, 2010-04-01), `webhook_failover_url` (url), `webhook_url` (url), `whitelisted_destinations` (array[string]) |
| 83 | |
| 84 | ## Retrieve a messaging profile |
| 85 | |
| 86 | `GET /messaging_profiles/{id}` |
| 87 | |
| 88 | ```bash |
| 89 | curl -H "Authorization: Bearer $TELNYX_API_KEY" "https://api.telnyx.com/v2/messaging_profiles/550e8400-e29b-41d4-a716-446655440000" |
| 90 | ``` |
| 91 | |
| 92 | Returns: `ai_assistant_id` (string | null), `alpha_sender` (string | null), `created_at` (date-time), `daily_spend_limit` (string), `daily_spend_limit_enabled` (boolean), `enabled` (boolean), `health_w |