$npx -y skills add team-telnyx/ai --skill telnyx-numbers-rubySearch, order, and manage phone numbers by location, features, and coverage.
| 1 | <!-- Auto-generated from Telnyx OpenAPI specs. Do not edit. --> |
| 2 | |
| 3 | # Telnyx Numbers - 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 | available_phone_numbers = client.available_phone_numbers.list |
| 30 | puts(available_phone_numbers) |
| 31 | ``` |
| 32 | |
| 33 | Common error codes: `401` invalid API key, `403` insufficient permissions, |
| 34 | `404` resource not found, `422` validation error (check field formats), |
| 35 | `429` rate limited (retry with exponential backoff). |
| 36 | |
| 37 | ## Important Notes |
| 38 | |
| 39 | - **Phone numbers** must be in E.164 format (e.g., `+13125550001`). Include the `+` prefix and country code. No spaces, dashes, or parentheses. |
| 40 | - **Pagination:** Use `.auto_paging_each` for automatic iteration: `page.auto_paging_each { |item| puts item.id }`. |
| 41 | |
| 42 | ## Reference Use Rules |
| 43 | |
| 44 | Do not invent Telnyx parameters, enums, response fields, or webhook fields. |
| 45 | |
| 46 | - 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. |
| 47 | - 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). |
| 48 | |
| 49 | ## Core Tasks |
| 50 | |
| 51 | ### Search available phone numbers |
| 52 | |
| 53 | Number search is the entrypoint for provisioning. Agents need the search method, key query filters, and the fields returned for candidate numbers. |
| 54 | |
| 55 | `client.available_phone_numbers.list()` — `GET /available_phone_numbers` |
| 56 | |
| 57 | | Parameter | Type | Required | Description | |
| 58 | |-----------|------|----------|-------------| |
| 59 | | `filter` | object | No | Consolidated filter parameter (deepObject style). | |
| 60 | |
| 61 | ```ruby |
| 62 | available_phone_numbers = client.available_phone_numbers.list |
| 63 | |
| 64 | puts(available_phone_numbers) |
| 65 | ``` |
| 66 | |
| 67 | Response wrapper: |
| 68 | - items: `available_phone_numbers.data` |
| 69 | - pagination: `available_phone_numbers.meta` |
| 70 | |
| 71 | Primary item fields: |
| 72 | - `phone_number` |
| 73 | - `record_type` |
| 74 | - `quickship` |
| 75 | - `reservable` |
| 76 | - `best_effort` |
| 77 | - `cost_information` |
| 78 | |
| 79 | ### Create a number order |
| 80 | |
| 81 | Number ordering is the production provisioning step after number selection. |
| 82 | |
| 83 | `client.number_orders.create()` — `POST /number_orders` |
| 84 | |
| 85 | | Parameter | Type | Required | Description | |
| 86 | |-----------|------|----------|-------------| |
| 87 | | `phone_numbers` | array[object] | Yes | | |
| 88 | | `connection_id` | string (UUID) | No | Identifies the connection associated with this phone number. | |
| 89 | | `messaging_profile_id` | string (UUID) | No | Identifies the messaging profile associated with the phone n... | |
| 90 | | `billing_group_id` | string (UUID) | No | Identifies the billing group associated with the phone numbe... | |
| 91 | | ... | | | +1 optional params in [references/api-details.md](references/api-details.md) | |
| 92 | |
| 93 | ```ruby |
| 94 | number_order = client.number_orders.create(phone_numbers: [{"phone_number": "+18005550101"}]) |
| 95 | puts(number_order) |
| 96 | ``` |
| 97 | |
| 98 | Primary response fields: |
| 99 | - `number_order.data.id` |
| 100 | - `number_order.data.status` |
| 101 | - `number_order.data.phone_numbers_count` |
| 102 | - `number_order.data.requirements_met` |
| 103 | - `number_order.data.messaging_profile_id` |
| 104 | - `number_order.data.connection_id` |
| 105 | |
| 106 | ### Check number order status |
| 107 | |
| 108 | Order status determines whether provisioning completed or additional requirements are still blocking fulfillment. |
| 109 | |
| 110 | `client.number_orders.retrieve()` — `GET /number_orders/{number_order_id}` |
| 111 | |
| 112 | | Parameter | Type | Required | Description | |
| 113 | |-----------|------|----------|-------------| |
| 114 | | `number_order_id` | string (UUID) | Yes | The number order ID. | |
| 115 | |
| 116 | ```ruby |
| 117 | number_order = client.number_orders.retrieve("550e8400-e29b-41d4-a716-446655440000") |
| 118 | |
| 119 | puts(number_order) |
| 120 | ``` |
| 121 | |
| 122 | Primary response fields: |
| 123 | - `number_order.data.id` |
| 124 | - `number_order.data.status` |
| 125 | - `number_order.data.requirements_met` |
| 126 | - `number_order.data.phone_numbers_count` |
| 127 | - `number_order.data.phone_numbers` |
| 128 | - `number_order.data.connection_id` |
| 129 | |
| 130 | --- |
| 131 | |
| 132 | ## Important Supporting Operations |
| 133 | |
| 134 | Use these when the core tasks above are close to your flow, but you need a common variation or follow-up step. |
| 135 | |
| 136 | ### Create a number reservation |
| 137 | |
| 138 | Create or provision an additional resource when the core tasks do not cover this flow. |
| 139 | |
| 140 | `client.number_reservations.create()` — `POST /number_reservations` |
| 141 | |
| 142 | | Parameter | Type | Required | Description | |
| 143 | |-----------|------|----------|-------------| |
| 144 | | `phone_numbers` | array[object] | Yes | | |
| 145 | | `status` | enum (pending, success, fai |