$npx -y skills add team-telnyx/ai --skill telnyx-numbers-services-curlConfigure voicemail, voice channels, and emergency (E911) services for your phone numbers. This skill provides REST API (curl) examples.
| 1 | <!-- Auto-generated from Telnyx OpenAPI specs. Do not edit. --> |
| 2 | |
| 3 | # Telnyx Numbers Services - 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 your voice channels for non-US zones |
| 53 | |
| 54 | Returns the non-US voice channels for your account. voice channels allow you to use Channel Billing for calls to your Telnyx phone numbers. Please check the Telnyx Support Articles section for full information and examples of how to utilize Channel Billing. |
| 55 | |
| 56 | `GET /channel_zones` |
| 57 | |
| 58 | ```bash |
| 59 | curl -H "Authorization: Bearer $TELNYX_API_KEY" "https://api.telnyx.com/v2/channel_zones" |
| 60 | ``` |
| 61 | |
| 62 | Returns: `channels` (int64), `countries` (array[string]), `created_at` (string), `id` (string), `name` (string), `record_type` (enum: channel_zone), `updated_at` (string) |
| 63 | |
| 64 | ## Update voice channels for non-US Zones |
| 65 | |
| 66 | Update the number of Voice Channels for the Non-US Zones. This allows your account to handle multiple simultaneous inbound calls to Non-US numbers. Use this endpoint to increase or decrease your capacity based on expected call volume. |
| 67 | |
| 68 | `PUT /channel_zones/{channel_zone_id}` — Required: `channels` |
| 69 | |
| 70 | ```bash |
| 71 | curl \ |
| 72 | -X PUT \ |
| 73 | -H "Authorization: Bearer $TELNYX_API_KEY" \ |
| 74 | -H "Content-Type: application/json" \ |
| 75 | -d '{ |
| 76 | "channels": 0 |
| 77 | }' \ |
| 78 | "https://api.telnyx.com/v2/channel_zones/{channel_zone_id}" |
| 79 | ``` |
| 80 | |
| 81 | Returns: `channels` (int64), `countries` (array[string]), `created_at` (string), `id` (string), `name` (string), `record_type` (enum: channel_zone), `updated_at` (string) |
| 82 | |
| 83 | ## List dynamic emergency addresses |
| 84 | |
| 85 | Returns the dynamic emergency addresses according to filters |
| 86 | |
| 87 | `GET /dynamic_emergency_addresses` |
| 88 | |
| 89 | ```bash |
| 90 | curl -H "Authorization: Bearer $TELNYX_API_KEY" "https://api.telnyx.com/v2/dynamic_emergency_addresses" |
| 91 | ``` |
| 92 | |
| 93 | Returns: `administrative_area` (string), `country_code` (enum: US, CA, PR), `created_at` (string), `extended_address` (string), `house_number` (string), `house_suffix` (string), `id` (string), `locality` (string), `postal_code` (string), `record_type` (string), `sip_geolocation_id` (string), `status` (enum: pending, activated, rejected), `street_name` (string), `street_post_directional` (string), `street_pre_directional` (string), `street_suffix` (string), `updated_at` (string) |
| 94 | |
| 95 | ## Create a dynamic emergency address. |
| 96 | |
| 97 | Creates a dynamic emergency address. |
| 98 | |
| 99 | `POST /dynamic_emergency_addresses` — Required: `house_number`, `street_name`, `locality`, `administrative_area`, `postal_code`, `country_code` |
| 100 | |
| 101 | Optional: `created_at` (string), `extended_address` (string), `house_suffix` (string), `id` (string), `record_type` (string), `sip_geolocation_id` (string), `status` (enum: pending, activated, rejected), `street_post_directional` (string), `street_pre_directional` (string), `street_suffix` (string), `updated_at` (string) |
| 102 | |
| 103 | ```bash |
| 104 | curl \ |
| 105 | -X POST \ |
| 106 | -H "Authorization: Bearer $TELNYX_API_KEY" \ |
| 107 | -H "Content-Type: application/json" \ |
| 108 | -d '{ |
| 109 | "house_number": "600", |
| 110 | "street_name": "Congress", |
| 111 | "locality": "Austin", |
| 112 | "administrative_area": "TX", |
| 113 | "postal_code": "78701", |
| 114 | "country_code": "US" |
| 115 | }' \ |
| 116 | "https://api.telnyx.com/v2/dynamic_emergency_addresses" |
| 117 | ``` |
| 118 | |
| 119 | Returns: `administrative_area` (string), `country_code` (enum: US, CA, PR), `created_at` (string), `extended_address` (string), `house_number` (string), `house_suffix` (strin |