$npx -y skills add team-telnyx/ai --skill telnyx-10dlc-ruby10DLC 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 - 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 | telnyx_brand = client.messaging_10dlc.brand.create( |
| 30 | country: "US", |
| 31 | display_name: "ABC Mobile", |
| 32 | email: "support@example.com", |
| 33 | entity_type: :PRIVATE_PROFIT, |
| 34 | vertical: :TECHNOLOGY |
| 35 | ) |
| 36 | puts(telnyx_brand) |
| 37 | ``` |
| 38 | |
| 39 | Common error codes: `401` invalid API key, `403` insufficient permissions, |
| 40 | `404` resource not found, `422` validation error (check field formats), |
| 41 | `429` rate limited (retry with exponential backoff). |
| 42 | |
| 43 | ## Important Notes |
| 44 | |
| 45 | - **Pagination:** Use `.auto_paging_each` for automatic iteration: `page.auto_paging_each { |item| puts item.id }`. |
| 46 | |
| 47 | ## Operational Caveats |
| 48 | |
| 49 | - 10DLC is sequential: create the brand first, then submit the campaign, then attach messaging infrastructure such as the messaging profile. |
| 50 | - Registration calls are not enough by themselves. Messaging cannot use the campaign until the assignment step completes successfully. |
| 51 | - 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. |
| 52 | |
| 53 | ## Reference Use Rules |
| 54 | |
| 55 | Do not invent Telnyx parameters, enums, response fields, or webhook fields. |
| 56 | |
| 57 | - 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. |
| 58 | - 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). |
| 59 | - Before reading or matching webhook fields beyond the inline examples, read [the webhook payload reference](references/api-details.md#webhook-payload-fields). |
| 60 | |
| 61 | ## Core Tasks |
| 62 | |
| 63 | ### Create a brand |
| 64 | |
| 65 | Brand registration is the entrypoint for any US A2P 10DLC campaign flow. |
| 66 | |
| 67 | `client.messaging_10dlc.brand.create()` — `POST /10dlc/brand` |
| 68 | |
| 69 | | Parameter | Type | Required | Description | |
| 70 | |-----------|------|----------|-------------| |
| 71 | | `entity_type` | object | Yes | Entity type behind the brand. | |
| 72 | | `display_name` | string | Yes | Display name, marketing name, or DBA name of the brand. | |
| 73 | | `country` | string | Yes | ISO2 2 characters country code. | |
| 74 | | `email` | string | Yes | Valid email address of brand support contact. | |
| 75 | | `vertical` | object | Yes | Vertical or industry segment of the brand. | |
| 76 | | `company_name` | string | No | (Required for Non-profit/private/public) Legal company name. | |
| 77 | | `first_name` | string | No | First name of business contact. | |
| 78 | | `last_name` | string | No | Last name of business contact. | |
| 79 | | ... | | | +16 optional params in [references/api-details.md](references/api-details.md) | |
| 80 | |
| 81 | ```ruby |
| 82 | telnyx_brand = client.messaging_10dlc.brand.create( |
| 83 | country: "US", |
| 84 | display_name: "ABC Mobile", |
| 85 | email: "support@example.com", |
| 86 | entity_type: :PRIVATE_PROFIT, |
| 87 | vertical: :TECHNOLOGY |
| 88 | ) |
| 89 | |
| 90 | puts(telnyx_brand) |
| 91 | ``` |
| 92 | |
| 93 | Primary response fields: |
| 94 | - `telnyx_brand.brandId` |
| 95 | - `telnyx_brand.identityStatus` |
| 96 | - `telnyx_brand.status` |
| 97 | - `telnyx_brand.displayName` |
| 98 | - `telnyx_brand.state` |
| 99 | - `telnyx_brand.altBusinessId` |
| 100 | |
| 101 | ### Submit a campaign |
| 102 | |
| 103 | Campaign submission is the compliance-critical step that determines whether traffic can be provisioned. |
| 104 | |
| 105 | `client.messaging_10dlc.campaign_builder.submit()` — `POST /10dlc/campaignBuilder` |
| 106 | |
| 107 | | Parameter | Type | Required | Description | |
| 108 | |-----------|------|----------|-------------| |
| 109 | | `brand_id` | string (UUID) | Yes | Alphanumeric identifier of the brand associated with this ca... | |
| 110 | | `description` | string | Yes | Summary description of this campaign. | |
| 111 | | `usecase` | string | Yes | Campaign usecase. | |
| 112 | | `age_gated` | boolean | No | Age gated message content in campaign. | |
| 113 | | `auto_renewal` | boolean | No | Campaign subscription auto-renewal option. | |
| 114 | | `direct_lending` | boolean | No | Direct lending or loan arrangement | |
| 115 | | ... | | | +29 optional params in [references/api-details.md](references/api-details.md) | |
| 116 | |
| 117 | ```ruby |
| 118 | telnyx_campaign_csp = client.messaging_10dlc.campaign_builder.submit( |
| 119 | brand_id: "BXXXXXX", |
| 120 | description: "Two-factor authentication messages", |
| 121 | usecase: "2FA", |
| 122 | sample1: "Your verification code is {{code}}", |
| 123 | ) |
| 124 | |
| 125 | puts(telnyx_campaign_csp) |
| 126 | ``` |
| 127 | |
| 128 | Primary response fields: |
| 129 | - `telnyx_camp |