Send WhatsApp messages from your connected numbers using reusable templates with {{variables}} — to a single recipient or a saved audience — and track every send.
Numbers#
The WhatsApp numbers connected to your company. Only numbers with connected status can send. Use a number's sessionId or phoneNumber as the send `from`.
List numbers#
/api/whatsapp/companies/{slug}/numbersconst numbers = await sentroy.whatsapp.numbers.list()
// → [{ sessionId, phoneNumber, label, status, connected }]Templates#
Reusable message bodies with {{variable}} placeholders. Variables are extracted automatically and filled at send time.
List templates#
/api/whatsapp/companies/{slug}/templatesconst templates = await sentroy.whatsapp.templates.list()Create template#
/api/whatsapp/companies/{slug}/templatesconst tpl = await sentroy.whatsapp.templates.create({
name: "Order shipped",
body: "Hi {{name}}, your order {{orderNo}} has shipped!",
})Update / delete template#
/api/whatsapp/companies/{slug}/templates/{id}await sentroy.whatsapp.templates.update("tpl-id", {
body: "Updated body with {{name}}",
})
await sentroy.whatsapp.templates.delete("tpl-id")Audiences#
Phone-based target lists. Each entry is a phone plus optional per-recipient variables, letting one send personalize every message.
List audiences#
/api/whatsapp/companies/{slug}/audiencesconst audiences = await sentroy.whatsapp.audiences.list()Create audience#
/api/whatsapp/companies/{slug}/audiencesconst audience = await sentroy.whatsapp.audiences.create({
name: "March promo",
entries: [
{ phone: "+905551112233", variables: { name: "Ada" } },
"+905554445566",
],
})Send#
Send a template (or raw body) to a single recipient (`to`) or a whole audience (`audienceId`). Variables are rendered per recipient; audience entry variables override the global ones. Returns a per-recipient result summary.
Send to one recipient#
/api/whatsapp/companies/{slug}/sendconst res = await sentroy.whatsapp.send({
to: "+905551112233",
templateId: "tpl-id",
variables: { name: "Ada", orderNo: "1042" },
})
// → { total, sent, failed, results: [...] }Send to an audience (bulk)#
Omit to and pass audienceId. Every audience entry is messaged, rate-limited on the server. Provide from (a connected number's sessionId or phoneNumber) when you have more than one number.
/api/whatsapp/companies/{slug}/sendconst res = await sentroy.whatsapp.send({
from: "+905550000000",
audienceId: "aud-id",
templateId: "tpl-id",
variables: { campaign: "March" },
})Send logs#
Every API/template send is logged per recipient. Filter by status, template, or number.
List send logs#
/api/whatsapp/companies/{slug}/logs?status=sent&page=1&limit=50const logs = await sentroy.whatsapp.logs.list({ status: "sent" })
// → { data, page, limit, total }