BulkSMSSender

FREEMIUM
By Marc du Plessis | Updated a month ago | SMS
Popularity

0.2 / 10

Latency

1,390ms

Service Level

100%

Health Check

N/A

README

Bulk SMS Sender


The Bulk SMS Sender API is a powerful tool that allows you to send SMS messages in bulk to multiple recipients quickly and efficiently. Whether youโ€™re sending notifications, alerts, or marketing messages, this API simplifies the process.

Table of Contents

Getting Started

Prerequisites

Before you start using the Bulk SMS API, make sure you have the following:

  • Twilio account credentials (Account SID and Auth Token)
  • A Twilio phone number (for the โ€˜fromโ€™ field)

Usage

Authentication

To use the Bulk SMS API, you need to provide your Twilio account credentials and a Twilio phone number. These should be included in the headers of your HTTP request:

  • X-Twilio-AccountSid: Your Twilio Account SID
  • X-Twilio-AuthToken: Your Twilio Auth Token
  • X-Twilio-Number: Your Twilio phone number (from which the SMS messages will be sent)

Sending Bulk SMS

To send SMS messages in bulk, make a POST request to the API endpoint. The request should include the following:

  • numbers: An array of recipient phone numbers (in E.164 format).
  • message: The text message you want to send.

Hereโ€™s an example using cURL:

curl -X POST https://rapid-api-url.com/sendBulkSMS \
  -H "X-Twilio-AccountSid: YOUR_TWILIO_ACCOUNT_SID" \
  -H "X-Twilio-AuthToken: YOUR_TWILIO_AUTH_TOKEN" \
  -H "X-Twilio-Number: YOUR_TWILIO_PHONE_NUMBER" \
  -H "Content-Type: application/json" \
  -d '{
    "numbers": ["+1234567890", "+9876543210"],
    "message": "Hello from Bulk SMS API!"
  }'

Nodejs example:

const axios = require('axios');

const RAPIDAPI_KEY = 'YOUR_RAPIDAPI_KEY';
const BULK_SMS_API_ENDPOINT = 'https://rapidapi.com/bulksms/sendBulkSMS';

// Twilio credentials
const TWILIO_ACCOUNT_SID = 'YOUR_TWILIO_ACCOUNT_SID';
const TWILIO_AUTH_TOKEN = 'YOUR_TWILIO_AUTH_TOKEN';
const TWILIO_NUMBER = 'YOUR_TWILIO_NUMBER';

async function sendBulkSMS(numbers, message) {
  try {
    const response = await axios.post(BULK_SMS_API_ENDPOINT, {
      numbers: numbers,
      message: message
    }, {
      headers: {
       'X-RapidAPI-Key': RAPIDAPI_KEY,
       'X-Twilio-AccountSid': TWILIO_ACCOUNT_SID,
       'X-Twilio-AuthToken': TWILIO_AUTH_TOKEN,
       'X-Twilio-Number': TWILIO_NUMBER,
       'Content-Type': 'application/json'
      }
    });

    return response.data;
  } catch (error) {
    throw error;
  }
}

// Usage example
const numbers = ['+1234567890', '+9876543210'];
const message = 'Hello from Bulk SMS API!';

sendBulkSMS(numbers, message)
  .then(data => {
    console.log('SMS sent successfully!');
    console.log(`Successful: ${data.successful}`);
    console.log(`Failed: ${data.failed}`);
  })
  .catch(error => {
    console.error('Error sending SMS:', error.message);
  });

API Reference

  • POST /sendBulkSMS: Send SMS messages in bulk.

Request Body:

{
  "numbers": ["string"],
  "message": "string"
}

Response:

{
  "successful": 2,
  "failed": 0,
  "messages": [
    {
      "to": "+1234567890",
      "body": "Hello from BulkSMSSender"
      "status": "delivered",
      "errorMessage": null,
      "success": true
    },
    {
      "to": "+9876543210",
      "body": "Hello from BulkSMSSender"
      "status": "delivered",
      "errorMessage": null,
      "success": true
    }
  ]
}

Error Handling

The API provides detailed error messages to help you identify and resolve issues. Common error scenarios include:

  • Invalid Twilio credentials.
  • Invalid recipient phone numbers.
  • Message sending failures.

Examples

Check out the examples directory for sample code and usage scenarios.

FAQs

Q: How can I obtain Twilio credentials?

A: You can sign up for a Twilio account at https://www.twilio.com/. Once registered, you will find your Account SID and Auth Token in your Twilio Dashboard.

Q: What is the E.164 format for phone numbers?

A: E.164 is a standardized format for phone numbers. It includes the country code, area code, and the local number. For example, a U.S. phone number in E.164 format looks like this: +1XXXXXXXXXX.

Followers: 1
API Creator:
Rapid account: Marc Du Plessis
Marc du Plessis
marcduplessis1
Log In to Rate API
Rating: 5 - Votes: 1