Introduction to Bandwidth SMS
Bandwidth is a Communications Platform as a Service (CPaaS) provider that offers programmable SMS messaging capabilities through its API. Bandwidth SMS enables businesses to:
- Send and receive SMS/MMS messages programmatically
- Provision and manage phone numbers
- Build automated messaging workflows
- Implement two-factor authentication
- Create customer notification systems
- Deploy messaging at scale with carrier-grade reliability
Unlike many SMS providers, Bandwidth owns and operates its own nationwide network, giving direct access to carriers with improved reliability and competitive pricing.
Core Bandwidth SMS Concepts
Key Components
| Component | Description |
|---|---|
| Dashboard | Web interface for account management, number provisioning, and analytics |
| Messaging API | RESTful API for sending/receiving messages programmatically |
| Phone Numbers | Voice and messaging-enabled numbers (local, toll-free, short codes) |
| Callbacks | Webhook notifications for message events (delivery, response) |
| Application | Configuration for routing messages and callbacks |
| Messaging Profile | Settings that control message handling and compliance |
Message Types
- SMS (Short Message Service): Text-only messages up to 160 characters per segment
- MMS (Multimedia Messaging Service): Messages with media attachments (images, audio, video)
- Group Messages: Messages sent to multiple recipients
- Long Messages: SMS messages that exceed 160 characters (automatically segmented)
Number Types
| Type | Features | Best For |
|---|---|---|
| Long Codes | Local 10-digit numbers | Person-to-person, low volume |
| Toll-Free | Numbers starting with 8XX | Business-to-consumer, higher volume |
| Short Codes | 5-6 digit numbers | Mass messaging, marketing campaigns |
| 10DLC | Registered 10-digit local codes | High-volume business messaging |
Getting Started with Bandwidth SMS
Account Setup Process
- Sign up for a Bandwidth account (requires business verification)
- Create a messaging application in the Bandwidth Dashboard
- Configure callback URLs for message events
- Order and provision phone numbers
- Associate numbers with your messaging application
- Generate API credentials (token, secret, account ID)
- Implement API calls in your application
Basic API Authentication
Authorization: Basic {Base64Encoded(username:password)}
Send SMS Message (Basic Example)
// POST https://messaging.bandwidth.com/api/v2/users/{accountId}/messages
{
"from": "+15551234567",
"to": ["+15557654321"],
"text": "Hello world!",
"applicationId": "93de2206-9669-4e07-948d-329f4b722ee2"
}
Receive SMS Callbacks
// Example callback received at your callback URL
{
"type": "message-received",
"time": "2023-02-15T16:33:10.220Z",
"description": "Incoming message received",
"to": "+15551234567",
"message": {
"id": "1589228737852541894",
"owner": "+15551234567",
"time": "2023-02-15T16:33:10.220Z",
"direction": "in",
"from": "+15557654321",
"text": "Hello back!",
"applicationId": "93de2206-9669-4e07-948d-329f4b722ee2"
}
}
Advanced SMS Features
Rich Messaging Capabilities
| Feature | Description | Example/Format |
|---|---|---|
| MMS | Send images, audio, videos | Include “media”: [“https://example.com/image.jpg”] in request |
| Unicode/Emoji | Support for non-ASCII characters | Simply include in the text field |
| Message Scheduling | Delayed message sending | Use “scheduleTime”: “2023-06-01T19:00:00Z” |
| Message Tags | Custom identifiers for tracking | Add “tag”: “promotion-june2023” to request |
Group Messaging Options
- Multiple Recipients: Send to up to 10 recipients per API call
- Group Reply Settings: Configure how replies from group messages are handled
- Individual replies (default)
- Group replies (all recipients see all responses)
Delivery Receipt Status Codes
| Code | Status | Description |
|---|---|---|
| 0 | Delivered | Message successfully delivered to recipient |
| 1 | Failed | Permanent failure, message not delivered |
| 2 | Sent | Message sent to carrier, awaiting confirmation |
| 3 | No Delivery Receipt | No receipt received from carrier |
| 4 | Unknown | Status unknown or unrecognized |
API Reference
Endpoint Structure
- Base URL:
https://messaging.bandwidth.com/api/v2/users/{accountId}/ - Message Endpoint:
messages - Media Endpoint:
media
Common Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| from | string | Yes | Sender phone number |
| to | array | Yes | Recipient phone number(s) |
| text | string | Yes* | Message content (*required unless media is present) |
| applicationId | string | Yes | Your Bandwidth application ID |
| media | array | No | URLs of media to attach (for MMS) |
| tag | string | No | Custom identifier for the message |
| priority | string | No | “normal” or “high” delivery priority |
| callbackUrl | string | No | Override default callback URL |
Media Handling
Upload Media:
PUT /api/v2/users/{accountId}/media/{mediaName} Content-Type: [appropriate MIME type]Reference in Message:
{ "from": "+15551234567", "to": ["+15557654321"], "text": "Check out this image", "media": ["https://messaging.bandwidth.com/api/v2/users/{accountId}/media/{mediaName}"] }Supported Media Types:
- Images: JPEG, PNG, GIF
- Audio: MP3, WAV
- Video: MP4
- Documents: PDF
Compliance and Regulations
Messaging Regulations
| Region | Key Regulations | Requirements |
|---|---|---|
| US | TCPA, CTIA Guidelines | Opt-in consent, clear identification, opt-out mechanism |
| Canada | CASL | Express consent, identification, unsubscribe mechanism |
| UK/EU | GDPR, PECR | Explicit consent, data protection, opt-out process |
10DLC Registration Requirements
- Brand Registration: Company details, use cases, sample messages
- Campaign Registration: Campaign details, message volume, opt-in processes
- Trust Score: Affects throughput and deliverability
- Compliance Monitoring: Ongoing monitoring of spam complaints and opt-out rates
Opt-Out Handling
- Standard Keywords: STOP, CANCEL, UNSUBSCRIBE, QUIT, END
- Automatic Processing: Bandwidth automatically handles standard opt-out keywords
- Custom Implementation: Implement custom opt-out logic using callbacks
Common Challenges and Solutions
| Challenge | Cause | Solution |
|---|---|---|
| Message Filtering | Carrier blocking due to spam suspicion | Follow best practices, register 10DLC, avoid spam triggers |
| Delayed Delivery | Network congestion, carrier issues | Implement retry logic, monitor delivery receipts |
| Failed MMS | Unsupported media type or size | Use supported formats, keep files under 1.5MB |
| Low Throughput | Rate limiting, capacity issues | Implement queuing, use proper number type for volume |
| Missing Callbacks | Network issues, URL configuration | Verify callback URL, implement retry handling |
Best Practices and Optimization Tips
Message Content Optimization
- Keep messages concise (under 160 characters when possible)
- Avoid URL shorteners that aren’t well-known
- Limit use of ALL CAPS and excessive punctuation (!!!!)
- Personalize messages when appropriate
- Include clear sender identification
- Provide value in every message
Technical Implementation Tips
- Implement Idempotency: Use message IDs to prevent duplicates
- Handle Delivery Receipts: Process DLRs to confirm delivery
- Implement Queuing: Buffer messages during rate limiting
- Error Handling: Gracefully handle API errors and retries
- Log Management: Track messages for troubleshooting
- Monitoring: Set up alerts for delivery failures or unusual patterns
Security Best Practices
- Use HTTPS for all API communications
- Rotate API credentials periodically
- Implement IP restrictions for API access
- Validate and sanitize all user inputs
- Store phone numbers securely (encrypt sensitive data)
- Use webhook signatures to verify callback authenticity
Performance Optimization
Throughput Maximization
| Number Type | Typical Throughput | Optimization Techniques |
|---|---|---|
| Local Numbers | 1 msg/sec | Use multiple numbers, implement queuing |
| Toll-Free | 3 msg/sec | Register for higher throughput |
| 10DLC | 15-100 msg/sec (varies) | Complete full brand and campaign registration |
| Short Codes | 100+ msg/sec | Best for highest volume needs |
Handling Rate Limiting
- HTTP 429 Response: Indicates rate limiting
- Retry Strategy: Implement exponential backoff
- Batching: Group messages to similar recipients
- Time-of-Day Optimization: Spread non-urgent messages across off-peak hours
Resources for Further Learning
Official Documentation
Code Libraries
Community Resources
- Bandwidth Developer Forums
- GitHub Examples Repository
- Bandwidth Status Page
- Support Knowledge Base
Contact Support
- Developer Support: support@bandwidth.com
- API Status: status.bandwidth.com
- Sales Inquiries: 855-864-7776
Note: This cheatsheet is for reference purposes only. Always refer to the official Bandwidth documentation for the most up-to-date information, as APIs and features may change.
