TutorialAPIGetting Started

Getting Started with Zavu's Messaging API

Get started with Zavu's unified messaging API in under 10 minutes. Send SMS, WhatsApp, and Email messages with a single integration and simple code.

Written by: Jennifer VillalobosReviewed by: Victor VillalobosJanuary 15, 20258 min read

Getting Started with Zavu's Messaging API

Zavu provides a unified API that lets you send messages across multiple channels—SMS, WhatsApp, and Email—with a single integration. In this guide, we'll walk through the basic setup and send your first message.

Prerequisites

Before you begin, make sure you have:
  • A Zavu account with API credentials
  • Node.js 18+ or Bun installed
  • Basic knowledge of JavaScript/TypeScript

Installation

Install the Zavu SDK using your preferred package manager:

bash
npm install @zavudev/sdk

Or with bun:

bash
bun add @zavudev/sdk

Initialize the Client

Create a new file and initialize the Zavu client with your API key:

typescript
import Zavudev from '@zavudev/sdk'; const client = new Zavudev({ apiKey: process.env.ZAVUDEV_API_KEY, });

Sending Your First Message

Now let's send a simple SMS message:

typescript
async function sendWelcomeMessage() { try { const response = await client.messages.send({ to: '+1234567890', text: 'Welcome to Zavu!', channel: 'sms', }); console.log('Message ID:', response.message.id); console.log('Status:', response.message.status); console.log('Channel:', response.message.channel); } catch (error) { console.error('Failed to send message:', error); } } sendWelcomeMessage();

Sending WhatsApp Messages

Send messages via WhatsApp (within 24h conversation window):

typescript
const response = await client.messages.send({ to: '+1234567890', text: 'Your order has been shipped!', channel: 'whatsapp', }); console.log('WhatsApp message sent:', response.message.id);

Adding Metadata

Track messages with custom metadata:

typescript
const response = await client.messages.send({ to: '+1234567890', text: 'Your verification code is 123456', channel: 'sms', metadata: { orderId: 'ORD-12345', userId: 'user_abc', }, });

Retrieving a Message

Get details about a sent message:

typescript
const response = await client.messages.retrieve('message_id_here'); console.log('Message details:', { id: response.message.id, to: response.message.to, status: response.message.status, channel: response.message.channel, createdAt: response.message.createdAt, });

Listing Messages

List messages with filtering and pagination:

typescript
// Get a page of messages const page = await client.messages.list({ limit: 10, channel: 'sms', status: 'delivered', }); console.log('Messages:', page.items); // Check for more pages if (page.hasNextPage()) { const nextPage = await page.getNextPage(); console.log('Next page:', nextPage.items); }

Async Iteration

Iterate through all messages using async iterators:

typescript
for await (const message of client.messages.list({ limit: 5 })) { console.log('Message:', message.id, message.status); }

Error Handling

Handle API errors gracefully:

typescript
import Zavudev from '@zavudev/sdk'; try { const response = await client.messages.send({ to: '+1234567890', text: 'Hello!', }); } catch (error) { if (error instanceof Zavudev.APIError) { console.error('API Error:', error.status, error.message); } else { throw error; } }

Next Steps

Now that you've sent your first message, explore these resources:

  • API Reference: Complete API documentation
  • Templates: Create reusable WhatsApp templates
  • Broadcasts: Send messages to multiple recipients
  • Contacts: Manage your contact database
Check out our documentation for more examples.Need help getting started? Contact us or join our Discord community for support and updates.

Need help? Contact us or join our Discord community for support.

Follow us on social media

Ready to start building?

Get started with Zavu's unified messaging API today.

Get Started Now
Getting Started with Zavu's Messaging API | Zavu Blog | Zavu