English
Quick Start
Let's send your first WhatsApp message through Zawa, from scratch. It takes about 5 minutes, so your coffee won't even get cold.
What You Need
- A phone with an active WhatsApp account.
- A terminal with
curl.jqmakes it even nicer. - Or Node.js 18+, if you'd rather run the complete script below.
Every request on this page goes to this base URL:
text
https://api-zawa.azickri.comCreate a Session
Call Create Session. It needs no headers and no body.
bash
curl -X POST "https://api-zawa.azickri.com/session"You'll get something like this back:
json
{
"id": "68b3f0a2c1d4e5f6a7b8c9d0",
"sessionId": "0b2f7059-8a90-4f6d-8684-b0e1ce6f0310"
}Hold on to both values. You'll send them as the id and session-id headers on every request from now on. To keep things easy, store them in shell variables:
bash
export ZAWA_ID="68b3f0a2c1d4e5f6a7b8c9d0"
export ZAWA_SESSION_ID="0b2f7059-8a90-4f6d-8684-b0e1ce6f0310"Don't take too long
The QR code is only valid for about 3 minutes. If it isn't scanned in time, the session is deleted automatically and you'll need to create a new one. Have your phone ready.
Get the QR Code
The QR code is generated in the background, so wait 2–3 seconds, then call Get Session:
bash
curl "https://api-zawa.azickri.com/session" \
-H "id: $ZAWA_ID" \
-H "session-id: $ZAWA_SESSION_ID"json
{
"id": "68b3f0a2c1d4e5f6a7b8c9d0",
"generatedId": "",
"name": "",
"sessionId": "0b2f7059-8a90-4f6d-8684-b0e1ce6f0310",
"isConnected": false,
"qrcode": "iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAYAAAB...",
"picture": ""
}The qrcode field is a base64-encoded PNG (without a data: prefix). The easiest ways to look at it:
bash
curl -s "https://api-zawa.azickri.com/session" \
-H "id: $ZAWA_ID" \
-H "session-id: $ZAWA_SESSION_ID" \
| jq -r '.qrcode' | base64 -d > qr.png
# Open qr.png in your favorite image viewerhtml
<!-- Add the data URL prefix and show it as an image -->
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAYAAAB..." />qrcode still empty?
That's normal for the first few seconds. Wait a moment and call it again. The QR code may also change a few times while it waits to be scanned, so always use the latest one.
Scan It With Your Phone
- Open WhatsApp on your phone.
- Go to Settings (iPhone) or the ⋮ menu (Android), then choose Linked devices.
- Tap Link a device and scan the QR code.
Then call Get Session again. Once connected, isConnected becomes true and name and picture are filled in:
json
{
"id": "68b3f0a2c1d4e5f6a7b8c9d0",
"generatedId": "6281234567890:[email protected]",
"name": "Zawa Bot",
"sessionId": "0b2f7059-8a90-4f6d-8684-b0e1ce6f0310",
"isConnected": true,
"qrcode": "",
"picture": "https://pps.whatsapp.net/v/t61.24694-24/..."
}Send Your First Message
The moment you've been waiting for. Replace 6281234567890 with the recipient's number in international format (your own number works great for testing), then call Send Message:
bash
curl -X POST "https://api-zawa.azickri.com/message" \
-H "id: $ZAWA_ID" \
-H "session-id: $ZAWA_SESSION_ID" \
-H "Content-Type: application/json" \
-d '{"phone":"6281234567890","type":"text","text":"Hello from Zawa! 👑"}'json
{
"messageId": "3EB0C4A8F1D2B3E4A5F6"
}Check the phone. If the message is there, congratulations, you're officially a Zawa user! 🎉
The Complete Version in Node.js
Don't feel like copy-pasting each step? This script does everything above in one go: it creates a session, saves the QR code to qr.png whenever it changes, waits for you to scan it, and then sends a message.
js
// quick-start.mjs
// Run: node quick-start.mjs 6281234567890
import { writeFile } from 'node:fs/promises';
const BASE_URL = 'https://api-zawa.azickri.com';
const phone = process.argv[2];
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
async function zawa(method, path, { headers = {}, body } = {}) {
const response = await fetch(BASE_URL + path, {
method,
headers: { 'Content-Type': 'application/json', ...headers },
body: body ? JSON.stringify(body) : undefined,
});
const data = await response.json();
if (!response.ok) throw new Error(`${data.statusCode}: ${data.message}`);
return data;
}
// 1. Create a session
const { id, sessionId } = await zawa('POST', '/session');
const auth = { 'id': id, 'session-id': sessionId };
console.log('Session created:', auth);
// 2 & 3. Save the QR code to qr.png, then wait until it's scanned
let lastQrcode = '';
while (true) {
const session = await zawa('GET', '/session', { headers: auth });
if (session.isConnected) {
console.log(`Connected as ${session.name}!`);
break;
}
if (session.qrcode && session.qrcode !== lastQrcode) {
lastQrcode = session.qrcode;
await writeFile('qr.png', Buffer.from(session.qrcode, 'base64'));
console.log('New QR code saved to qr.png, scan it with your phone!');
}
await sleep(3000);
}
// 4. Send your first message
const { messageId } = await zawa('POST', '/message', {
headers: auth,
body: { phone, type: 'text', text: 'Hello from Zawa! 👑' },
});
console.log('Message sent:', messageId);If the script stops with 404: session not found while waiting, the QR code expired before you scanned it. Just run it again and scan a little faster. 😄
What's Next?
- Read the Core Concepts to understand the session lifecycle and number formats.
- Try sending images, documents, locations, or contacts.
- Send to a group or post a status.
- Hit an error? Check Errors & Fixes.