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
- Create an account and confirm your email.
- In the dashboard click Add number, then link WhatsApp with the QR code or a phone-number code.
- Copy
apiUrl,idInstanceandapiTokenInstancefrom 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
| Status | Meaning |
|---|---|
400 | Missing or invalid parameters — the error field explains which. |
401 | Unknown instance or wrong token. |
403 | The account is suspended or not approved yet. |
409 | The message was cancelled because the outgoing queue was cleared. |
429 | The number reached its daily message limit (resets at midnight UTC). |
466 | The 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
{ "stateInstance": "authorized" }
authorized (connected) · notAuthorized (needs linking) · starting (reconnecting) · blocked · paused. getStatusInstance returns {"statusInstance": "online" | "offline"}.
qr
{ "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
{ "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
logout unlinks the phone ({"isLogout": true}). reboot restarts the connection and keeps the link ({"isReboot": true}).
getSettings · setSettings
{
"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.
| Field | Meaning |
|---|---|
incomingWebhook | Incoming messages and files (on by default) |
outgoingMessageWebhook | Messages typed on the phone |
outgoingAPIMessageWebhook | Messages sent through the API |
outgoingWebhook | Status of sent messages: sent, delivered, read, failed |
stateWebhook | Connection changes: authorized, notAuthorized, blocked |
incomingCallWebhook | Incoming calls |
markIncomingMessagesReaded | Mark every incoming message read (blue ticks) as it arrives |
markIncomingMessagesReadedOnReply | Mark a chat read when you reply to it through the API |
delaySendMessagesMilliseconds | Gap between messages from this number (500–60000 ms; null = default) |
autoTypingSpeed | Show “typing…” before each text, at this many characters per second (0 = off, max 8 s) |
sendMessage
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
{
"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
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
{ "chatId": "923001234567@c.us", "latitude": 31.5204, "longitude": 74.3587, "nameLocation": "Our office", "address": "Main Boulevard, Lahore" }
sendContact
{ "chatId": "923001234567@c.us", "contact": { "phoneContact": 923009876543, "firstName": "Ali", "lastName": "Khan", "company": "Acme" } }
editMessage · deleteMessage
{ "chatId": "923001234567@c.us", "idMessage": "3EB0C767D82B4E5F9A21", "message": "Corrected text" }
{ "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
{ "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
{ "result": true }
Call this after processing each notification, then call receiveNotification again. clearNotificationsQueue empties the queue at once.
getChatHistory
{ "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
{ "chatId": "923001234567@c.us", "idMessage": "3EB0C767D82B4E5F9A21" }
lastIncomingMessages · lastOutgoingMessages
Messages from the last minutes (default 1440 = 24 hours, max 7 days), newest first, same shape as getChatHistory.
readChat
{ "chatId": "923001234567@c.us" } // or add "idMessage" to mark one message
// → { "setRead": true }
checkWhatsapp
{ "phoneNumber": 923001234567 }
// → { "existsWhatsapp": true }
getAvatar
{ "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
{ "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
[ { "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.