Skip to content

Send Message ​

POST /message

Zawa's star endpoint. Send a message to a number, group, or channel, with seven types to choose from: text, image, video, audio, document, location, and contact. Each type needs different fields, so check the tables below.

Endpoint Details ​

  • Base URL: https://api-zawa.azickri.com
  • Headers: id, session-id, and Content-Type: application/json
  • Requires: a connected session (isConnected: true)

Headers ​

HeaderTypeRequiredDescription
idstringYesThe id from Create Session.
session-idstringYesThe sessionId from Create Session.

Request Body ​

FieldTypeRequiredDescription
phonestringOne of*Recipient number in international format, e.g. 6281234567890.
groupstringOne of*Group ID, e.g. [email protected].
newsletterstringOne of*Channel ID, e.g. 120363000000000000@newsletter.
typestringYesMessage type: text, image, video, audio, document, location, or contact.
textstringFor textThe message text. For image, video, and document it becomes the caption (optional).
imageobjectFor imageSee the image object.
videoobjectFor videoSee the video object.
audioobjectFor audioSee the audio object.
documentobjectFor documentSee the document object.
locationobjectFor locationSee the location object.
contactobjectFor contactSee the contact object.

* Fill in one of phone, group, or newsletter. If you fill in more than one, Zawa uses group first, then newsletter, then phone. The number format rules are in Core Concepts.

Media Objects ​

Media is sent by URL. Zawa downloads the file itself, so the URL must be public and point straight at the file. See also Sending Media From a URL.

ObjectFieldTypeRequiredDescription
imageurlstringYesImage URL. JPG is the safest choice.
mimetypestringYesFor example image/jpeg.
thumbnailstringNoThumbnail image URL. Uses the default thumbnail if empty.
videourlstringYesVideo URL. MP4 is the safest choice.
mimetypestringYesFor example video/mp4.
durationnumberYesVideo length in seconds, greater than 0.
thumbnailstringNoThumbnail image URL. Uses the default thumbnail if empty.
audiourlstringYesAudio URL. MP3 is the safest choice.
mimetypestringYesFor example audio/mpeg.
durationnumberYesAudio length in seconds, greater than 0.
documenturlstringYesDocument URL.
namestringYesFile name shown in the chat, e.g. invoice.pdf.
sizenumberYesFile size in bytes, greater than 0.
mimetypestringYesFor example application/pdf.

Audio isn't a voice note

Audio is sent as a regular audio file, not as a voice note (the green waveform kind).

Location and Contact Objects ​

ObjectFieldTypeRequiredDescription
locationlatitudenumberYesLatitude, must not be 0.
longitudenumberYesLongitude, must not be 0.
namestringNoPlace name, e.g. Monas.
addressstringNoPlace address.
contactnamestringYesName of the shared contact.
phonestringYesThe contact's number in international format, e.g. 6281234567890.

Example Request ​

The simplest example: send a text message to one number.

bash
curl -X POST "https://api-zawa.azickri.com/message" \
  -H "id: YOUR_ID" \
  -H "session-id: YOUR_SESSION_ID" \
  -H "Content-Type: application/json" \
  -d '{"phone":"6281234567890","type":"text","text":"Hello from Zawa! 👋"}'
javascript
import axios from 'axios';

const response = await axios.post(
  'https://api-zawa.azickri.com/message',
  {
    phone: '6281234567890',
    type: 'text',
    text: 'Hello from Zawa! 👋',
  },
  {
    headers: {
      'id': 'YOUR_ID',
      'session-id': 'YOUR_SESSION_ID',
    },
  },
);

console.log(response.data);
javascript
const response = await fetch('https://api-zawa.azickri.com/message', {
  method: 'POST',
  headers: {
    'id': 'YOUR_ID',
    'session-id': 'YOUR_SESSION_ID',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    phone: '6281234567890',
    type: 'text',
    text: 'Hello from Zawa! 👋',
  }),
});

const data = await response.json();
console.log(data);

Body Examples by Type ​

Swap the body in the request above for any of these.

json
{
  "phone": "6281234567890",
  "type": "text",
  "text": "Hello from Zawa! 👋"
}
json
{
  "phone": "6281234567890",
  "type": "image",
  "text": "This is the caption, it's optional",
  "image": {
    "url": "https://example.com/image.jpg",
    "mimetype": "image/jpeg"
  }
}
json
{
  "phone": "6281234567890",
  "type": "video",
  "text": "Video caption",
  "video": {
    "url": "https://example.com/video.mp4",
    "mimetype": "video/mp4",
    "duration": 30,
    "thumbnail": "https://example.com/video-thumbnail.jpg"
  }
}
json
{
  "phone": "6281234567890",
  "type": "audio",
  "audio": {
    "url": "https://example.com/audio.mp3",
    "mimetype": "audio/mpeg",
    "duration": 30
  }
}
json
{
  "phone": "6281234567890",
  "type": "document",
  "text": "Here's this month's invoice",
  "document": {
    "url": "https://example.com/invoice.pdf",
    "name": "invoice.pdf",
    "size": 102400,
    "mimetype": "application/pdf"
  }
}
json
{
  "phone": "6281234567890",
  "type": "location",
  "location": {
    "name": "Monas",
    "address": "Gambir, Central Jakarta",
    "latitude": -6.175392,
    "longitude": 106.827153
  }
}
json
{
  "phone": "6281234567890",
  "type": "contact",
  "contact": {
    "name": "Azickri",
    "phone": "6281234567890"
  }
}
json
{
  "group": "[email protected]",
  "type": "text",
  "text": "Hi everyone! 👋"
}
json
{
  "newsletter": "120363000000000000@newsletter",
  "type": "text",
  "text": "Fresh update coming through!"
}

Response ​

json
{
  "messageId": "3EB0C4A8F1D2B3E4A5F6"
}
json
// No recipient
{
  "statusCode": 400,
  "message": "invalid phone, group or newsletter"
}

// A required field for that type is missing
{
  "statusCode": 400,
  "message": "image should not be empty"
}

// Missing headers
{
  "statusCode": 400,
  "message": "invalid header"
}
json
{
  "statusCode": 404,
  "message": "session not found"
}
json
// Session isn't connected
{
  "statusCode": 500,
  "message": "session not connected"
}

// Media download failed
{
  "statusCode": 500,
  "message": "error parser file from url 404 Not Found"
}
FieldTypeDescription
messageIdstringThe message ID from WhatsApp.

A messageId doesn't guarantee delivery

A messageId means WhatsApp's server accepted the message. Zawa doesn't check whether the recipient is on WhatsApp, so make sure the number is right.