Frequently Asked Questions
Use Node.js with Express, the MessageBird API, and a batch sending service to efficiently handle large volumes of SMS messages. This setup allows you to send messages concurrently in controlled batches, minimizing server load and respecting API rate limits, which is crucial for bulk sending.
MessageBird is a Communication Platform as a Service (CPaaS) that provides a reliable SMS API with global reach. In a Node.js SMS application, MessageBird's Node.js SDK is used to interact with their API to actually send the SMS messages.
Express.js simplifies building a robust API endpoint to manage bulk SMS sending. It provides a structured framework for handling requests, routing, middleware (like validation and rate limiting), and responses, making it easier to organize and maintain your bulk SMS application logic.
Batching is essential when sending SMS to large recipient lists to avoid overwhelming server resources and hitting API rate limits. The article recommends starting with a batch size of 50 and a 1-second delay between batches, but these parameters should be adjusted based on testing and your MessageBird account limits.
Store your MessageBird Live API Access Key securely in a .env file, which should be added to your .gitignore. Then, load these environment variables into your Node.js application using the dotenv package. This keeps your API key secret and separate from your code.
Express-validator provides middleware for input validation and sanitization, ensuring your API receives data in the correct format, which is crucial for preventing errors. It's used to validate that recipients are provided as a non-empty array of strings and that the message body is a non-empty string.
Rate limiting protects your application from abuse and helps ensure you stay within MessageBird's API usage limits. The express-rate-limit middleware allows you to control the number of bulk send requests from a given IP address within a specific timeframe, preventing overload.
A persistent job queue, like BullMQ or Kue, is strongly recommended for production bulk SMS applications, especially with large volumes. This ensures that messages are sent reliably even if the server restarts and provides better scalability and retry mechanisms for failed sends.
A suitable schema includes a 'users' table with phone numbers, subscription status, and other user details. An 'sms_campaign_messages' table tracks campaign details, individual message statuses (e.g., pending, sent, failed), and links back to the user. Proper indexing is vital for performance.
Handle MessageBird API errors inside the Promise within your messaging service. Log the error details, collect them in a results object, and implement selective retries for transient errors like timeouts or 5xx server errors, but avoid retrying non-recoverable errors like invalid recipient or originator format.
The MESSAGEBIRD_ORIGINATOR
environment variable sets the sender ID that recipients see. It must be a valid, purchased MessageBird number in E.164 format (e.g., +12025550187) or a registered alphanumeric sender ID. An incorrect originator will lead to errors.
Secure your bulk SMS endpoint using API key authentication (e.g., via headers), input validation, rate limiting, and appropriate authorization mechanisms. Never expose your MessageBird API key directly in client-side code or commit it to version control.
Use a library like async-retry or implement manual exponential backoff within the Promise handling each message send. Only retry on transient errors (timeouts, 5xx) and implement logic to avoid retrying non-recoverable errors (invalid recipient, insufficient balance).
Batch size controls the number of messages sent concurrently. A larger batch size increases throughput but also increases the risk of server overload or hitting API rate limits. It's crucial to tune this parameter based on testing and your server resources.
Yes, you can use a registered alphanumeric sender ID (up to 11 characters) as the MESSAGEBIRD_ORIGINATOR, but availability and regulations vary by country. Check MessageBird's documentation for specific requirements and register your sender ID in the MessageBird Dashboard if needed.
How to Send Bulk SMS with MessageBird Node.js and Express (2025 Guide)
Send bulk SMS messages efficiently using MessageBird's API with Node.js and Express. This tutorial shows you how to build a production-ready bulk SMS broadcasting system with proper batching, rate limiting, error handling, and delivery tracking.
What You'll Build:
Prerequisites:
Table of Contents:
What Is Bulk SMS Broadcasting?
Bulk SMS broadcasting lets you send the same message to multiple recipients simultaneously—a critical capability for modern business communications. You'll use this for:
Marketing Campaigns: Send promotional messages to your customer base and drive engagement
Emergency Alerts: Notify users about urgent situations requiring immediate attention
System Notifications: Broadcast service updates, maintenance windows, or status changes
Event Reminders: Send reminders to registered attendees to reduce no-shows
MessageBird's Bulk Messaging Capabilities:
Why Use MessageBird for Bulk SMS?
MessageBird provides enterprise-grade SMS infrastructure with direct carrier connections in 190+ countries, competitive pricing starting at $0.0075 per message, and a developer-friendly API. The Node.js SDK simplifies integration and handles authentication, request formatting, and error handling automatically—making it ideal for developers building bulk SMS solutions with Node.js and Express.
Set Up Your MessageBird Account
You need a MessageBird account and API key to follow this tutorial.
Step 1: Create MessageBird Account
Step 2: Get Your API Key
live_
)test_
)Important Security Notes:
MessageBird Pricing Overview:
MessageBird charges per message segment sent. Costs vary by destination country:
Check MessageBird's pricing page for current rates in your target countries.
Initialize Your Node.js Project
Set up a new Node.js project with Express and MessageBird dependencies. This foundation enables you to build a production-ready bulk SMS API.
Create Project Directory:
Install Required Packages:
Package Versions (January 2025):
express
: ^4.18.0 – Web frameworkmessagebird
: ^4.0.0 – Official MessageBird SDKdotenv
: ^16.4.0 – Environment variable managementexpress-validator
: ^7.0.0 – Request validationexpress-rate-limit
: ^7.1.0 – API rate limitingCreate Environment File (.env):
Add .env to .gitignore:
Project Structure:
Build the Bulk SMS Broadcasting Endpoint
Create a REST API endpoint that accepts recipient lists and broadcasts messages efficiently. This endpoint forms the core of your bulk SMS system, handling input validation, batching, and response formatting.
Create server.js:
Key Implementation Details:
Batching Logic: You split large recipient lists into batches of 50 (MessageBird's maximum per request). This prevents API rejections and improves reliability.
Rate Limiting: You implement a 1-second delay between batches to respect MessageBird's rate limits (500 requests/second for POST operations, verified January 2025).
Error Handling: You track both successful deliveries and failures, returning detailed results for each batch.
Delivery Status Tracking: You store message IDs for later status checks through MessageBird's delivery reports.
How Batching and Rate Limiting Work
Intelligent batching and rate limiting are essential for reliable bulk SMS delivery. Understanding MessageBird's API constraints helps you optimize throughput while avoiding rate limit errors.
MessageBird API Rate Limits (Verified January 2025):
How to Calculate Optimal Batch Size:
MessageBird allows up to 50 recipients per request. With a 500 req/s limit:
Tuning Parameters:
When to Adjust Batch Size:
Advanced Batching Strategies:
For campaigns exceeding 100,000 recipients, consider implementing:
Track Message Delivery Status
Monitor message delivery in real-time using MessageBird's delivery status webhooks and API. Tracking delivery status is crucial for campaign analytics, compliance reporting, and troubleshooting delivery issues.
How MessageBird Delivery Tracking Works:
When you send messages, MessageBird returns a unique message ID for each batch. You use these IDs to:
Message Status Values:
scheduled
– You scheduled the message for future deliverysent
– MessageBird sent the message to the carrierbuffered
– The carrier queued the message for deliverydelivered
– The recipient received the messageexpired
– The message expired before deliverydelivery_failed
– Delivery failed permanentlyCreate Status Checking Endpoint:
Set Up Delivery Report Webhooks:
You can configure webhooks to receive real-time delivery updates instead of polling the API.
In MessageBird Dashboard:
https://your-domain.com/api/webhooks/delivery-status
Webhook Handler:
Best Practices for Delivery Tracking:
Handle Errors and Failed Deliveries
When sending bulk SMS, you'll encounter various error codes that indicate different failure types. Understanding these errors helps you implement effective retry logic and maintain high delivery rates.
Common MessageBird Error Codes:
EC_UNKNOWN_SUBSCRIBER
EC_ABSENT_SUBSCRIBER
EC_ILLEGAL_SUBSCRIBER
EC_FACILITY_NOT_SUPPORTED
EC_SUBSCRIBER_OPTEDOUT
EC_SENDER_UNREGISTERED
Implement Comprehensive Error Handling:
Error Logging Best Practices:
You should log errors with sufficient detail for debugging while protecting sensitive information:
Handling Opt-Out Requests:
When you receive error code 103 (EC_SUBSCRIBER_OPTEDOUT), immediately:
Optimize Bulk SMS Performance
Significantly improve throughput and reliability with proven optimization techniques. Performance optimization is critical when scaling from hundreds to thousands of messages per minute.
Use Job Queues for Large-Scale Sending:
For campaigns exceeding 10,000 recipients, you should use a job queue system to handle processing asynchronously.
Example with BullMQ:
Database Optimization:
You should store recipient data efficiently to support fast bulk operations:
Caching Strategy:
You can cache MessageBird API responses to reduce redundant lookups:
Monitor Performance Metrics:
You should track these key metrics to identify bottlenecks:
Recommended Monitoring Tools:
Security Best Practices:
Validate and Format Phone Numbers
Phone number validation is essential before sending bulk SMS—it reduces wasted API calls, improves delivery rates, and ensures MessageBird can properly route messages to international carriers.
Install Phone Number Validation Library:
Implement E.164 Format Validation:
MessageBird requires phone numbers in E.164 format:
+[country code][subscriber number]
(no spaces, hyphens, or parentheses).Examples of Valid E.164 Format:
+12025550123
(country code 1 + 10-digit number)+447911123456
(country code 44 + mobile number)+31612345678
(country code 31 + mobile number)Bulk Validation Function:
Character Encoding and Message Segmentation:
You should understand how message length affects costs:
Check Message Segment Count:
Sender ID Best Practices:
You can use alphanumeric sender IDs (like "YourBrand") or phone numbers:
Sender ID Registration by Country:
Test Your Bulk SMS System
Thoroughly testing your bulk SMS implementation before production deployment is critical. Testing helps identify rate limiting issues_ validates error handling_ and ensures your system can handle expected load.
Manual Testing with curl:
Expected Response:
Automated Testing Recommendations:
You should implement unit tests for critical functions:
Load Testing:
You should test your system under realistic load conditions:
Test Scenarios to Cover:
Deploy Your Bulk SMS System to Production
Proper deployment configuration ensures production reliability, scalability, and security. Production deployments require environment-specific settings, monitoring, and infrastructure that differs from development.
Environment Configuration:
Create separate environment files for each stage:
Production Dockerfile:
Docker Compose for Complete Stack:
Job Queue Setup for Production:
You should use a robust job queue system for campaigns exceeding 10,000 recipients:
Option 1: BullMQ with Redis (Recommended)
Option 2: AWS SQS for Serverless
Option 3: RabbitMQ for Enterprise
Monitoring and Alerting:
You should monitor these critical metrics:
Recommended Monitoring Tools:
Security Best Practices:
FAQ: Bulk SMS with MessageBird, Node.js, and Express
How many SMS messages can I send per second with MessageBird?
MessageBird supports up to 500 POST requests per second, with each request handling up to 50 recipients. This means you can theoretically send to 25,000 recipients per second. However, we recommend a practical limit of 10,000–15,000 recipients per second with proper batching and 1-second delays to ensure reliability and avoid rate limit errors.
What is the maximum number of recipients per MessageBird API request?
MessageBird allows a maximum of 50 recipients per API request. For larger campaigns, you need to split recipients into batches of 50 and send multiple requests with appropriate delays between batches to respect rate limits.
How much does it cost to send bulk SMS with MessageBird?
MessageBird pricing varies by destination country. US/Canada messages cost $0.0075–$0.015 per SMS segment, Europe costs $0.02–$0.08 per segment, and Asia-Pacific costs $0.015–$0.12 per segment. Multi-segment messages (over 160 characters for GSM-7 or 70 characters for Unicode) multiply these costs. Check MessageBird's pricing page for current rates.
How do I handle phone number validation for international bulk SMS?
Use the
libphonenumber-js
library to validate and format phone numbers in E.164 format (+[country code][subscriber number]
). This ensures MessageBird can properly route messages to international carriers. Always validate numbers before sending to avoid wasted API calls and delivery failures. See our E.164 phone format guide for more details.What happens if a bulk SMS message fails to deliver?
MessageBird returns specific error codes for failed deliveries. Common failures include invalid numbers (error code 1), opted-out recipients (error code 103), and unregistered sender IDs (error code 104). Implement retry logic for temporary failures (like phones being turned off) and remove permanently failed numbers from your lists. Use delivery webhooks to monitor real-time status updates.
How do I set up delivery tracking for bulk SMS campaigns?
Configure MessageBird delivery webhooks in your dashboard under Developers → Webhooks. Set your webhook URL (e.g.,
https://your-domain.com/api/webhooks/delivery-status
) and select Message Status Updates. MessageBird will POST delivery status changes to your endpoint in real-time, allowing you to trackdelivered
,failed
,expired
, and other statuses without polling the API.Can I schedule bulk SMS messages for future delivery with MessageBird?
Yes, MessageBird supports scheduled message delivery. Add a
scheduledDatetime
parameter to your API request in ISO 8601 format (e.g.,2025-01-20T14:30:00Z
). This is useful for time-zone-optimized campaigns, appointment reminders, and promotional messages during peak engagement hours.What's the difference between GSM-7 and UCS-2 encoding for SMS?
GSM-7 encoding supports 160 characters per SMS segment and includes standard Latin characters, numbers, and basic punctuation. UCS-2 encoding supports 70 characters per segment and is required for Unicode characters like emojis, Chinese/Arabic text, and special symbols. UCS-2 messages cost more due to fewer characters per segment. Use the
calculateSegments()
function in this tutorial to estimate costs before sending.How do I register a sender ID for bulk SMS in the United States?
US A2P (Application-to-Person) messaging requires 10DLC registration through MessageBird. The process takes 2–4 weeks and includes business verification, use case approval, and brand registration. Without 10DLC registration, your messages may be blocked or heavily filtered by US carriers. Check MessageBird's documentation for country-specific sender ID requirements.
What's the best architecture for sending millions of SMS messages?
For campaigns exceeding 100,000 recipients, use a job queue system like BullMQ with Redis or AWS SQS. Split recipients into batches of 10,000–50,000 per job, process jobs asynchronously with worker processes, implement retry logic for failed batches, and monitor queue depth and processing lag. This architecture allows horizontal scaling and prevents API rate limit errors while maintaining high throughput.
Launch Your Production Bulk SMS System
You now have a complete, production-ready bulk SMS broadcasting system built with MessageBird, Node.js, and Express. This implementation provides everything needed to send high-volume SMS campaigns reliably and efficiently.
Your system includes intelligent batching, rate limiting, comprehensive error handling, delivery tracking, and phone number validation—all essential components for enterprise-grade bulk messaging.
What You Built:
Next Steps to Enhance Your System:
Related Guides:
Additional Resources:
You're ready to start sending bulk SMS messages efficiently and reliably using MessageBird!