$npx -y skills add team-telnyx/ai --skill telnyx-10dlc-javascript10DLC 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 - JavaScript |
| 4 | |
| 5 | ## Installation |
| 6 | |
| 7 | ```bash |
| 8 | npm install telnyx@6.74.2 |
| 9 | ``` |
| 10 | |
| 11 | ## Setup |
| 12 | |
| 13 | ```javascript |
| 14 | import Telnyx from 'telnyx'; |
| 15 | |
| 16 | const client = new Telnyx({ |
| 17 | apiKey: process.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 | ```javascript |
| 29 | try { |
| 30 | const telnyxBrand = await client.messaging10dlc.brand.create({ |
| 31 | country: 'US', |
| 32 | displayName: 'ABC Mobile', |
| 33 | email: 'support@example.com', |
| 34 | entityType: 'PRIVATE_PROFIT', |
| 35 | vertical: 'TECHNOLOGY', |
| 36 | }); |
| 37 | } catch (err) { |
| 38 | if (err instanceof Telnyx.APIConnectionError) { |
| 39 | console.error('Network error — check connectivity and retry'); |
| 40 | } else if (err instanceof Telnyx.RateLimitError) { |
| 41 | const retryAfter = err.headers?.['retry-after'] || 1; |
| 42 | await new Promise(r => setTimeout(r, retryAfter * 1000)); |
| 43 | } else if (err instanceof Telnyx.APIError) { |
| 44 | console.error(`API error ${err.status}: ${err.message}`); |
| 45 | if (err.status === 422) { |
| 46 | console.error('Validation error — check required fields and formats'); |
| 47 | } |
| 48 | } |
| 49 | } |
| 50 | ``` |
| 51 | |
| 52 | Common error codes: `401` invalid API key, `403` insufficient permissions, |
| 53 | `404` resource not found, `422` validation error (check field formats), |
| 54 | `429` rate limited (retry with exponential backoff). |
| 55 | |
| 56 | ## Important Notes |
| 57 | |
| 58 | - **Pagination:** List methods return an auto-paginating iterator. Use `for await (const item of result) { ... }` to iterate through all pages automatically. |
| 59 | |
| 60 | ## Operational Caveats |
| 61 | |
| 62 | - 10DLC is sequential: create the brand first, then submit the campaign, then attach messaging infrastructure such as the messaging profile. |
| 63 | - Registration calls are not enough by themselves. Messaging cannot use the campaign until the assignment step completes successfully. |
| 64 | - 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. |
| 65 | |
| 66 | ## Reference Use Rules |
| 67 | |
| 68 | Do not invent Telnyx parameters, enums, response fields, or webhook fields. |
| 69 | |
| 70 | - 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. |
| 71 | - 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). |
| 72 | - Before reading or matching webhook fields beyond the inline examples, read [the webhook payload reference](references/api-details.md#webhook-payload-fields). |
| 73 | |
| 74 | ## Core Tasks |
| 75 | |
| 76 | ### Create a brand |
| 77 | |
| 78 | Brand registration is the entrypoint for any US A2P 10DLC campaign flow. |
| 79 | |
| 80 | `client.messaging10dlc.brand.create()` — `POST /10dlc/brand` |
| 81 | |
| 82 | | Parameter | Type | Required | Description | |
| 83 | |-----------|------|----------|-------------| |
| 84 | | `entityType` | object | Yes | Entity type behind the brand. | |
| 85 | | `displayName` | string | Yes | Display name, marketing name, or DBA name of the brand. | |
| 86 | | `country` | string | Yes | ISO2 2 characters country code. | |
| 87 | | `email` | string | Yes | Valid email address of brand support contact. | |
| 88 | | `vertical` | object | Yes | Vertical or industry segment of the brand. | |
| 89 | | `companyName` | string | No | (Required for Non-profit/private/public) Legal company name. | |
| 90 | | `firstName` | string | No | First name of business contact. | |
| 91 | | `lastName` | string | No | Last name of business contact. | |
| 92 | | ... | | | +16 optional params in [references/api-details.md](references/api-details.md) | |
| 93 | |
| 94 | ```javascript |
| 95 | const telnyxBrand = await client.messaging10dlc.brand.create({ |
| 96 | country: 'US', |
| 97 | displayName: 'ABC Mobile', |
| 98 | email: 'support@example.com', |
| 99 | entityType: 'PRIVATE_PROFIT', |
| 100 | vertical: 'TECHNOLOGY', |
| 101 | }); |
| 102 | |
| 103 | console.log(telnyxBrand.identityStatus); |
| 104 | ``` |
| 105 | |
| 106 | Primary response fields: |
| 107 | - `telnyxBrand.brandId` |
| 108 | - `telnyxBrand.identityStatus` |
| 109 | - `telnyxBrand.status` |
| 110 | - `telnyxBrand.displayName` |
| 111 | - `telnyxBrand.state` |
| 112 | - `telnyxBrand.altBusinessId` |
| 113 | |
| 114 | ### Submit a campaign |
| 115 | |
| 116 | Campaign submission is the compliance-critical step that determines whether traffic can be provisioned. |
| 117 | |
| 118 | `client.messaging10dlc.campaignBuilder.submit()` — `POST /10dlc/campaignBuilder` |
| 119 | |
| 120 | | Parameter | Type | Required | Description | |
| 121 | |-----------|------|----------|-------------| |
| 122 | | `brandId` | string (UUID) | Yes | Alphanumeric identifier of the brand associated with this ca... | |
| 123 | | `description` | string | Yes | Summary description of thi |