Campaigns

Open in ClaudeOpen in ChatGPT.md

Send a campaign to a list

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

Send to a contact list with dynamic fields {{df1}}…{{df6}}. Unsubscribed and blacklisted contacts are filtered out automatically.

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
list_idstring (uuid)yes
namestringnolen 1–100
fromstringnolen 2–20
bodystringyeslen 1–1005
schedule_atstring (date-time)no
unsubscribenone | link | replynodefault "none"
skip_recent_daysintegerno1–14
linksmap<string, string (uri)>no

Response

200 — SendResult

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
404not_found

Examples

curl

bash
curl -X POST "https://smsprovider-web.vercel.app/api/v1/campaigns" \
  -H "Authorization: Bearer $BATLER_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"list_id":"5b0d2a8e-1d7c-4a35-9a7e-3c1a3b5e9f00","from":"MyBrand","body":"היי {{df1}}, מבצע סוף עונה: 20% הנחה! [shop]","links":{"shop":"https://example.com/sale"},"unsubscribe":"link","schedule_at":"2026-11-05T09:00:00+02:00"}'

Node.js

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

const sms = new BatlerSMS({ apiKey: process.env.BATLER_API_KEY! });
const body = {
  "list_id": "5b0d2a8e-1d7c-4a35-9a7e-3c1a3b5e9f00",
  "from": "MyBrand",
  "body": "היי {{df1}}, מבצע סוף עונה: 20% הנחה! [shop]",
  "links": {
    "shop": "https://example.com/sale"
  },
  "unsubscribe": "link",
  "schedule_at": "2026-11-05T09:00:00+02:00"
};
const result = await sms.campaigns.create(body);

PHP

php
<?php
$ch = curl_init("https://smsprovider-web.vercel.app/api/v1/campaigns");
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(["list_id" => "5b0d2a8e-1d7c-4a35-9a7e-3c1a3b5e9f00", "from" => "MyBrand", "body" => "היי {{df1}}, מבצע סוף עונה: 20% הנחה! [shop]", "links" => ["shop" => "https://example.com/sale"], "unsubscribe" => "link", "schedule_at" => "2026-11-05T09:00:00+02:00"], 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/campaigns",
    headers={"Authorization": f"Bearer {os.environ['BATLER_API_KEY']}", "Idempotency-Key": str(uuid.uuid4())},
    json={"list_id": "5b0d2a8e-1d7c-4a35-9a7e-3c1a3b5e9f00", "from": "MyBrand", "body": "היי {{df1}}, מבצע סוף עונה: 20% הנחה! [shop]", "links": {"shop": "https://example.com/sale"}, "unsubscribe": "link", "schedule_at": "2026-11-05T09:00:00+02:00"},
    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/campaigns");
req.Headers.Add("Idempotency-Key", Guid.NewGuid().ToString());
req.Content = new StringContent("{\"list_id\":\"5b0d2a8e-1d7c-4a35-9a7e-3c1a3b5e9f00\",\"from\":\"MyBrand\",\"body\":\"היי {{df1}}, מבצע סוף עונה: 20% הנחה! [shop]\",\"links\":{\"shop\":\"https://example.com/sale\"},\"unsubscribe\":\"link\",\"schedule_at\":\"2026-11-05T09:00:00+02:00\"}", System.Text.Encoding.UTF8, "application/json");
var res = await http.SendAsync(req);
var result = await res.Content.ReadAsStringAsync();
☰
Send a campaign to a list · Batler SMS API · Batler SMS