. Create an API key under API keys.Guide
Sending messages
Message types
POST /v1/sessions/{sessionId}/messages sends one message. type decides which other field is required:
type | Required | Optional |
|---|---|---|
text | body (up to 64 KB) | reply_to |
image, video | media_r2_key or url | caption |
document, sticker | media_r2_key or url | filename (with url) |
audio | media_r2_key or url | ptt: true sends it as a voice note; MP3, M4A and WebM are converted to Ogg/Opus first |
location | location: {lat, lng} | |
poll | poll_name, choices (2–12) | |
contact | contact: {name, phone} |
curl -X POST "https://api.chatkomodo.com/v1/sessions/YOUR_DEVICE_ID/messages" \
-H "Authorization: Bearer $CHATKOMODO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"chat_id": "+447700900123",
"type": "image",
"url": "https://example.com/promo.jpg",
"caption": "This week'\''s offer"
}'const res = await fetch('https://api.chatkomodo.com/v1/sessions/YOUR_DEVICE_ID/messages', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.CHATKOMODO_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"chat_id": "+447700900123",
"type": "image",
"url": "https://example.com/promo.jpg",
"caption": "This week's offer"
}),
});
const data = await res.json();
if (!res.ok) throw new Error(`${data.code}: ${data.error}`);
console.log(data);import os
import requests
res = requests.post(
"https://api.chatkomodo.com/v1/sessions/YOUR_DEVICE_ID/messages",
headers={
"Authorization": f"Bearer {os.environ['CHATKOMODO_API_KEY']}",
},
json={
"chat_id": "+447700900123",
"type": "image",
"url": "https://example.com/promo.jpg",
"caption": "This week's offer",
},
timeout=30,
)
res.raise_for_status()
print(res.json())<?php
require 'vendor/autoload.php';
$client = new GuzzleHttp\Client();
$res = $client->request('POST', 'https://api.chatkomodo.com/v1/sessions/YOUR_DEVICE_ID/messages', [
'headers' => [
'Authorization' => 'Bearer ' . getenv('CHATKOMODO_API_KEY'),
],
'json' => [
'chat_id' => '+447700900123',
'type' => 'image',
'url' => 'https://example.com/promo.jpg',
'caption' => 'This week\'s offer',
],
]);
print_r(json_decode((string) $res->getBody(), true));package main
import (
"fmt"
"io"
"net/http"
"os"
"strings"
)
func main() {
body := strings.NewReader(`{
"chat_id": "+447700900123",
"type": "image",
"url": "https://example.com/promo.jpg",
"caption": "This week's offer"
}`)
req, err := http.NewRequest("POST", "https://api.chatkomodo.com/v1/sessions/YOUR_DEVICE_ID/messages", body)
if err != nil {
panic(err)
}
req.Header.Set("Authorization", "Bearer "+os.Getenv("CHATKOMODO_API_KEY"))
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
data, _ := io.ReadAll(res.Body)
if res.StatusCode >= 400 {
panic(fmt.Sprintf("%d: %s", res.StatusCode, data))
}
fmt.Println(string(data))
}curl -X POST "https://api.chatkomodo.com/v1/sessions/YOUR_DEVICE_ID/messages" \
-H "Authorization: Bearer $CHATKOMODO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"chat_id": "+447700900123",
"type": "poll",
"poll_name": "Preferred delivery time?",
"choices": [
"Morning",
"Afternoon",
"Evening"
]
}'const res = await fetch('https://api.chatkomodo.com/v1/sessions/YOUR_DEVICE_ID/messages', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.CHATKOMODO_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"chat_id": "+447700900123",
"type": "poll",
"poll_name": "Preferred delivery time?",
"choices": [
"Morning",
"Afternoon",
"Evening"
]
}),
});
const data = await res.json();
if (!res.ok) throw new Error(`${data.code}: ${data.error}`);
console.log(data);import os
import requests
res = requests.post(
"https://api.chatkomodo.com/v1/sessions/YOUR_DEVICE_ID/messages",
headers={
"Authorization": f"Bearer {os.environ['CHATKOMODO_API_KEY']}",
},
json={
"chat_id": "+447700900123",
"type": "poll",
"poll_name": "Preferred delivery time?",
"choices": [
"Morning",
"Afternoon",
"Evening",
],
},
timeout=30,
)
res.raise_for_status()
print(res.json())<?php
require 'vendor/autoload.php';
$client = new GuzzleHttp\Client();
$res = $client->request('POST', 'https://api.chatkomodo.com/v1/sessions/YOUR_DEVICE_ID/messages', [
'headers' => [
'Authorization' => 'Bearer ' . getenv('CHATKOMODO_API_KEY'),
],
'json' => [
'chat_id' => '+447700900123',
'type' => 'poll',
'poll_name' => 'Preferred delivery time?',
'choices' => [
'Morning',
'Afternoon',
'Evening',
],
],
]);
print_r(json_decode((string) $res->getBody(), true));package main
import (
"fmt"
"io"
"net/http"
"os"
"strings"
)
func main() {
body := strings.NewReader(`{
"chat_id": "+447700900123",
"type": "poll",
"poll_name": "Preferred delivery time?",
"choices": [
"Morning",
"Afternoon",
"Evening"
]
}`)
req, err := http.NewRequest("POST", "https://api.chatkomodo.com/v1/sessions/YOUR_DEVICE_ID/messages", body)
if err != nil {
panic(err)
}
req.Header.Set("Authorization", "Bearer "+os.Getenv("CHATKOMODO_API_KEY"))
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
data, _ := io.ReadAll(res.Body)
if res.StatusCode >= 400 {
panic(fmt.Sprintf("%d: %s", res.StatusCode, data))
}
fmt.Println(string(data))
}Buttons and list messages have their own endpoint: POST /v1/sessions/{sessionId}/messages/interactive.
Media files
Either pass a public url (downloaded by ChatKomodo, up to 25 MB), or upload once (up to 10 MB) and send by key — faster when the same file goes to many people:
curl -X POST "https://api.chatkomodo.com/v1/media/upload" \
-H "Authorization: Bearer $CHATKOMODO_API_KEY" \
-F "file=@price-list.pdf"import { readFile } from 'node:fs/promises';
const form = new FormData();
form.append('file', new Blob([await readFile('price-list.pdf')]), 'price-list.pdf');
const res = await fetch('https://api.chatkomodo.com/v1/media/upload', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.CHATKOMODO_API_KEY}`,
},
body: form,
});
const data = await res.json();
if (!res.ok) throw new Error(`${data.code}: ${data.error}`);
console.log(data);import os
import requests
res = requests.post(
"https://api.chatkomodo.com/v1/media/upload",
headers={
"Authorization": f"Bearer {os.environ['CHATKOMODO_API_KEY']}",
},
files={"file": open("price-list.pdf", "rb")},
timeout=30,
)
res.raise_for_status()
print(res.json())<?php
require 'vendor/autoload.php';
$client = new GuzzleHttp\Client();
$res = $client->request('POST', 'https://api.chatkomodo.com/v1/media/upload', [
'headers' => [
'Authorization' => 'Bearer ' . getenv('CHATKOMODO_API_KEY'),
],
'multipart' => [
['name' => 'file', 'contents' => fopen('price-list.pdf', 'r')],
],
]);
print_r(json_decode((string) $res->getBody(), true));package main
import (
"bytes"
"fmt"
"io"
"mime/multipart"
"net/http"
"os"
)
func main() {
body := &bytes.Buffer{}
form := multipart.NewWriter(body)
file, err := os.Open("price-list.pdf")
if err != nil {
panic(err)
}
defer file.Close()
part, err := form.CreateFormFile("file", "price-list.pdf")
if err != nil {
panic(err)
}
if _, err := io.Copy(part, file); err != nil {
panic(err)
}
form.Close()
req, err := http.NewRequest("POST", "https://api.chatkomodo.com/v1/media/upload", body)
if err != nil {
panic(err)
}
req.Header.Set("Authorization", "Bearer "+os.Getenv("CHATKOMODO_API_KEY"))
req.Header.Set("Content-Type", form.FormDataContentType())
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
data, _ := io.ReadAll(res.Body)
if res.StatusCode >= 400 {
panic(fmt.Sprintf("%d: %s", res.StatusCode, data))
}
fmt.Println(string(data))
}The response has the key to send as media_r2_key. Uploaded files are listed in GET /v1/media.
Message statuses
The send call answers as soon as the message is queued. Its status then moves on:
| Status | Meaning |
|---|---|
queued | Waiting in the device's queue (see pacing below). |
sent | Accepted by WhatsApp (one grey tick). Webhook message.sent. |
delivered | Reached the recipient's phone (two grey ticks). |
read | Opened, if the recipient shares read receipts (two blue ticks). |
failed | Not sent; error says why (for example not on WhatsApp, monthly quota used up). Webhook message.failed. Retry with POST /v1/sessions/{sessionId}/messages/{msgId}/retry. |
cancelled | Taken out of the queue with POST /v1/sessions/{sessionId}/messages/cancel. |
Safe retries: Idempotency-Key
A network error after you sent a request does not tell you whether the message went out. Add an Idempotency-Key header (an order id, a UUID) and simply repeat the request: the second call returns the first result with "idempotent_replay": true instead of sending twice.
curl -X POST "https://api.chatkomodo.com/v1/sessions/YOUR_DEVICE_ID/messages" \
-H "Authorization: Bearer $CHATKOMODO_API_KEY" \
-H "Idempotency-Key: order-1042-shipped" \
-H "Content-Type: application/json" \
-d '{
"chat_id": "+447700900123",
"type": "text",
"body": "Your order #1042 has shipped."
}'const res = await fetch('https://api.chatkomodo.com/v1/sessions/YOUR_DEVICE_ID/messages', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.CHATKOMODO_API_KEY}`,
'Idempotency-Key': 'order-1042-shipped',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"chat_id": "+447700900123",
"type": "text",
"body": "Your order #1042 has shipped."
}),
});
const data = await res.json();
if (!res.ok) throw new Error(`${data.code}: ${data.error}`);
console.log(data);import os
import requests
res = requests.post(
"https://api.chatkomodo.com/v1/sessions/YOUR_DEVICE_ID/messages",
headers={
"Authorization": f"Bearer {os.environ['CHATKOMODO_API_KEY']}",
"Idempotency-Key": "order-1042-shipped",
},
json={
"chat_id": "+447700900123",
"type": "text",
"body": "Your order #1042 has shipped.",
},
timeout=30,
)
res.raise_for_status()
print(res.json())<?php
require 'vendor/autoload.php';
$client = new GuzzleHttp\Client();
$res = $client->request('POST', 'https://api.chatkomodo.com/v1/sessions/YOUR_DEVICE_ID/messages', [
'headers' => [
'Authorization' => 'Bearer ' . getenv('CHATKOMODO_API_KEY'),
'Idempotency-Key' => 'order-1042-shipped',
],
'json' => [
'chat_id' => '+447700900123',
'type' => 'text',
'body' => 'Your order #1042 has shipped.',
],
]);
print_r(json_decode((string) $res->getBody(), true));package main
import (
"fmt"
"io"
"net/http"
"os"
"strings"
)
func main() {
body := strings.NewReader(`{
"chat_id": "+447700900123",
"type": "text",
"body": "Your order #1042 has shipped."
}`)
req, err := http.NewRequest("POST", "https://api.chatkomodo.com/v1/sessions/YOUR_DEVICE_ID/messages", body)
if err != nil {
panic(err)
}
req.Header.Set("Authorization", "Bearer "+os.Getenv("CHATKOMODO_API_KEY"))
req.Header.Set("Idempotency-Key", "order-1042-shipped")
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
data, _ := io.ReadAll(res.Body)
if res.StatusCode >= 400 {
panic(fmt.Sprintf("%d: %s", res.StatusCode, data))
}
fmt.Println(string(data))
}Pacing and new numbers
WhatsApp blocks numbers that behave like bulk senders, so every device sends through its own queue at a human pace: a few seconds between messages to different chats (with a short typing indicator), at most 30 messages a minute and 1 000 a day. A newly linked number is warmed up for its first 24 hours (at most 10 a minute and 200 a day). Repeated send errors slow the queue down by themselves.
So the API answers fast, and delivery follows the queue. For many recipients use a broadcast rather than a loop of single sends: it adds consent checks, the send window and progress counters. To send faster, spread traffic over several devices with a rotator.
Number protection
Most bans come from messaging people who never talked to the number. So each number may send a first message to only a limited number of new contacts a day: 20 on its first day, growing over two weeks of warm-up to 800 (you can set your own value up to 1 000 once it is warmed up). People who wrote to the number first, groups and test devices are not counted. A message over the limit is not refused: it waits for the next morning (08:00–10:00 WIB), so a large list to cold contacts simply spreads over several days. You can also cap every message a day with daily_limit.
GET /v1/sessions/{sessionId}/health shows the number's age, today's counts against the limits, and the failures, blocks and opt-outs of the last 7 days (level: good, careful or at_risk). Set limits with PUT /v1/sessions/{sessionId}/limits.
Before a broadcast, POST /v1/sessions/{sessionId}/blasts/risk scores its ban risk from 0 to 100 with the reasons (cold list, young number, shortened links, promotional words, the same text to everyone…). Starting a high-risk broadcast answers 409 BLAST_RISK_HIGH with the reasons; start it again with "accept_risk": true to go ahead (asked once, recorded in the audit log).
When a device is offline
Sends to a device that is not connected are refused with 409 CONFLICT, so you notice at once. Pass "connect_only": false to queue the message anyway; it goes out when the device reconnects. The webhook session.disconnected tells you when a phone logs out.
Opt-outs
People who reply STOP (and the same word in many languages) are opted out automatically. A one-to-one send to them still goes out and the response carries a warning:
{
"id": "01JA5W2B7C9D0E1F2G3H4J5K6M",
"status": "queued",
"warnings": [
{
"code": "RECIPIENT_OPTED_OUT",
"message": "This recipient has opted out of messages"
}
]
}With enforce_api switched on in PUT /v1/consent/config the send is refused instead (409 RECIPIENT_OPTED_OUT). Broadcasts always skip opted-out people.
Free plan limits
A business on the Free plan can send text messages, images and reactions. Everything else (documents, video, audio, stickers, locations, polls, contact cards, buttons and lists, status updates, channel posts and message edits) needs a paid plan, and texts and captions must not contain links (a URL, a www. address or a bare domain such as wa.me/…; e-mail addresses are fine). Such requests are refused before anything is queued:
{
"error": "Links cannot be sent on the Free plan. Remove the link or upgrade your plan.",
"code": "FREE_PLAN_RESTRICTED",
"reason": "link",
"upgrade_url": "https://chatkomodo.com/billing"
}reason is type or link. Messages sent by automations (auto-replies, chatbots, broadcasts, scheduled and recurring messages, store notifications) follow the same rules: a refused one is logged as failed and fires message.failed with the same code. On the Free plan every text and caption ends with the line Sent via ChatKomodo WA Gateway · chatkomodo.com (in Indonesian for Indonesian-language businesses), and images carry a small ChatKomodo badge in the bottom-right corner. free_plan in GET /v1/usage tells you whether the rules apply; test devices follow them too.
Send window
Broadcast messages are only released inside the business's daily send window (setting send_window, in the business time zone or each recipient's own). Outside it they wait. One-to-one replies, scheduled and recurring messages are not held.
Personalization tokens
Broadcasts, templates, auto-replies and welcome messages fill {name}, {first_name}, {phone}, {var1}…{var5} and {attr.<field>} per recipient. Give a fallback with double braces: {{first_name|there}}.