Reference / WhatsApp

WhatsApp

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#

GET/api/whatsapp/companies/{slug}/numbers
const 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#

GET/api/whatsapp/companies/{slug}/templates
const templates = await sentroy.whatsapp.templates.list()

Create template#

POST/api/whatsapp/companies/{slug}/templates
const tpl = await sentroy.whatsapp.templates.create({
  name: "Order shipped",
  body: "Hi {{name}}, your order {{orderNo}} has shipped!",
})

Update / delete template#

PATCH/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#

GET/api/whatsapp/companies/{slug}/audiences
const audiences = await sentroy.whatsapp.audiences.list()

Create audience#

POST/api/whatsapp/companies/{slug}/audiences
const 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#

POST/api/whatsapp/companies/{slug}/send
const 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.

POST/api/whatsapp/companies/{slug}/send
const 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#

GET/api/whatsapp/companies/{slug}/logs?status=sent&page=1&limit=50
const logs = await sentroy.whatsapp.logs.list({ status: "sent" })
// → { data, page, limit, total }