Send a batch of different messages
http
POST https://smsprovider-web.vercel.app/api/v1/messages/batchUp to 2,500 different messages in one request (a different text per recipient).
Authentication: Authorization: Bearer bm_live_… · Required scope: sms:send
Send an Idempotency-Key header (a unique string, e.g. a UUID). Repeating the same key within 24 hours returns the same response without charging again.Request body
| Field | Type | Required | Notes |
|---|---|---|---|
messages | object[] | yes | items 1–2500 |
from | string | no | len 2–20 |
schedule_at | string (date-time) | no | |
campaign_name | string | no | len 1–50 |
allow_international | boolean | no |
Response
200 — SendResult
Errors
| Status | Code |
|---|---|
| 400 | validation_error |
| 400 | idempotency_key_required |
| 409 | idempotency_conflict |
| 402 | insufficient_credits |
| 403 | sender_not_verified |
| 422 | invalid_destination |
| 429 | daily_limit_exceeded |
| 403 | org_suspended |
| 401 | unauthorized |
| 403 | insufficient_scope |
| 429 | rate_limited |
| 500 | internal_error |
Examples
curl
bash
curl -X POST "https://smsprovider-web.vercel.app/api/v1/messages/batch" \
-H "Authorization: Bearer $BATLER_API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{"from":"MyBrand","messages":[{"to":"0501234567","body":"דנה, התור שלך מחר ב-10:00","ref":"appt-1"},{"to":"0527654321","body":"יוסי, התור שלך מחר ב-11:30","ref":"appt-2"}]}'Node.js
ts
import { BatlerSMS } from "@batler/sms";
const sms = new BatlerSMS({ apiKey: process.env.BATLER_API_KEY! });
const body = {
"from": "MyBrand",
"messages": [
{
"to": "0501234567",
"body": "דנה, התור שלך מחר ב-10:00",
"ref": "appt-1"
},
{
"to": "0527654321",
"body": "יוסי, התור שלך מחר ב-11:30",
"ref": "appt-2"
}
]
};
const result = await sms.messages.batch(body);PHP
php
<?php
$ch = curl_init("https://smsprovider-web.vercel.app/api/v1/messages/batch");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer " . getenv("BATLER_API_KEY"),
"Content-Type: application/json",
"Idempotency-Key: " . bin2hex(random_bytes(16)),
],
CURLOPT_POSTFIELDS => json_encode(["from" => "MyBrand", "messages" => [["to" => "0501234567", "body" => "דנה, התור שלך מחר ב-10:00", "ref" => "appt-1"], ["to" => "0527654321", "body" => "יוסי, התור שלך מחר ב-11:30", "ref" => "appt-2"]]], JSON_UNESCAPED_UNICODE),
]);
$result = json_decode(curl_exec($ch), true);Python
python
import os, uuid, requests
resp = requests.request(
"POST", "https://smsprovider-web.vercel.app/api/v1/messages/batch",
headers={"Authorization": f"Bearer {os.environ['BATLER_API_KEY']}", "Idempotency-Key": str(uuid.uuid4())},
json={"from": "MyBrand", "messages": [{"to": "0501234567", "body": "דנה, התור שלך מחר ב-10:00", "ref": "appt-1"}, {"to": "0527654321", "body": "יוסי, התור שלך מחר ב-11:30", "ref": "appt-2"}]},
timeout=30,
)
resp.raise_for_status()
result = resp.json()C#
csharp
using var http = new HttpClient();
http.DefaultRequestHeaders.Authorization = new("Bearer", Environment.GetEnvironmentVariable("BATLER_API_KEY"));
var req = new HttpRequestMessage(HttpMethod.Post, "https://smsprovider-web.vercel.app/api/v1/messages/batch");
req.Headers.Add("Idempotency-Key", Guid.NewGuid().ToString());
req.Content = new StringContent("{\"from\":\"MyBrand\",\"messages\":[{\"to\":\"0501234567\",\"body\":\"דנה, התור שלך מחר ב-10:00\",\"ref\":\"appt-1\"},{\"to\":\"0527654321\",\"body\":\"יוסי, התור שלך מחר ב-11:30\",\"ref\":\"appt-2\"}]}", System.Text.Encoding.UTF8, "application/json");
var res = await http.SendAsync(req);
var result = await res.Content.ReadAsStringAsync();