Prerequisites
- A Telnyx account (free to create)
1. Get two phone numbers
Purchase two Telnyx numbers so you can test messaging between them without registration requirements.Go to Numbers
Navigate to Numbers > Search & Buy in the portal.
Search for numbers
Enter your preferred area code or region, check SMS under features, and click Search.
Having two numbers lets you test on-net (Telnyx-to-Telnyx) messaging immediately, and also test receiving inbound messages.
2. Create a Messaging Profile
Go to Messaging
Navigate to Messaging in the portal.
Assign both numbers
Go to My Numbers, and for each number, click the Messaging Profile dropdown, select your profile, and save.
3. Get your API key
Go to API Keys and copy your API key (or create one if needed).4. Send a message
- SMS
- MMS
YOUR_API_KEY: Your API key from step 3from: Your first Telnyx number (the sender)to: Your second Telnyx number (the recipient)
E.164 format is required. Always include the
+ prefix, country code, and full number with no spaces or punctuation.International number format examples
International number format examples
| Country | Format | Example |
|---|---|---|
| US/Canada | +1 + 10 digits | +15551234567 |
| UK | +44 + 10-11 digits (drop leading 0) | +447911123456 |
| Germany | +49 + 10-11 digits (drop leading 0) | +4915123456789 |
| Australia | +61 + 9 digits (drop leading 0) | +61412345678 |
| Brazil | +55 + 10-11 digits | +5511987654321 |
| India | +91 + 10 digits | +919876543210 |
- ❌
15551234567(missing+) - ❌
+1 (555) 123-4567(contains spaces and punctuation) - ❌
+1-555-123-4567(contains dashes) - ✅
+15551234567
Sending to non-Telnyx numbers? Off-net messaging to external carriers typically requires sender registration (10DLC, toll-free verification, etc.). See Next steps for registration guides.
Response
A successful response looks like this:status: "queued" means your message is on its way. Save the id to track delivery status.
Error handling
API errors return structured responses with error codes and messages. Handle these gracefully in your application:Common errors
| HTTP Status | Error | Solution |
|---|---|---|
401 | Invalid API key | Check your API key is correct and active |
403 | Number not enabled for messaging | Assign the from number to a messaging profile |
422 | Invalid from number format | Use E.164 format: +15551234567 |
422 | Invalid to number format | Use E.164 format: +15551234567 |
422 | Registration required | Register for 10DLC, toll-free verification, or another sender type |
422 | Message text too long | Split into multiple messages or reduce content |
402 | Insufficient balance | Add funds to your account |
For delivery failures (after the message was accepted), check webhook events like
message.finalized with status: "delivery_failed".