Developers

Code examples

SendCore is a plain JSON REST API, so any HTTP client works — no SDK to install. Copy a starting point below.

cURL
curl -X POST https://api.sendcore.in/companies/$COMPANY_ID/whatsapp/campaigns/$CAMPAIGN_ID/blasts \
  -H "x-api-key: $SENDCORE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"audienceType":"MANUAL","manualNumbers":["919876543210"]}'
Node.js (18+)
const BASE = "https://api.sendcore.in";
const headers = { "x-api-key": process.env.SENDCORE_API_KEY, "Content-Type": "application/json" };

async function call(method, path, body) {
  const res = await fetch(BASE + path, { method, headers, body: body && JSON.stringify(body) });
  if (!res.ok) throw new Error(`${res.status}: ${await res.text()}`);
  return res.json();
}

const c = `/companies/${process.env.COMPANY_ID}/whatsapp/campaigns/${process.env.CAMPAIGN_ID}`;
const { blast, recipients } = await call("POST", `${c}/blasts`, {
  audienceType: "MANUAL",
  manualNumbers: ["919876543210"],
});
await call("POST", `${c}/blasts/${blast.id}/queue`, {
  recipients: recipients.map((to) => ({ to, variables: ["Asha"] })),
});
Python (requests)
import os, requests

BASE = "https://api.sendcore.in"
s = requests.Session()
s.headers["x-api-key"] = os.environ["SENDCORE_API_KEY"]

c = f"{BASE}/companies/{os.environ['COMPANY_ID']}/whatsapp/campaigns/{os.environ['CAMPAIGN_ID']}"
r = s.post(f"{c}/blasts", json={"audienceType": "MANUAL", "manualNumbers": ["919876543210"]})
r.raise_for_status()
blast = r.json()["blast"]

s.post(f"{c}/blasts/{blast['id']}/queue",
       json={"recipients": [{"to": "919876543210", "variables": ["Asha"]}]}).raise_for_status()
print(s.get(f"{c}/blasts/{blast['id']}/progress").json())
PHP
<?php
$base = "https://api.sendcore.in/companies/" . getenv("COMPANY_ID") . "/whatsapp/templates";
$ch = curl_init($base);
curl_setopt_array($ch, [
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HTTPHEADER => ["x-api-key: " . getenv("SENDCORE_API_KEY")],
]);
$templates = json_decode(curl_exec($ch), true);
print_r($templates);

Full endpoint reference in the API docs. Official SDK packages are on our roadmap.