Senders are phone numbers or identities used to send messages. Each project can have multiple senders with one designated as default.
List Senders
const result = await client.senders.list({});
for (const sender of result.items) {
console.log(sender.id, sender.name, sender.phoneNumber);
if (sender.isDefault) {
console.log("(Default sender)");
}
}
// With pagination
const result = await client.senders.list({
limit: 50,
cursor: "cursor_xxx",
});
Get Sender
const result = await client.senders.get({
senderId: "snd_abc123",
});
console.log(result.id);
console.log(result.name);
console.log(result.phoneNumber);
console.log(result.isDefault);
Create Sender
const result = await client.senders.create({
name: "Marketing",
phoneNumber: "+15551234567",
setAsDefault: true,
});
console.log(result.id); // snd_xxx
With Webhook
const result = await client.senders.create({
name: "Marketing",
phoneNumber: "+15551234567",
webhookUrl: "https://your-app.com/webhooks",
webhookEvents: ["message.inbound", "message.delivered", "message.failed"],
});
// Webhook secret is only returned on create
if (result.webhook?.secret) {
console.log("Save this secret:", result.webhook.secret);
}
Update Sender
const result = await client.senders.update({
senderId: "snd_abc123",
name: "Support",
setAsDefault: true,
});
Update Webhook Configuration
const result = await client.senders.update({
senderId: "snd_abc123",
webhookUrl: "https://new-url.com/webhooks",
webhookEvents: ["message.inbound"],
webhookActive: true,
});
Disable Webhook
const result = await client.senders.update({
senderId: "snd_abc123",
webhookActive: false,
});
Remove Webhook
const result = await client.senders.update({
senderId: "snd_abc123",
webhookUrl: null,
});
Delete Sender
await client.senders.delete({
senderId: "snd_abc123",
});
You cannot delete the default sender. Set another sender as default first.
Regenerate Webhook Secret
If your webhook secret is compromised, generate a new one:
const result = await client.senders.regenerateWebhookSecret({
senderId: "snd_abc123",
});
console.log("New secret:", result.secret);
After regenerating the secret, update your webhook handler to use the new secret. The old secret will no longer work.
WhatsApp Business Profile
Manage the WhatsApp Business Profile for senders with a connected WhatsApp Business Account.
Get Profile
const response = await client.senders.getProfile("snd_abc123");
console.log(response.profile.about);
console.log(response.profile.description);
console.log(response.profile.address);
console.log(response.profile.email);
console.log(response.profile.websites);
console.log(response.profile.vertical);
console.log(response.profile.profilePictureUrl);
Update Profile
const response = await client.senders.updateProfile("snd_abc123", {
about: "Your trusted online store",
description: "Best products at competitive prices",
address: "123 Main St, San Francisco, CA",
email: "support@example.com",
websites: ["https://example.com"],
vertical: "RETAIL",
});
Upload Profile Picture
const response = await client.senders.uploadProfilePicture("snd_abc123", {
imageUrl: "https://example.com/logo.png",
mimeType: "image/png",
});
Profile methods are only available for senders with a WhatsApp Business Account connected.
Using Senders in Messages
Specify a sender when sending a message:
const result = await client.messages.send({
to: "+14155551234",
text: "Hello!",
'Zavu-Sender': "snd_abc123",
});
If no sender is specified, the default sender is used.