Manage Senders with the TypeScript SDK
Create, update and list sender profiles via the Zavu TypeScript SDK. Combine phone numbers, WhatsApp accounts and webhooks into routing identities.
Senders are phone numbers or identities used to send messages. Each project can have multiple senders with one designated as default.
List Senders
TypeScriptconst 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
TypeScriptconst result = await client.senders.retrieve({ senderId: "snd_abc123", }); console.log(result.id); console.log(result.name); console.log(result.phoneNumber); console.log(result.isDefault);
Create Sender
TypeScriptconst result = await client.senders.create({ name: "Marketing", phoneNumber: "+15551234567", setAsDefault: true, }); console.log(result.id); // snd_xxx
With Webhook
TypeScriptconst 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
TypeScriptconst result = await client.senders.update({ senderId: "snd_abc123", name: "Support", setAsDefault: true, });
Update Webhook Configuration
TypeScriptconst result = await client.senders.update({ senderId: "snd_abc123", webhookUrl: "https://new-url.com/webhooks", webhookEvents: ["message.inbound"], webhookActive: true, });
Disable Webhook
TypeScriptconst result = await client.senders.update({ senderId: "snd_abc123", webhookActive: false, });
Remove Webhook
TypeScriptconst result = await client.senders.update({ senderId: "snd_abc123", webhookUrl: null, });
Delete Sender
TypeScriptawait client.senders.delete({ senderId: "snd_abc123", });
Regenerate Webhook Secret
If your webhook secret is compromised, generate a new one:
TypeScriptconst result = await client.senders.regenerateWebhookSecret({ senderId: "snd_abc123", }); console.log("New secret:", result.secret);
WhatsApp Business Profile
Manage the WhatsApp Business Profile for senders with a connected WhatsApp Business Account.
Get Profile
TypeScriptconst 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
TypeScriptconst 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
TypeScriptconst response = await client.senders.uploadProfilePicture("snd_abc123", { imageUrl: "https://example.com/logo.png", mimeType: "image/png", });
Using Senders in Messages
Specify a sender when sending a message:
TypeScriptconst result = await client.messages.send({ to: "+14155551234", text: "Hello!", 'Zavu-Sender': "snd_abc123", });
If no sender is specified, the default sender is used.