$npx -y skills add team-telnyx/ai --skill telnyx-numbers-compliance-goManage regulatory requirements, number bundles, supporting documents, and verified numbers for compliance. This skill provides Go SDK examples.
| 1 | <!-- Auto-generated from Telnyx OpenAPI specs. Do not edit. --> |
| 2 | |
| 3 | # Telnyx Numbers Compliance - Go |
| 4 | |
| 5 | ## Installation |
| 6 | |
| 7 | ```bash |
| 8 | go get github.com/team-telnyx/telnyx-go |
| 9 | ``` |
| 10 | |
| 11 | ## Setup |
| 12 | |
| 13 | ```go |
| 14 | import ( |
| 15 | "context" |
| 16 | "fmt" |
| 17 | "os" |
| 18 | |
| 19 | "github.com/team-telnyx/telnyx-go" |
| 20 | "github.com/team-telnyx/telnyx-go/option" |
| 21 | ) |
| 22 | |
| 23 | client := telnyx.NewClient( |
| 24 | option.WithAPIKey(os.Getenv("TELNYX_API_KEY")), |
| 25 | ) |
| 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 | ```go |
| 36 | import "errors" |
| 37 | |
| 38 | result, err := client.Messages.Send(ctx, params) |
| 39 | if err != nil { |
| 40 | var apiErr *telnyx.Error |
| 41 | if errors.As(err, &apiErr) { |
| 42 | switch apiErr.StatusCode { |
| 43 | case 422: |
| 44 | fmt.Println("Validation error — check required fields and formats") |
| 45 | case 429: |
| 46 | // Rate limited — wait and retry with exponential backoff |
| 47 | fmt.Println("Rate limited, retrying...") |
| 48 | default: |
| 49 | fmt.Printf("API error %d: %s\n", apiErr.StatusCode, apiErr.Error()) |
| 50 | } |
| 51 | } else { |
| 52 | fmt.Println("Network error — check connectivity and retry") |
| 53 | } |
| 54 | } |
| 55 | ``` |
| 56 | |
| 57 | Common error codes: `401` invalid API key, `403` insufficient permissions, |
| 58 | `404` resource not found, `422` validation error (check field formats), |
| 59 | `429` rate limited (retry with exponential backoff). |
| 60 | |
| 61 | ## Important Notes |
| 62 | |
| 63 | - **Phone numbers** must be in E.164 format (e.g., `+13125550001`). Include the `+` prefix and country code. No spaces, dashes, or parentheses. |
| 64 | - **Pagination:** Use `ListAutoPaging()` for automatic iteration: `iter := client.Resource.ListAutoPaging(ctx, params); for iter.Next() { item := iter.Current() }`. |
| 65 | |
| 66 | ## Retrieve Bundles |
| 67 | |
| 68 | Get all allowed bundles. |
| 69 | |
| 70 | `GET /bundle_pricing/billing_bundles` |
| 71 | |
| 72 | ```go |
| 73 | page, err := client.BundlePricing.BillingBundles.List(context.Background(), telnyx.BundlePricingBillingBundleListParams{}) |
| 74 | if err != nil { |
| 75 | log.Fatal(err) |
| 76 | } |
| 77 | fmt.Printf("%+v\n", page) |
| 78 | ``` |
| 79 | |
| 80 | Returns: `cost_code` (string), `created_at` (date), `currency` (string), `id` (uuid), `is_public` (boolean), `mrc_price` (float), `name` (string), `slug` (string), `specs` (array[string]) |
| 81 | |
| 82 | ## Get Bundle By Id |
| 83 | |
| 84 | Get a single bundle by ID. |
| 85 | |
| 86 | `GET /bundle_pricing/billing_bundles/{bundle_id}` |
| 87 | |
| 88 | ```go |
| 89 | billingBundle, err := client.BundlePricing.BillingBundles.Get( |
| 90 | context.Background(), |
| 91 | "8661948c-a386-4385-837f-af00f40f111a", |
| 92 | telnyx.BundlePricingBillingBundleGetParams{}, |
| 93 | ) |
| 94 | if err != nil { |
| 95 | log.Fatal(err) |
| 96 | } |
| 97 | fmt.Printf("%+v\n", billingBundle.Data) |
| 98 | ``` |
| 99 | |
| 100 | Returns: `active` (boolean), `bundle_limits` (array[object]), `cost_code` (string), `created_at` (date), `id` (uuid), `is_public` (boolean), `name` (string), `slug` (string) |
| 101 | |
| 102 | ## Get User Bundles |
| 103 | |
| 104 | Get a paginated list of user bundles. |
| 105 | |
| 106 | `GET /bundle_pricing/user_bundles` |
| 107 | |
| 108 | ```go |
| 109 | page, err := client.BundlePricing.UserBundles.List(context.Background(), telnyx.BundlePricingUserBundleListParams{}) |
| 110 | if err != nil { |
| 111 | log.Fatal(err) |
| 112 | } |
| 113 | fmt.Printf("%+v\n", page) |
| 114 | ``` |
| 115 | |
| 116 | Returns: `active` (boolean), `billing_bundle` (object), `created_at` (date), `id` (uuid), `resources` (array[object]), `updated_at` (date), `user_id` (uuid) |
| 117 | |
| 118 | ## Create User Bundles |
| 119 | |
| 120 | Creates multiple user bundles for the user. |
| 121 | |
| 122 | `POST /bundle_pricing/user_bundles/bulk` |
| 123 | |
| 124 | Optional: `idempotency_key` (uuid), `items` (array[object]) |
| 125 | |
| 126 | ```go |
| 127 | userBundle, err := client.BundlePricing.UserBundles.New(context.Background(), telnyx.BundlePricingUserBundleNewParams{}) |
| 128 | if err != nil { |
| 129 | log.Fatal(err) |
| 130 | } |
| 131 | fmt.Printf("%+v\n", userBundle.Data) |
| 132 | ``` |
| 133 | |
| 134 | Returns: `active` (boolean), `billing_bundle` (object), `created_at` (date), `id` (uuid), `resources` (array[object]), `updated_at` (date), `user_id` (uuid) |
| 135 | |
| 136 | ## Get Unused User Bundles |
| 137 | |
| 138 | Returns all user bundles that aren't in use. |
| 139 | |
| 140 | `GET /bundle_pricing/user_bundles/unused` |
| 141 | |
| 142 | ```go |
| 143 | response, err := client.BundlePricing.UserBundles.ListUnused(context.Background(), telnyx.BundlePricingUserBundleListUnusedParams{}) |
| 144 | if err != nil { |
| 145 | log.Fatal(err) |
| 146 | } |
| 147 | fmt.Printf("%+v\n", response.Data) |
| 148 | ``` |
| 149 | |
| 150 | Returns: `billing_bundle` (object), `user_bundle_ids` (array[string]) |
| 151 | |
| 152 | ## Get User Bundle by Id |
| 153 | |
| 154 | Retrieves a user bundle by its ID. |
| 155 | |
| 156 | `GET /bundle_pricing/user_bundles/{user_bundle_id}` |
| 157 | |
| 158 | ```go |
| 159 | userBundle, err := client.BundlePricing.UserBundles.Get( |
| 160 | context.Background(), |
| 161 | "ca1d2263-d1f1-43ac-ba53-248e7a4bb26a", |
| 162 | telnyx.BundlePricingUserBundleGetParams{}, |
| 163 | ) |
| 164 | if err != nil { |
| 165 | log.Fatal(err) |
| 166 | } |
| 167 | fmt.Printf("%+v\n", userBundle.Data) |
| 168 | ``` |
| 169 | |
| 170 | Returns: `active` (boolean), `billing_bundle` (object), `created_at` (date), `id` (uuid), `resources` (array[object]), `updated_at` (date), `user_ |