$npx -y skills add team-telnyx/ai --skill telnyx-numbers-compliance-rubyManage regulatory requirements, number bundles, supporting documents, and verified numbers for compliance. This skill provides Ruby SDK examples.
| 1 | <!-- Auto-generated from Telnyx OpenAPI specs. Do not edit. --> |
| 2 | |
| 3 | # Telnyx Numbers Compliance - 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 | ## Retrieve Bundles |
| 54 | |
| 55 | Get all allowed bundles. |
| 56 | |
| 57 | `GET /bundle_pricing/billing_bundles` |
| 58 | |
| 59 | ```ruby |
| 60 | page = client.bundle_pricing.billing_bundles.list |
| 61 | |
| 62 | puts(page) |
| 63 | ``` |
| 64 | |
| 65 | Returns: `cost_code` (string), `created_at` (date), `currency` (string), `id` (uuid), `is_public` (boolean), `mrc_price` (float), `name` (string), `slug` (string), `specs` (array[string]) |
| 66 | |
| 67 | ## Get Bundle By Id |
| 68 | |
| 69 | Get a single bundle by ID. |
| 70 | |
| 71 | `GET /bundle_pricing/billing_bundles/{bundle_id}` |
| 72 | |
| 73 | ```ruby |
| 74 | billing_bundle = client.bundle_pricing.billing_bundles.retrieve("8661948c-a386-4385-837f-af00f40f111a") |
| 75 | |
| 76 | puts(billing_bundle) |
| 77 | ``` |
| 78 | |
| 79 | Returns: `active` (boolean), `bundle_limits` (array[object]), `cost_code` (string), `created_at` (date), `id` (uuid), `is_public` (boolean), `name` (string), `slug` (string) |
| 80 | |
| 81 | ## Get User Bundles |
| 82 | |
| 83 | Get a paginated list of user bundles. |
| 84 | |
| 85 | `GET /bundle_pricing/user_bundles` |
| 86 | |
| 87 | ```ruby |
| 88 | page = client.bundle_pricing.user_bundles.list |
| 89 | |
| 90 | puts(page) |
| 91 | ``` |
| 92 | |
| 93 | Returns: `active` (boolean), `billing_bundle` (object), `created_at` (date), `id` (uuid), `resources` (array[object]), `updated_at` (date), `user_id` (uuid) |
| 94 | |
| 95 | ## Create User Bundles |
| 96 | |
| 97 | Creates multiple user bundles for the user. |
| 98 | |
| 99 | `POST /bundle_pricing/user_bundles/bulk` |
| 100 | |
| 101 | Optional: `idempotency_key` (uuid), `items` (array[object]) |
| 102 | |
| 103 | ```ruby |
| 104 | user_bundle = client.bundle_pricing.user_bundles.create |
| 105 | |
| 106 | puts(user_bundle) |
| 107 | ``` |
| 108 | |
| 109 | Returns: `active` (boolean), `billing_bundle` (object), `created_at` (date), `id` (uuid), `resources` (array[object]), `updated_at` (date), `user_id` (uuid) |
| 110 | |
| 111 | ## Get Unused User Bundles |
| 112 | |
| 113 | Returns all user bundles that aren't in use. |
| 114 | |
| 115 | `GET /bundle_pricing/user_bundles/unused` |
| 116 | |
| 117 | ```ruby |
| 118 | response = client.bundle_pricing.user_bundles.list_unused |
| 119 | |
| 120 | puts(response) |
| 121 | ``` |
| 122 | |
| 123 | Returns: `billing_bundle` (object), `user_bundle_ids` (array[string]) |
| 124 | |
| 125 | ## Get User Bundle by Id |
| 126 | |
| 127 | Retrieves a user bundle by its ID. |
| 128 | |
| 129 | `GET /bundle_pricing/user_bundles/{user_bundle_id}` |
| 130 | |
| 131 | ```ruby |
| 132 | user_bundle = client.bundle_pricing.user_bundles.retrieve("ca1d2263-d1f1-43ac-ba53-248e7a4bb26a") |
| 133 | |
| 134 | puts(user_bundle) |
| 135 | ``` |
| 136 | |
| 137 | Returns: `active` (boolean), `billing_bundle` (object), `created_at` (date), `id` (uuid), `resources` (array[object]), `updated_at` (date), `user_id` (uuid) |
| 138 | |
| 139 | ## Deactivate User Bundle |
| 140 | |
| 141 | Deactivates a user bundle by its ID. |
| 142 | |
| 143 | `DELETE /bundle_pricing/user_bundles/{user_bundle_id}` |
| 144 | |
| 145 | ```ruby |
| 146 | response = client.bundle_pricing.user_bundles.deactivate("ca1d2263-d1f1-43ac-ba53-248e7a4bb26a") |
| 147 | |
| 148 | puts(response) |
| 149 | ``` |
| 150 | |
| 151 | Returns: `active` (boolean), `billing_bundle` (object), `created_at` (date), `id` (uuid), `resources` (array[object]), `updated_at` (date), `user_id` (uuid) |
| 152 | |
| 153 | ## Get User Bundle Resources |
| 154 | |
| 155 | Retrieves the resources of a user bundle by its ID. |
| 156 | |
| 157 | `GET /bundle_pricing/user_bundles/{user_bundle_id}/resources` |
| 158 | |
| 159 | ```ruby |
| 160 | response = client.bundle_pricing.user_bundles.list_resources("ca1d2263-d1f1-43ac-ba53-248e7a4bb26a") |
| 161 | |
| 162 | puts(response) |
| 163 | ``` |
| 164 | |
| 165 | Returns: `created_at` (date), `id` (uuid), `resource` (string), `resource_type` (string), `updated_at` (date) |
| 166 | |
| 167 | ## List all document links |
| 168 | |
| 169 | List all documents links ordered by created_at descending. |
| 170 | |
| 171 | `GET /document_links` |
| 172 | |
| 173 | ` |