$npx -y skills add team-telnyx/ai --skill telnyx-10dlc-go10DLC brand and campaign registration for US A2P messaging compliance. Assign phone numbers to campaigns.
| 1 | <!-- Auto-generated from Telnyx OpenAPI specs. Do not edit. --> |
| 2 | |
| 3 | # Telnyx 10DLC - 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 | telnyxBrand, err := client.Messaging10dlc.Brand.New(context.Background(), telnyx.Messaging10dlcBrandNewParams{ |
| 39 | Country: "US", |
| 40 | DisplayName: "ABC Mobile", |
| 41 | Email: "support@example.com", |
| 42 | EntityType: telnyx.EntityTypePrivateProfit, |
| 43 | Vertical: telnyx.VerticalTechnology, |
| 44 | }) |
| 45 | if err != nil { |
| 46 | var apiErr *telnyx.Error |
| 47 | if errors.As(err, &apiErr) { |
| 48 | switch apiErr.StatusCode { |
| 49 | case 422: |
| 50 | fmt.Println("Validation error — check required fields and formats") |
| 51 | case 429: |
| 52 | fmt.Println("Rate limited, retrying...") |
| 53 | default: |
| 54 | fmt.Printf("API error %d: %s\n", apiErr.StatusCode, apiErr.Error()) |
| 55 | } |
| 56 | } else { |
| 57 | fmt.Println("Network error — check connectivity and retry") |
| 58 | } |
| 59 | } |
| 60 | ``` |
| 61 | |
| 62 | Common error codes: `401` invalid API key, `403` insufficient permissions, |
| 63 | `404` resource not found, `422` validation error (check field formats), |
| 64 | `429` rate limited (retry with exponential backoff). |
| 65 | |
| 66 | ## Important Notes |
| 67 | |
| 68 | - **Pagination:** Use `ListAutoPaging()` for automatic iteration: `iter := client.Resource.ListAutoPaging(ctx, params); for iter.Next() { item := iter.Current() }`. |
| 69 | |
| 70 | ## Operational Caveats |
| 71 | |
| 72 | - 10DLC is sequential: create the brand first, then submit the campaign, then attach messaging infrastructure such as the messaging profile. |
| 73 | - Registration calls are not enough by themselves. Messaging cannot use the campaign until the assignment step completes successfully. |
| 74 | - Treat registration status fields as part of the control flow. Do not assume the campaign is send-ready until the returned status fields confirm it. |
| 75 | |
| 76 | ## Reference Use Rules |
| 77 | |
| 78 | Do not invent Telnyx parameters, enums, response fields, or webhook fields. |
| 79 | |
| 80 | - 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. |
| 81 | - 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). |
| 82 | - Before reading or matching webhook fields beyond the inline examples, read [the webhook payload reference](references/api-details.md#webhook-payload-fields). |
| 83 | |
| 84 | ## Core Tasks |
| 85 | |
| 86 | ### Create a brand |
| 87 | |
| 88 | Brand registration is the entrypoint for any US A2P 10DLC campaign flow. |
| 89 | |
| 90 | `client.Messaging10dlc.Brand.New()` — `POST /10dlc/brand` |
| 91 | |
| 92 | | Parameter | Type | Required | Description | |
| 93 | |-----------|------|----------|-------------| |
| 94 | | `EntityType` | object | Yes | Entity type behind the brand. | |
| 95 | | `DisplayName` | string | Yes | Display name, marketing name, or DBA name of the brand. | |
| 96 | | `Country` | string | Yes | ISO2 2 characters country code. | |
| 97 | | `Email` | string | Yes | Valid email address of brand support contact. | |
| 98 | | `Vertical` | object | Yes | Vertical or industry segment of the brand. | |
| 99 | | `CompanyName` | string | No | (Required for Non-profit/private/public) Legal company name. | |
| 100 | | `FirstName` | string | No | First name of business contact. | |
| 101 | | `LastName` | string | No | Last name of business contact. | |
| 102 | | ... | | | +16 optional params in [references/api-details.md](references/api-details.md) | |
| 103 | |
| 104 | ```go |
| 105 | telnyxBrand, err := client.Messaging10dlc.Brand.New(context.Background(), telnyx.Messaging10dlcBrandNewParams{ |
| 106 | Country: "US", |
| 107 | DisplayName: "ABC Mobile", |
| 108 | Email: "support@example.com", |
| 109 | EntityType: telnyx.EntityTypePrivateProfit, |
| 110 | Vertical: telnyx.VerticalTechnology, |
| 111 | }) |
| 112 | if err != nil { |
| 113 | log.Fatal(err) |
| 114 | } |
| 115 | fmt.Printf("%+v\n", telnyxBrand.IdentityStatus) |
| 116 | ``` |
| 117 | |
| 118 | Primary response fields: |
| 119 | - `telnyxBrand.BrandID` |
| 120 | - `telnyxBrand.IdentityStatus` |
| 121 | - `telnyxBrand.Status` |
| 122 | - `telnyxBrand.DisplayName` |
| 123 | - `telnyxBrand.State` |
| 124 | - `telnyxBrand.AltBusinessID` |
| 125 | |
| 126 | ### Submit a campaign |
| 127 | |
| 128 | Campaign submission is the compliance-critical step that determines whether traffic can be provisioned. |
| 129 | |
| 130 | `client.Messaging10dlc.CampaignBuilder.Submit()` — `POST /10dlc/campaignBuilder` |
| 131 | |
| 132 | | Parameter | Type | Required | Description | |
| 133 | |-----------|------|----------|-------------| |
| 134 | | `BrandId` | string (UUID) | Yes |