FireSMS
Examples

Bulk Send

Code examples for sending SMS to multiple recipients

📨 Bulk Send

Same message to everyone (multi mode)

Want to see these examples running end to end? Check out the firesms-examples repo on GitHub — fully working apps in Node.js, TypeScript, Python, and PHP.

curl -X POST https://firesms.vercel.app/api/v1/bulk-send \
  -H "Content-Type: application/json" \
  -d '{
    "api_key": "YOUR_API_KEY",
    "mode": "multi",
    "messages": [
      { "to": "27821234567", "text": "Your appointment is tomorrow at 9am." },
      { "to": "27831234567", "text": "Your appointment is tomorrow at 9am." },
      { "to": "27841234567", "text": "Your appointment is tomorrow at 9am." }
    ]
  }'
const numbers = ['27821234567', '27831234567', '27841234567'];
const text = 'Your appointment is tomorrow at 9am.';

const response = await fetch('https://firesms.vercel.app/api/v1/bulk-send', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    api_key: 'YOUR_API_KEY',
    mode: 'multi',
    messages: numbers.map(to => ({ to, text })),
  }),
});

const data = await response.json();
console.log(`Sent ${data.sent}/${data.total} — Cost: R${data.cost}`);
const numbers: string[] = ['27821234567', '27831234567', '27841234567'];
const text = 'Your appointment is tomorrow at 9am.';

const response = await fetch('https://firesms.vercel.app/api/v1/bulk-send', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    api_key: process.env.FIRESMS_API_KEY!,
    mode: 'multi',
    messages: numbers.map(to => ({ to, text })),
  }),
});

const data = await response.json();
console.log(`Sent ${data.sent}/${data.total} — Cost: R${data.cost}`);
import requests
import os

numbers = ['27821234567', '27831234567', '27841234567']
text = 'Your appointment is tomorrow at 9am.'

response = requests.post(
    'https://firesms.vercel.app/api/v1/bulk-send',
    json={
        'api_key': os.environ['FIRESMS_API_KEY'],
        'mode': 'multi',
        'messages': [{'to': n, 'text': text} for n in numbers],
    }
)

data = response.json()
print(f"Sent {data['sent']}/{data['total']} — Cost: R{data['cost']}")
<?php

$numbers = ['27821234567', '27831234567', '27841234567'];
$text = 'Your appointment is tomorrow at 9am.';

$messages = array_map(fn($n) => ['to' => $n, 'text' => $text], $numbers);

$response = file_get_contents('https://firesms.vercel.app/api/v1/bulk-send', false, stream_context_create([
    'http' => [
        'method'  => 'POST',
        'header'  => 'Content-Type: application/json',
        'content' => json_encode([
            'api_key'  => getenv('FIRESMS_API_KEY'),
            'mode'     => 'multi',
            'messages' => $messages,
        ]),
    ],
]));

$data = json_decode($response, true);
echo "Sent {$data['sent']}/{$data['total']} — Cost: R{$data['cost']}";

Personalised messages (multi mode)

curl -X POST https://firesms.vercel.app/api/v1/bulk-send \
  -H "Content-Type: application/json" \
  -d '{
    "api_key": "YOUR_API_KEY",
    "mode": "multi",
    "messages": [
      { "to": "27821234567", "text": "Hi John, your order #1042 has shipped!" },
      { "to": "27831234567", "text": "Hi Sarah, your order #1043 has shipped!" },
      { "to": "27841234567", "text": "Hi Thabo, your order #1044 has shipped!" }
    ]
  }'
const recipients = [
  { to: '27821234567', name: 'John',  order: '1042' },
  { to: '27831234567', name: 'Sarah', order: '1043' },
  { to: '27841234567', name: 'Thabo', order: '1044' },
];

const response = await fetch('https://firesms.vercel.app/api/v1/bulk-send', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    api_key: 'YOUR_API_KEY',
    mode: 'multi',
    messages: recipients.map(r => ({
      to: r.to,
      text: `Hi ${r.name}, your order #${r.order} has shipped!`,
    })),
  }),
});

const data = await response.json();
data.results.forEach(r => {
  console.log(`${r.to}: ${r.success ? '✓' : '✗ ' + r.error}`);
});
interface Recipient {
  to: string;
  name: string;
  order: string;
}

const recipients: Recipient[] = [
  { to: '27821234567', name: 'John',  order: '1042' },
  { to: '27831234567', name: 'Sarah', order: '1043' },
  { to: '27841234567', name: 'Thabo', order: '1044' },
];

const response = await fetch('https://firesms.vercel.app/api/v1/bulk-send', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    api_key: process.env.FIRESMS_API_KEY!,
    mode: 'multi',
    messages: recipients.map(r => ({
      to: r.to,
      text: `Hi ${r.name}, your order #${r.order} has shipped!`,
    })),
  }),
});

const data = await response.json();
data.results.forEach((r: { to: string; success: boolean; error?: string }) => {
  console.log(`${r.to}: ${r.success ? '✓' : '✗ ' + r.error}`);
});
import requests
import os

recipients = [
    { 'to': '27821234567', 'name': 'John',  'order': '1042' },
    { 'to': '27831234567', 'name': 'Sarah', 'order': '1043' },
    { 'to': '27841234567', 'name': 'Thabo', 'order': '1044' },
]

response = requests.post(
    'https://firesms.vercel.app/api/v1/bulk-send',
    json={
        'api_key': os.environ['FIRESMS_API_KEY'],
        'mode': 'multi',
        'messages': [
            {
                'to': r['to'],
                'text': f"Hi {r['name']}, your order #{r['order']} has shipped!",
            }
            for r in recipients
        ],
    }
)

data = response.json()
for result in data['results']:
    status = '✓' if result['success'] else f"✗ {result.get('error')}"
    print(f"{result['to']}: {status}")
<?php

$recipients = [
    ['to' => '27821234567', 'name' => 'John',  'order' => '1042'],
    ['to' => '27831234567', 'name' => 'Sarah', 'order' => '1043'],
    ['to' => '27841234567', 'name' => 'Thabo', 'order' => '1044'],
];

$messages = array_map(fn($r) => [
    'to'   => $r['to'],
    'text' => "Hi {$r['name']}, your order #{$r['order']} has shipped!",
], $recipients);

$response = file_get_contents('https://firesms.vercel.app/api/v1/bulk-send', false, stream_context_create([
    'http' => [
        'method'  => 'POST',
        'header'  => 'Content-Type: application/json',
        'content' => json_encode([
            'api_key'  => getenv('FIRESMS_API_KEY'),
            'mode'     => 'multi',
            'messages' => $messages,
        ]),
    ],
]));

$data = json_decode($response, true);
foreach ($data['results'] as $result) {
    $status = $result['success'] ? '✓' : '✗ ' . $result['error'];
    echo $result['to'] . ': ' . $status . PHP_EOL;
}

Scheduled campaign (batch mode)

curl -X POST https://firesms.vercel.app/api/v1/bulk-send \
  -H "Content-Type: application/json" \
  -d '{
    "api_key": "YOUR_API_KEY",
    "mode": "batch",
    "batchName": "April Promotion",
    "from": "FireSMS",
    "startTime": "2024-04-01 08:00:00",
    "messages": [
      { "to": "27821234567", "text": "Hi John, April special: 30% off all orders!" },
      { "to": "27831234567", "text": "Hi Sarah, April special: 30% off all orders!" }
    ]
  }'
const response = await fetch('https://firesms.vercel.app/api/v1/bulk-send', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    api_key: 'YOUR_API_KEY',
    mode: 'batch',
    batchName: 'April Promotion',
    from: 'FireSMS',
    startTime: '2024-04-01 08:00:00',
    messages: [
      { to: '27821234567', text: 'Hi John, April special: 30% off all orders!' },
      { to: '27831234567', text: 'Hi Sarah, April special: 30% off all orders!' },
    ],
  }),
});

const data = await response.json();
console.log('Batch ID:', data.batchId);
console.log('Scheduled for:', data.scheduled);
console.log('Total cost: R' + data.cost);
const response = await fetch('https://firesms.vercel.app/api/v1/bulk-send', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    api_key: process.env.FIRESMS_API_KEY!,
    mode: 'batch',
    batchName: 'April Promotion',
    from: 'FireSMS',
    startTime: '2024-04-01 08:00:00',
    messages: [
      { to: '27821234567', text: 'Hi John, April special: 30% off all orders!' },
      { to: '27831234567', text: 'Hi Sarah, April special: 30% off all orders!' },
    ],
  }),
});

const data = await response.json();
console.log('Batch ID:', data.batchId);
console.log('Scheduled for:', data.scheduled);
import requests
import os

response = requests.post(
    'https://firesms.vercel.app/api/v1/bulk-send',
    json={
        'api_key': os.environ['FIRESMS_API_KEY'],
        'mode': 'batch',
        'batchName': 'April Promotion',
        'from': 'FireSMS',
        'startTime': '2024-04-01 08:00:00',
        'messages': [
            { 'to': '27821234567', 'text': 'Hi John, April special: 30% off all orders!' },
            { 'to': '27831234567', 'text': 'Hi Sarah, April special: 30% off all orders!' },
        ],
    }
)

data = response.json()
print('Batch ID:', data['batchId'])
print('Scheduled for:', data['scheduled'])
print('Total cost: R' + data['cost'])
<?php

$response = file_get_contents('https://firesms.vercel.app/api/v1/bulk-send', false, stream_context_create([
    'http' => [
        'method'  => 'POST',
        'header'  => 'Content-Type: application/json',
        'content' => json_encode([
            'api_key'   => getenv('FIRESMS_API_KEY'),
            'mode'      => 'batch',
            'batchName' => 'April Promotion',
            'from'      => 'FireSMS',
            'startTime' => '2024-04-01 08:00:00',
            'messages'  => [
                ['to' => '27821234567', 'text' => 'Hi John, April special: 30% off all orders!'],
                ['to' => '27831234567', 'text' => 'Hi Sarah, April special: 30% off all orders!'],
            ],
        ]),
    ],
]));

$data = json_decode($response, true);
echo 'Batch ID: ' . $data['batchId'] . PHP_EOL;
echo 'Scheduled for: ' . $data['scheduled'] . PHP_EOL;
echo 'Total cost: R' . $data['cost'] . PHP_EOL;