$npx -y skills add team-telnyx/ai --skill telnyx-numbers-compliance-javaManage regulatory requirements, number bundles, supporting documents, and verified numbers for compliance. This skill provides Java SDK examples.
| 1 | <!-- Auto-generated from Telnyx OpenAPI specs. Do not edit. --> |
| 2 | |
| 3 | # Telnyx Numbers Compliance - Java |
| 4 | |
| 5 | ## Installation |
| 6 | |
| 7 | ```text |
| 8 | <!-- Maven --> |
| 9 | <dependency> |
| 10 | <groupId>com.telnyx.sdk</groupId> |
| 11 | <artifactId>telnyx</artifactId> |
| 12 | <version>6.36.0</version> |
| 13 | </dependency> |
| 14 | |
| 15 | // Gradle |
| 16 | implementation("com.telnyx.sdk:telnyx:6.36.0") |
| 17 | ``` |
| 18 | |
| 19 | ## Setup |
| 20 | |
| 21 | ```java |
| 22 | import com.telnyx.sdk.client.TelnyxClient; |
| 23 | import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient; |
| 24 | |
| 25 | TelnyxClient client = TelnyxOkHttpClient.fromEnv(); |
| 26 | ``` |
| 27 | |
| 28 | All examples below assume `client` is already initialized as shown above. |
| 29 | |
| 30 | ## Error Handling |
| 31 | |
| 32 | All API calls can fail with network errors, rate limits (429), validation errors (422), |
| 33 | or authentication errors (401). Always handle errors in production code: |
| 34 | |
| 35 | ```java |
| 36 | import com.telnyx.sdk.errors.TelnyxServiceException; |
| 37 | |
| 38 | try { |
| 39 | var result = client.messages().send(params); |
| 40 | } catch (TelnyxServiceException e) { |
| 41 | System.err.println("API error " + e.statusCode() + ": " + e.getMessage()); |
| 42 | if (e.statusCode() == 422) { |
| 43 | System.err.println("Validation error — check required fields and formats"); |
| 44 | } else if (e.statusCode() == 429) { |
| 45 | // Rate limited — wait and retry with exponential backoff |
| 46 | Thread.sleep(1000); |
| 47 | } |
| 48 | } |
| 49 | ``` |
| 50 | |
| 51 | Common error codes: `401` invalid API key, `403` insufficient permissions, |
| 52 | `404` resource not found, `422` validation error (check field formats), |
| 53 | `429` rate limited (retry with exponential backoff). |
| 54 | |
| 55 | ## Important Notes |
| 56 | |
| 57 | - **Phone numbers** must be in E.164 format (e.g., `+13125550001`). Include the `+` prefix and country code. No spaces, dashes, or parentheses. |
| 58 | - **Pagination:** List methods return a page. Use `.autoPager()` for automatic iteration: `for (var item : page.autoPager()) { ... }`. For manual control, use `.hasNextPage()` and `.nextPage()`. |
| 59 | |
| 60 | ## Retrieve Bundles |
| 61 | |
| 62 | Get all allowed bundles. |
| 63 | |
| 64 | `GET /bundle_pricing/billing_bundles` |
| 65 | |
| 66 | ```java |
| 67 | import com.telnyx.sdk.models.bundlepricing.billingbundles.BillingBundleListPage; |
| 68 | import com.telnyx.sdk.models.bundlepricing.billingbundles.BillingBundleListParams; |
| 69 | |
| 70 | BillingBundleListPage page = client.bundlePricing().billingBundles().list(); |
| 71 | ``` |
| 72 | |
| 73 | Returns: `cost_code` (string), `created_at` (date), `currency` (string), `id` (uuid), `is_public` (boolean), `mrc_price` (float), `name` (string), `slug` (string), `specs` (array[string]) |
| 74 | |
| 75 | ## Get Bundle By Id |
| 76 | |
| 77 | Get a single bundle by ID. |
| 78 | |
| 79 | `GET /bundle_pricing/billing_bundles/{bundle_id}` |
| 80 | |
| 81 | ```java |
| 82 | import com.telnyx.sdk.models.bundlepricing.billingbundles.BillingBundleRetrieveParams; |
| 83 | import com.telnyx.sdk.models.bundlepricing.billingbundles.BillingBundleRetrieveResponse; |
| 84 | |
| 85 | BillingBundleRetrieveResponse billingBundle = client.bundlePricing().billingBundles().retrieve("8661948c-a386-4385-837f-af00f40f111a"); |
| 86 | ``` |
| 87 | |
| 88 | Returns: `active` (boolean), `bundle_limits` (array[object]), `cost_code` (string), `created_at` (date), `id` (uuid), `is_public` (boolean), `name` (string), `slug` (string) |
| 89 | |
| 90 | ## Get User Bundles |
| 91 | |
| 92 | Get a paginated list of user bundles. |
| 93 | |
| 94 | `GET /bundle_pricing/user_bundles` |
| 95 | |
| 96 | ```java |
| 97 | import com.telnyx.sdk.models.bundlepricing.userbundles.UserBundleListPage; |
| 98 | import com.telnyx.sdk.models.bundlepricing.userbundles.UserBundleListParams; |
| 99 | |
| 100 | UserBundleListPage page = client.bundlePricing().userBundles().list(); |
| 101 | ``` |
| 102 | |
| 103 | Returns: `active` (boolean), `billing_bundle` (object), `created_at` (date), `id` (uuid), `resources` (array[object]), `updated_at` (date), `user_id` (uuid) |
| 104 | |
| 105 | ## Create User Bundles |
| 106 | |
| 107 | Creates multiple user bundles for the user. |
| 108 | |
| 109 | `POST /bundle_pricing/user_bundles/bulk` |
| 110 | |
| 111 | Optional: `idempotency_key` (uuid), `items` (array[object]) |
| 112 | |
| 113 | ```java |
| 114 | import com.telnyx.sdk.models.bundlepricing.userbundles.UserBundleCreateParams; |
| 115 | import com.telnyx.sdk.models.bundlepricing.userbundles.UserBundleCreateResponse; |
| 116 | |
| 117 | UserBundleCreateResponse userBundle = client.bundlePricing().userBundles().create(); |
| 118 | ``` |
| 119 | |
| 120 | Returns: `active` (boolean), `billing_bundle` (object), `created_at` (date), `id` (uuid), `resources` (array[object]), `updated_at` (date), `user_id` (uuid) |
| 121 | |
| 122 | ## Get Unused User Bundles |
| 123 | |
| 124 | Returns all user bundles that aren't in use. |
| 125 | |
| 126 | `GET /bundle_pricing/user_bundles/unused` |
| 127 | |
| 128 | ```java |
| 129 | import com.telnyx.sdk.models.bundlepricing.userbundles.UserBundleListUnusedParams; |
| 130 | import com.telnyx.sdk.models.bundlepricing.userbundles.UserBundleListUnusedResponse; |
| 131 | |
| 132 | UserBundleListUnusedResponse response = client.bundlePricing().userBundles().listUnused(); |
| 133 | ``` |
| 134 | |
| 135 | Returns: `billing_bundle` (object), `user_bundle_ids` (array[string]) |
| 136 | |
| 137 | ## Get User Bundle by Id |
| 138 | |
| 139 | Retrieves a user bundle by its ID. |
| 140 | |
| 141 | `GET /bundle_pricing/user_bundles/{user_bundle_id}` |
| 142 | |
| 143 | ```java |
| 144 | import com.telnyx.sdk.models.bundlepricing.userbund |