$npx -y skills add team-telnyx/ai --skill telnyx-numbers-config-rubyConfigure phone number settings including caller ID, call forwarding, messaging enablement, and connection assignments. This skill provides Ruby SDK examples.
| 1 | <!-- Auto-generated from Telnyx OpenAPI specs. Do not edit. --> |
| 2 | |
| 3 | # Telnyx Numbers Config - Ruby |
| 4 | |
| 5 | ## Installation |
| 6 | |
| 7 | ```bash |
| 8 | gem install telnyx |
| 9 | ``` |
| 10 | |
| 11 | ## Setup |
| 12 | |
| 13 | ```ruby |
| 14 | require "telnyx" |
| 15 | |
| 16 | client = Telnyx::Client.new( |
| 17 | api_key: ENV["TELNYX_API_KEY"], # This is the default and can be omitted |
| 18 | ) |
| 19 | ``` |
| 20 | |
| 21 | All examples below assume `client` is already initialized as shown above. |
| 22 | |
| 23 | ## Error Handling |
| 24 | |
| 25 | All API calls can fail with network errors, rate limits (429), validation errors (422), |
| 26 | or authentication errors (401). Always handle errors in production code: |
| 27 | |
| 28 | ```ruby |
| 29 | begin |
| 30 | result = client.messages.send_(to: "+13125550001", from: "+13125550002", text: "Hello") |
| 31 | rescue Telnyx::Errors::APIConnectionError |
| 32 | puts "Network error — check connectivity and retry" |
| 33 | rescue Telnyx::Errors::RateLimitError |
| 34 | # 429: rate limited — wait and retry with exponential backoff |
| 35 | sleep(1) # Check Retry-After header for actual delay |
| 36 | rescue Telnyx::Errors::APIStatusError => e |
| 37 | puts "API error #{e.status}: #{e.message}" |
| 38 | if e.status == 422 |
| 39 | puts "Validation error — check required fields and formats" |
| 40 | end |
| 41 | end |
| 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 | - **Phone numbers** must be in E.164 format (e.g., `+13125550001`). Include the `+` prefix and country code. No spaces, dashes, or parentheses. |
| 51 | - **Pagination:** Use `.auto_paging_each` for automatic iteration: `page.auto_paging_each { |item| puts item.id }`. |
| 52 | |
| 53 | ## Bulk update phone number profiles |
| 54 | |
| 55 | `POST /messaging_numbers_bulk_updates` — Required: `messaging_profile_id`, `numbers` |
| 56 | |
| 57 | Optional: `assign_only` (boolean) |
| 58 | |
| 59 | ```ruby |
| 60 | messaging_numbers_bulk_update = client.messaging_numbers_bulk_updates.create( |
| 61 | messaging_profile_id: "00000000-0000-0000-0000-000000000000", |
| 62 | numbers: ["+18880000000", "+18880000001", "+18880000002"] |
| 63 | ) |
| 64 | |
| 65 | puts(messaging_numbers_bulk_update) |
| 66 | ``` |
| 67 | |
| 68 | Returns: `failed` (array[string]), `order_id` (uuid), `pending` (array[string]), `record_type` (enum: messaging_numbers_bulk_update), `success` (array[string]) |
| 69 | |
| 70 | ## Retrieve bulk update status |
| 71 | |
| 72 | `GET /messaging_numbers_bulk_updates/{order_id}` |
| 73 | |
| 74 | ```ruby |
| 75 | messaging_numbers_bulk_update = client.messaging_numbers_bulk_updates.retrieve("order_id") |
| 76 | |
| 77 | puts(messaging_numbers_bulk_update) |
| 78 | ``` |
| 79 | |
| 80 | Returns: `failed` (array[string]), `order_id` (uuid), `pending` (array[string]), `record_type` (enum: messaging_numbers_bulk_update), `success` (array[string]) |
| 81 | |
| 82 | ## List mobile phone numbers with messaging settings |
| 83 | |
| 84 | `GET /mobile_phone_numbers/messaging` |
| 85 | |
| 86 | ```ruby |
| 87 | page = client.mobile_phone_numbers.messaging.list |
| 88 | |
| 89 | puts(page) |
| 90 | ``` |
| 91 | |
| 92 | Returns: `country_code` (string), `created_at` (date-time), `features` (object), `id` (string), `messaging_product` (string), `messaging_profile_id` (string | null), `organization_id` (string), `phone_number` (string), `record_type` (enum: messaging_phone_number, messaging_settings), `tags` (array[string]), `traffic_type` (string), `type` (enum: longcode), `updated_at` (date-time) |
| 93 | |
| 94 | ## Retrieve a mobile phone number with messaging settings |
| 95 | |
| 96 | `GET /mobile_phone_numbers/{id}/messaging` |
| 97 | |
| 98 | ```ruby |
| 99 | messaging = client.mobile_phone_numbers.messaging.retrieve("550e8400-e29b-41d4-a716-446655440000") |
| 100 | |
| 101 | puts(messaging) |
| 102 | ``` |
| 103 | |
| 104 | Returns: `country_code` (string), `created_at` (date-time), `features` (object), `id` (string), `messaging_product` (string), `messaging_profile_id` (string | null), `organization_id` (string), `phone_number` (string), `record_type` (enum: messaging_phone_number, messaging_settings), `tags` (array[string]), `traffic_type` (string), `type` (enum: longcode), `updated_at` (date-time) |
| 105 | |
| 106 | ## List phone numbers |
| 107 | |
| 108 | `GET /phone_numbers` |
| 109 | |
| 110 | ```ruby |
| 111 | page = client.phone_numbers.list |
| 112 | |
| 113 | puts(page) |
| 114 | ``` |
| 115 | |
| 116 | Returns: `billing_group_id` (string | null), `call_forwarding_enabled` (boolean), `call_recording_enabled` (boolean), `caller_id_name_enabled` (boolean), `cnam_listing_enabled` (boolean), `connection_id` (string | null), `connection_name` (string | null), `country_iso_alpha2` (string), `created_at` (date-time), `customer_reference` (string | null), `deletion_lock_enabled` (boolean), `emergency_address_id` (string | null), `emergency_enabled` (boolean), `emergency_status` (enum: active, deprovisioning, disabled, provisioning, provisioning-failed), `external_pin` (string | null), `hd_voice_enabled` (boolean), `id` (string), `inbound_call_screening` (enum: disabled, reject_calls, flag_calls), `messaging_profile_id` (string | null), `messaging_profile_name` (string | null), `phone_number` (string), `phone_number_type` (enum: local, toll_free, mobil |