API reference

The API uses the same URL format and JSON as Green API, so libraries, n8n nodes and apps written for Green API work after changing the API URL, instance ID and token.

Getting started

  1. Create an account and confirm your email.
  2. In the dashboard click Add number, then link WhatsApp with the QR code or a phone-number code.
  3. Copy apiUrl, idInstance and apiTokenInstance from Connection details.

URL & authentication

Every request goes to:

{apiUrl}/waInstance{idInstance}/{method}/{apiTokenInstance}

For example https://api.relaykit.cloud/waInstance7104512230/getStateInstance/8f3c…e91a. The token in the URL is the password for that number — keep it secret and only call the API from your server. You can regenerate it in the dashboard at any time. Requests with a body use Content-Type: application/json (except sendFileByUpload).

Phone numbers are written with the country code and no +, as a chat id: 923001234567@c.us. Groups use their …@g.us id.

Errors & limits

StatusMeaning
400Missing or invalid parameters — the error field explains which.
401Unknown instance or wrong token.
403The account is suspended or not approved yet.
409The message was cancelled because the outgoing queue was cleared.
429The number reached its daily message limit (resets at midnight UTC).
466The number isn't linked — link it in the dashboard first.

Messages from one number are sent one at a time with a short natural gap (about 1.5 s), so a burst of requests is queued rather than rejected. Each request waits until its message is sent.

getStateInstance

GET/waInstance{id}/getStateInstance/{token}
{ "stateInstance": "authorized" }

authorized (connected) · notAuthorized (needs linking) · starting (reconnecting) · blocked · paused. getStatusInstance returns {"statusInstance": "online" | "offline"}.

qr

GET/waInstance{id}/qr/{token}
{ "type": "qrCode", "message": "iVBORw0KGgo…" }   // base64 PNG
{ "type": "alreadyLogged", "message": "instance already authorized" }

Show the PNG and scan it in WhatsApp → Linked devices → Link a device. Call it every few seconds while waiting — the code refreshes.

getAuthorizationCode

POST/waInstance{id}/getAuthorizationCode/{token}
{ "phoneNumber": 923001234567 }
// → { "status": true, "code": "ABCD1234" }

Link without a camera: in WhatsApp → Linked devices → Link a device → Link with phone number instead, type the 8-character code.

logout · reboot

GET/waInstance{id}/logout/{token}

GET/waInstance{id}/reboot/{token}

logout unlinks the phone ({"isLogout": true}). reboot restarts the connection and keeps the link ({"isReboot": true}).

getSettings · setSettings

GET/waInstance{id}/getSettings/{token}

POST/waInstance{id}/setSettings/{token}
{
  "webhookUrl": "https://your-app.com/whatsapp/webhook",
  "webhookUrlToken": "a-long-random-secret",
  "incomingWebhook": "yes",
  "outgoingMessageWebhook": "yes",
  "outgoingAPIMessageWebhook": "no",
  "outgoingWebhook": "yes",
  "stateWebhook": "yes",
  "incomingCallWebhook": "yes",
  "markIncomingMessagesReaded": "no",
  "markIncomingMessagesReadedOnReply": "yes",
  "delaySendMessagesMilliseconds": 3000,
  "autoTypingSpeed": 10
}
// → { "saveSettings": true }

Send only the fields you want to change. Everything can also be changed in the dashboard.

FieldMeaning
incomingWebhookIncoming messages and files (on by default)
outgoingMessageWebhookMessages typed on the phone
outgoingAPIMessageWebhookMessages sent through the API
outgoingWebhookStatus of sent messages: sent, delivered, read, failed
stateWebhookConnection changes: authorized, notAuthorized, blocked
incomingCallWebhookIncoming calls
markIncomingMessagesReadedMark every incoming message read (blue ticks) as it arrives
markIncomingMessagesReadedOnReplyMark a chat read when you reply to it through the API
delaySendMessagesMillisecondsGap between messages from this number (500–60000 ms; null = default)
autoTypingSpeedShow “typing…” before each text, at this many characters per second (0 = off, max 8 s)

sendMessage

POST/waInstance{id}/sendMessage/{token}
curl -X POST "https://api.relaykit.cloud/waInstance7104512230/sendMessage/YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"chatId": "923001234567@c.us", "message": "Hello 👋"}'
// → { "idMessage": "3EB0C767D82B4E5F9A21" }

Up to 20,000 characters. WhatsApp formatting works: *bold*, _italic_, ~strike~.

JavaScript

const res = await fetch(`${API_URL}/waInstance${ID}/sendMessage/${TOKEN}`, {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ chatId: '923001234567@c.us', message: 'Hello 👋' }),
});
const { idMessage } = await res.json();

PHP

$ch = curl_init("$apiUrl/waInstance$id/sendMessage/$token");
curl_setopt_array($ch, [
  CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true,
  CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
  CURLOPT_POSTFIELDS => json_encode(['chatId' => '923001234567@c.us', 'message' => 'Hello']),
]);
$result = json_decode(curl_exec($ch), true);

sendFileByUrl

POST/waInstance{id}/sendFileByUrl/{token}
{
  "chatId": "923001234567@c.us",
  "urlFile": "https://example.com/brochure.pdf",
  "fileName": "brochure.pdf",
  "caption": "Here is our brochure"
}

Images and videos are sent as media; everything else as a document. Max 64 MB. The URL must be publicly reachable.

sendFileByUpload

POST/waInstance{id}/sendFileByUpload/{token}
curl -X POST "$API_URL/waInstance$ID/sendFileByUpload/$TOKEN" \
  -F "chatId=923001234567@c.us" -F "caption=Invoice" -F "file=@invoice.pdf"

Multipart form with file, chatId and optional fileName and caption.

sendLocation

POST/waInstance{id}/sendLocation/{token}
{ "chatId": "923001234567@c.us", "latitude": 31.5204, "longitude": 74.3587, "nameLocation": "Our office", "address": "Main Boulevard, Lahore" }

sendContact

POST/waInstance{id}/sendContact/{token}
{ "chatId": "923001234567@c.us", "contact": { "phoneContact": 923009876543, "firstName": "Ali", "lastName": "Khan", "company": "Acme" } }

editMessage · deleteMessage

POST/waInstance{id}/editMessage/{token}
{ "chatId": "923001234567@c.us", "idMessage": "3EB0C767D82B4E5F9A21", "message": "Corrected text" }
POST/waInstance{id}/deleteMessage/{token}
{ "chatId": "923001234567@c.us", "idMessage": "3EB0C767D82B4E5F9A21" }
// → { "isDeleted": true }

Only messages sent from this number can be edited (about 15 minutes after sending) or deleted for everyone. Reply to a message by adding "quotedMessageId" to sendMessage.

Webhooks

Set a webhook URL in the dashboard (or with setSettings) and every notification you switched on is POSTed to it as JSON. If you set a webhook token it is sent as Authorization: Bearer <token>. Answer with any 2xx status. Failed deliveries are retried three times, then kept in the polling queue so nothing is lost.

{
  "typeWebhook": "incomingMessageReceived",
  "instanceData": { "idInstance": 7104512230, "wid": "923111234567@c.us", "typeInstance": "whatsapp" },
  "timestamp": 1764400000,
  "idMessage": "3A1B2C3D4E5F",
  "senderData": {
    "chatId": "923001234567@c.us", "chatName": "Sara",
    "sender": "923001234567@c.us", "senderName": "Sara"
  },
  "messageData": {
    "typeMessage": "textMessage",
    "textMessageData": { "textMessage": "Thank you!" }
  }
}

typeMessage can also be extendedTextMessage (extendedTextMessageData.text), imageMessage, videoMessage, documentMessage, audioMessage, stickerMessage, locationMessage, contactMessage or pollMessage. In groups, chatId is the group and sender is the person.

Files

For photos, videos, voice notes and documents, fileMessageData includes a downloadUrl. Files are kept for 7 days.

"messageData": {
  "typeMessage": "imageMessage",
  "fileMessageData": {
    "downloadUrl": "https://api.relaykit.cloud/media/7104512230/9f2c…e1.jpg",
    "caption": "Our receipt", "fileName": "", "mimeType": "image/jpeg"
  }
}

Notification types

Switch each one on or off per number in the dashboard, or with setSettings.

outgoingMessageReceived · outgoingAPIMessageReceived

A message sent from the phone, or through the API. Same shape as incomingMessageReceived, with sender being your own number.

outgoingMessageStatus

{ "typeWebhook": "outgoingMessageStatus", "instanceData": { … }, "timestamp": 1764400010,
  "idMessage": "3EB0C767D82B4E5F9A21", "chatId": "923001234567@c.us", "status": "delivered", "sendByApi": true }

status: sent → delivered → read, or failed. Read receipts only arrive when the recipient has read receipts switched on.

stateInstanceChanged

{ "typeWebhook": "stateInstanceChanged", "instanceData": { … }, "timestamp": 1764400000, "stateInstance": "notAuthorized" }

Sent when the number connects (authorized), is unlinked (notAuthorized) or blocked by WhatsApp (blocked).

incomingCall

{ "typeWebhook": "incomingCall", "instanceData": { … }, "timestamp": 1764400000,
  "from": "923001234567@c.us", "status": "offer", "idMessage": "6F2A…", "isVideo": false }

status: offer (ringing), pickUp, missed, declined, hangUp. Calls can't be answered through the API. Calls you place from the phone are not reported, because WhatsApp doesn't share them with linked devices.

receiveNotification

GET/waInstance{id}/receiveNotification/{token}?receiveTimeout=5
{ "receiptId": 42, "body": { "typeWebhook": "incomingMessageReceived", … } }
// or null when the queue is empty

For apps that can't receive webhooks (for example on a laptop). Waits up to receiveTimeout seconds (max 20) for the next notification. Notifications stay in the queue until you delete them, and expire after 14 days.

deleteNotification

DELETE/waInstance{id}/deleteNotification/{token}/{receiptId}
{ "result": true }

Call this after processing each notification, then call receiveNotification again. clearNotificationsQueue empties the queue at once.

getChatHistory

POST/waInstance{id}/getChatHistory/{token}
{ "chatId": "923001234567@c.us", "count": 50 }
// → [ { "type": "incoming", "idMessage": "3A1B…", "timestamp": 1764400000, "typeMessage": "textMessage",
       "chatId": "923001234567@c.us", "senderId": "923001234567@c.us", "senderName": "Sara", "textMessage": "Thank you!" },
     { "type": "outgoing", "idMessage": "3EB0…", "typeMessage": "textMessage", "textMessage": "Your order shipped",
       "statusMessage": "read", "sendByApi": true, … } ]

Newest first. The journal keeps the last 7 days of messages received or sent while the number was connected to RelayKit.

getMessage

POST/waInstance{id}/getMessage/{token}
{ "chatId": "923001234567@c.us", "idMessage": "3EB0C767D82B4E5F9A21" }

lastIncomingMessages · lastOutgoingMessages

GET/waInstance{id}/lastIncomingMessages/{token}?minutes=1440

GET/waInstance{id}/lastOutgoingMessages/{token}?minutes=1440

Messages from the last minutes (default 1440 = 24 hours, max 7 days), newest first, same shape as getChatHistory.

readChat

POST/waInstance{id}/readChat/{token}
{ "chatId": "923001234567@c.us" }        // or add "idMessage" to mark one message
// → { "setRead": true }

checkWhatsapp

POST/waInstance{id}/checkWhatsapp/{token}
{ "phoneNumber": 923001234567 }
// → { "existsWhatsapp": true }

getAvatar

POST/waInstance{id}/getAvatar/{token}
{ "chatId": "923001234567@c.us" }
// → { "existsWhatsapp": true, "urlAvatar": "https://pps.whatsapp.net/…", "available": true }

The link is temporary (WhatsApp expires it after a while). It's empty when the person has no photo or hides it.

getContactInfo

POST/waInstance{id}/getContactInfo/{token}
{ "chatId": "923001234567@c.us" }
// → { "chatId": "923001234567@c.us", "name": "Sara", "avatar": "https://…", "description": "Available",
     "isBusiness": true, "email": "hello@shop.pk", "category": "Retail", … }

name is the name the person last used when messaging you. description is their About text when it's public.

showMessagesQueue · clearMessagesQueue

GET/waInstance{id}/showMessagesQueue/{token}

GET/waInstance{id}/clearMessagesQueue/{token}
[ { "chatId": "923001234567@c.us", "typeMessage": "textMessage", "queuedAt": 1764400000 } ]
// clearMessagesQueue → { "isCleared": true }

Messages from one number go out one at a time with a gap. These show or cancel what's still waiting. A cancelled request returns HTTP 409.