TutorialAPIGetting Started

Getting Started with Zavu's Messaging API

Learn how to integrate Zavu's unified messaging API into your application in under 10 minutes.

Zavu TeamJanuary 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, Viber, and more—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+ installed
  • Basic knowledge of JavaScript/TypeScript

Installation

First, install the Zavu SDK using your preferred package manager:

bash
npm install @zavu/sdk

Or with pnpm:

bash
pnpm add @zavu/sdk

Initialize the Client

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

typescript
"token keyword">import { Zavu } "token keyword">from '@zavu/sdk'"token keyword">const zavu = "token keyword">new Zavu({ apiKey: process.env.ZAVU_API_KEY, // Optional: specify "token keyword">default channel defaultChannel: 'sms'})

Sending Your First Message

Now let's send a simple SMS message:

typescript
"token keyword">async "token keyword">function sendWelcomeMessage() { "token keyword">try { "token keyword">const result = "token keyword">await zavu.messages.send({ to: '+1234567890', content: 'Welcome to Zavu! 🎉', channel: 'sms' }) console.log('Message sent:', result.messageId) console.log('Status:', result.status) } "token keyword">catch (error) { console.error('Failed to send message:', error) }}sendWelcomeMessage()

Cross-Channel Messaging

One of Zavu's most powerful features is automatic channel selection. Let Zavu choose the best channel based on user preferences and availability:

typescript
"token keyword">const result = "token keyword">await zavu.messages.send({ to: '+1234567890', content: 'Your order has been shipped!', // Zavu will automatically select the best channel channelStrategy: 'auto', // Fallback order "token keyword">if primary channel fails fallbackOrder: ['whatsapp', 'sms', 'email']})

Handling Webhooks

Set up webhooks to receive delivery status updates:

typescript
// In your API route handler"token keyword">export "token keyword">async "token keyword">function POST(request: Request) { "token keyword">const payload = "token keyword">await request.json() // Verify webhook signature "token keyword">const isValid = zavu.webhooks.verify( payload, request.headers.get('x-zavu-signature') ) "token keyword">if (!isValid) { "token keyword">return "token keyword">new Response('Invalid signature', { status: 401 }) } // Handle different event types "token keyword">switch (payload."token keyword">type) { "token keyword">case 'message.delivered': console.log('Message delivered:', payload.messageId) "token keyword">break "token keyword">case 'message.failed': console.log('Message failed:', payload.error) "token keyword">break "token keyword">case 'message.read': console.log('Message read by recipient') "token keyword">break } "token keyword">return "token keyword">new Response('OK', { status: 200 })}

Next Steps

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

  • Message Templates: Create reusable templates for common messages
  • Bulk Messaging: Send messages to thousands of recipients efficiently
  • Analytics: Track delivery rates and engagement metrics
  • Number Management: Provision and manage phone numbers
Check out our [API Reference](/docs/api) for complete documentation.

Ready to start building?

Get started with Zavu's unified messaging API today.

Get Started Now