Messages

Open in ClaudeOpen in ChatGPT.md

Send an SMS

http
POST https://smsprovider-web.vercel.app/api/v1/messages

Send the same text to one or up to 1,000 recipients. Credits are reserved immediately (1 segment = 1 credit) and messages are queued. Embedded links ([link-id] in the text + links) are shortened with click tracking.

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

FieldTypeRequiredNotes
tostring | string[]yeslen 5–20, items 1–1000
fromstringnolen 2–20
bodystringyeslen 1–1005
schedule_atstring (date-time)no
campaign_namestringnolen 1–50
unsubscribe_linkbooleanno
unsubscribe_replybooleanno
linksmap<string, string (uri)>no
skip_recent_daysintegerno1–14
allow_internationalbooleanno
android_hashstringnopattern ^[A-Za-z0-9+/]{11}$
refstringnolen 1–100

Response

200 — SendResult

json
{
  "batch_id": "7d1c3c5e-2b1f-4c55-9a51-1f0b8f1b2a10",
  "accepted": 1,
  "rejected": [],
  "credits_reserved": 1,
  "messages": [
    {
      "id": "0e9b2f0a-6c1d-4f43-8c33-6f3b3f0d9a11",
      "status": "queued",
      "to": "+972501234567",
      "segments": 1,
      "credits": 1,
      "ref": "order-123",
      "scheduled_at": null,
      "created_at": "2026-11-02T18:00:00Z"
    }
  ]
}

Errors

StatusCode
400validation_error
400idempotency_key_required
409idempotency_conflict
402insufficient_credits
403sender_not_verified
422invalid_destination
429daily_limit_exceeded
403org_suspended
401unauthorized
403insufficient_scope
429rate_limited
500internal_error

Examples

curl

bash
curl -X POST "https://smsprovider-web.vercel.app/api/v1/messages" \
  -H "Authorization: Bearer $BATLER_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"to":["0501234567"],"from":"MyBrand","body":"שלום! ההזמנה שלך יצאה למשלוח: [track]","links":{"track":"https://example.com/orders/123"},"ref":"order-123"}'

Node.js

ts
import { BatlerSMS } from "@batler/sms";

const sms = new BatlerSMS({ apiKey: process.env.BATLER_API_KEY! });
const body = {
  "to": [
    "0501234567"
  ],
  "from": "MyBrand",
  "body": "שלום! ההזמנה שלך יצאה למשלוח: [track]",
  "links": {
    "track": "https://example.com/orders/123"
  },
  "ref": "order-123"
};
const result = await sms.messages.send(body);

PHP

php
<?php
$ch = curl_init("https://smsprovider-web.vercel.app/api/v1/messages");
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(["to" => ["0501234567"], "from" => "MyBrand", "body" => "שלום! ההזמנה שלך יצאה למשלוח: [track]", "links" => ["track" => "https://example.com/orders/123"], "ref" => "order-123"], 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",
    headers={"Authorization": f"Bearer {os.environ['BATLER_API_KEY']}", "Idempotency-Key": str(uuid.uuid4())},
    json={"to": ["0501234567"], "from": "MyBrand", "body": "שלום! ההזמנה שלך יצאה למשלוח: [track]", "links": {"track": "https://example.com/orders/123"}, "ref": "order-123"},
    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");
req.Headers.Add("Idempotency-Key", Guid.NewGuid().ToString());
req.Content = new StringContent("{\"to\":[\"0501234567\"],\"from\":\"MyBrand\",\"body\":\"שלום! ההזמנה שלך יצאה למשלוח: [track]\",\"links\":{\"track\":\"https://example.com/orders/123\"},\"ref\":\"order-123\"}", System.Text.Encoding.UTF8, "application/json");
var res = await http.SendAsync(req);
var result = await res.Content.ReadAsStringAsync();
☰