$npx -y skills add team-telnyx/ai --skill telnyx-10dlc-python10DLC 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 - Python |
| 4 | |
| 5 | ## Installation |
| 6 | |
| 7 | ```bash |
| 8 | pip install telnyx |
| 9 | ``` |
| 10 | |
| 11 | ## Setup |
| 12 | |
| 13 | ```python |
| 14 | import os |
| 15 | from telnyx import Telnyx |
| 16 | |
| 17 | client = Telnyx( |
| 18 | api_key=os.environ.get("TELNYX_API_KEY"), # This is the default and can be omitted |
| 19 | ) |
| 20 | ``` |
| 21 | |
| 22 | All examples below assume `client` is already initialized as shown above. |
| 23 | |
| 24 | ## Error Handling |
| 25 | |
| 26 | All API calls can fail with network errors, rate limits (429), validation errors (422), |
| 27 | or authentication errors (401). Always handle errors in production code: |
| 28 | |
| 29 | ```python |
| 30 | import telnyx |
| 31 | |
| 32 | try: |
| 33 | telnyx_brand = client.messaging_10dlc.brand.create( |
| 34 | country="US", |
| 35 | display_name="ABC Mobile", |
| 36 | email="support@example.com", |
| 37 | entity_type="PRIVATE_PROFIT", |
| 38 | vertical="TECHNOLOGY", |
| 39 | ) |
| 40 | except telnyx.APIConnectionError: |
| 41 | print("Network error — check connectivity and retry") |
| 42 | except telnyx.RateLimitError: |
| 43 | import time |
| 44 | time.sleep(1) # Check Retry-After header for actual delay |
| 45 | except telnyx.APIStatusError as e: |
| 46 | print(f"API error {e.status_code}: {e.message}") |
| 47 | if e.status_code == 422: |
| 48 | print("Validation error — check required fields and formats") |
| 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 | - **Pagination:** List methods return an auto-paginating iterator. Use `for item in page_result:` to iterate through all pages automatically. |
| 58 | |
| 59 | ## Operational Caveats |
| 60 | |
| 61 | - 10DLC is sequential: create the brand first, then submit the campaign, then attach messaging infrastructure such as the messaging profile. |
| 62 | - Registration calls are not enough by themselves. Messaging cannot use the campaign until the assignment step completes successfully. |
| 63 | - 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. |
| 64 | |
| 65 | ## Reference Use Rules |
| 66 | |
| 67 | Do not invent Telnyx parameters, enums, response fields, or webhook fields. |
| 68 | |
| 69 | - 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. |
| 70 | - 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). |
| 71 | - Before reading or matching webhook fields beyond the inline examples, read [the webhook payload reference](references/api-details.md#webhook-payload-fields). |
| 72 | |
| 73 | ## Core Tasks |
| 74 | |
| 75 | ### Create a brand |
| 76 | |
| 77 | Brand registration is the entrypoint for any US A2P 10DLC campaign flow. |
| 78 | |
| 79 | `client.messaging_10dlc.brand.create()` — `POST /10dlc/brand` |
| 80 | |
| 81 | | Parameter | Type | Required | Description | |
| 82 | |-----------|------|----------|-------------| |
| 83 | | `entity_type` | object | Yes | Entity type behind the brand. | |
| 84 | | `display_name` | string | Yes | Display name, marketing name, or DBA name of the brand. | |
| 85 | | `country` | string | Yes | ISO2 2 characters country code. | |
| 86 | | `email` | string | Yes | Valid email address of brand support contact. | |
| 87 | | `vertical` | object | Yes | Vertical or industry segment of the brand. | |
| 88 | | `company_name` | string | No | (Required for Non-profit/private/public) Legal company name. | |
| 89 | | `first_name` | string | No | First name of business contact. | |
| 90 | | `last_name` | string | No | Last name of business contact. | |
| 91 | | ... | | | +16 optional params in [references/api-details.md](references/api-details.md) | |
| 92 | |
| 93 | ```python |
| 94 | telnyx_brand = client.messaging_10dlc.brand.create( |
| 95 | country="US", |
| 96 | display_name="ABC Mobile", |
| 97 | email="support@example.com", |
| 98 | entity_type="PRIVATE_PROFIT", |
| 99 | vertical="TECHNOLOGY", |
| 100 | ) |
| 101 | print(telnyx_brand.identity_status) |
| 102 | ``` |
| 103 | |
| 104 | Primary response fields: |
| 105 | - `telnyx_brand.brand_id` |
| 106 | - `telnyx_brand.identity_status` |
| 107 | - `telnyx_brand.status` |
| 108 | - `telnyx_brand.display_name` |
| 109 | - `telnyx_brand.state` |
| 110 | - `telnyx_brand.alt_business_id` |
| 111 | |
| 112 | ### Submit a campaign |
| 113 | |
| 114 | Campaign submission is the compliance-critical step that determines whether traffic can be provisioned. |
| 115 | |
| 116 | `client.messaging_10dlc.campaign_builder.submit()` — `POST /10dlc/campaignBuilder` |
| 117 | |
| 118 | | Parameter | Type | Required | Description | |
| 119 | |-----------|------|----------|-------------| |
| 120 | | `brand_id` | string (UUID) | Yes | Alphanumeric identifier of the brand associated with this ca... | |
| 121 | | `description` | string | Yes | Summary description of this campaign. | |
| 122 | | `usecase` | string | Yes | Campaign usecase. | |
| 123 | | `age_gated` | boolean | No | Age gated message content in campaign. | |
| 124 | | `auto_renewal` | boolean | |