From nothing to a working request
This page takes about ten minutes. By the end you will have a key, a request that works, and the handful of rules every endpoint follows.
Create a key #
An API key lets a program act for one workspace (one business’s account in Chatilo). To make one:
- Sign in to Chatilo as the workspace’s owner or an admin.
- Open API and webhooks in the menu, under Automate. Go there now.
- Choose New key, give it a name that says where it will be used, and pick its access: Read and write or Read only.
- Copy the key. It starts with
ck_live_and is shown once. Only a fingerprint of it is stored, so nobody can show it to you again.
Make one key per system. Then you can switch one off without breaking the others, and the page shows when each was last used. A workspace can have ten.
API access is part of some plans. If the page says it isn’t in yours, requests answer not_in_plan until the plan is changed.
Make your first request #
Ask who the key belongs to. Replace YOUR_API_KEY with your key:
curl "https://chatilo.me/api/v1/me" \
-H "Authorization: Bearer YOUR_API_KEY"<?php
$apiKey = 'YOUR_API_KEY';
$ch = curl_init('https://chatilo.me/api/v1/me');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $apiKey],
]);
$result = json_decode((string) curl_exec($ch), true);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
if ($status >= 400) {
throw new RuntimeException($result['error']['code'] . ': ' . $result['error']['message']);
}
print_r($result);const apiKey = 'YOUR_API_KEY';
const response = await fetch("https://chatilo.me/api/v1/me", {
headers: {
Authorization: `Bearer ${apiKey}`,
},
});
const result = await response.json();
if (!response.ok) {
throw new Error(`${result.error.code}: ${result.error.message}`);
}
console.log(result);import requests
api_key = "YOUR_API_KEY"
response = requests.get(
"https://chatilo.me/api/v1/me",
headers={"Authorization": f"Bearer {api_key}"},
timeout=30,
)
result = response.json()
if not response.ok:
raise RuntimeError(f"{result['error']['code']}: {result['error']['message']}")
print(result)You get the workspace back:
{
"ok": true,
"workspace": {
"id": 1,
"name": "Maple Thread Co.",
"plan": "Growth",
"timezone": "Asia/Kolkata"
},
"key": {
"name": "Order system",
"scope": "write"
}
}That’s the whole pattern: an address, your key in a header, JSON back. Next, send your first WhatsApp message, or read on for the rules.
Base address #
Every request on this installation starts with:
https://chatilo.me/api/v1Chatilo is self-hosted, so the address is the one your Chatilo runs on. The examples on these pages already use it. Always use https in production: a key sent over plain http can be read on the way.
Authentication #
Send the key in the Authorization header of every request, after the word Bearer and a space:
Authorization: Bearer YOUR_API_KEYThere are no sessions, cookies or tokens to refresh. A missing or wrong key answers 401 unauthorized. A key only ever sees its own workspace: an id that belongs to another workspace answers “not found”, exactly as if it didn’t exist.
Scopes #
A key has one of two levels of access, chosen when it is made:
| Key | Scope | What it can do |
|---|---|---|
| Read only | read | Every GET request: list and look up contacts, conversations, messages, broadcasts, orders, bookings and the rest. Good for reports and dashboards. |
| Read and write | read write | Everything a read-only key can, plus every request that changes something: POST, PUT and DELETE. |
The rule is simple enough to remember: reading is GET, and GET never changes anything. A read-only key that tries to change something gets 403 read_only_key. Each endpoint in the reference says which key it needs, and Get the account tells a program what its own key may do. Subscribing to events (POST /hooks) is a change, so it needs a read-and-write key.
Keys made before scopes existed are read-and-write, as they always were.
Requests and responses #
- Send JSON. Put the body in JSON with the header
Content-Type: application/json. Filters onGETrequests go in the query string. - You get JSON. A success has
"ok": trueand a 2xx status. Anything that was created answers201. - Methods.
GETreads,POSTcreates or does something,PUTchanges the fields you send and leaves the rest alone,DELETEremoves. - Dates and times come back in UTC as
2026-01-31T09:30:00Z. When you send one, include an offset (2026-01-31T15:00:00+05:30) or aZ. A time with neither is read on the workspace’s own clock. - Phone numbers need the country code. Send
+919876543210; spaces and dashes are ignored. They come back as digits only:919876543210. - Money is a whole number in the currency’s smallest unit, with the currency beside it:
129950and"INR"is ₹1,299.50. - Ids are whole numbers and belong to one kind of thing: contact 12 and conversation 12 are unrelated.
- Unknown fields are ignored, so a typo in a field name does nothing rather than failing. Check the response to see what was stored.
Errors #
Every failed request has a 4xx or 5xx status and the same body:
{
"ok": false,
"error": {
"code": "window_closed",
"message": "The customer hasn’t written in the last 24 hours. Send a template instead."
}
}code is a fixed word your program can test for; it will not change. message is a sentence written for a person, and may be reworded, so show it but don’t match on it.
| Status | Meaning | What to do |
|---|---|---|
400 | The body couldn’t be read. | Fix the JSON. |
401 | No key, or a wrong one. | Check the header and the key. |
402 | The workspace’s plan has ended. | Renew the plan in the app. |
403 | Not allowed: a read-only key, a plan without this feature, or a plan limit reached. | Read the code; retrying won’t help. |
404 | No such endpoint, or nothing with that id in this workspace. | Check the address and the id. |
409 | It can’t be done in the current state: the time is taken, the order is already cancelled. | Fetch the item and decide again. |
422 | Something you sent is missing or not valid. | The code names the field. |
429 | Too many requests. | Wait for Retry-After seconds. |
500 | A fault on the server. | Retry shortly, with an Idempotency-Key. |
502 | WhatsApp or another channel refused the message. | The message says why. |
Every error code #
This list is made from the same description as the reference, so it is complete.
| Code | Status | When |
|---|---|---|
already_checked_in | 409 | The ticket was checked in before. |
booking_not_found | 404 | No booking with that id or reference in this workspace. |
campaign_not_found | 404 | No broadcast with that id in this workspace. |
contact_limit | 403 | The plan’s contact limit is reached, so a new contact can’t be added. |
contact_not_found | 404 | No contact with that id or phone number in this workspace. |
conversation_not_found | 404 | No conversation with that id in this workspace. conversation_id is not a conversation in this workspace. |
entry_not_found | 404 | No entry with that id or ticket code in this workspace. |
hook_limit | 403 | The workspace already has 50 subscriptions. |
hook_not_found | 404 | No subscription with that id in this workspace. |
idempotency_conflict | 409 | A request with the same Idempotency-Key is still running. |
invalid_active | 422 | active isn’t true or false. |
invalid_assignee | 422 | assigned_to isn’t an active team member of this workspace. |
invalid_attributes | 422 | attributes isn’t an object of names and text values, or there are more than 50. |
invalid_audience | 422 | audience.type isn’t all, tags or segment, or no tag was given. |
invalid_bill | 422 | account_no or amount is missing, or amount is not above zero. |
invalid_category | 422 | category is longer than 60 characters. |
invalid_channel | 422 | channel is not whatsapp or sms. |
invalid_contacts | 422 | contacts is missing or isn’t a list. |
invalid_customer | 422 | customer has no contact_id, phone or name. |
invalid_date | 422 | A date filter isn’t a date and time like 2026-01-31T09:30:00Z. date is missing or isn’t YYYY-MM-DD. |
invalid_description | 422 | description is longer than 800 characters. |
invalid_email | 422 | email isn’t an email address. |
invalid_event | 404 | There is no event with that name. event isn’t an event name. |
invalid_filter | 422 | opted_in isn’t true or false. assigned_to isn’t an id or “none”. |
invalid_header | 422 | The template has a media header and variables.header isn’t a link. |
invalid_idempotency_key | 422 | The Idempotency-Key is longer than 200 characters. |
invalid_image | 422 | image_url is private, unreachable, too large, or not a JPEG or PNG. |
invalid_json | 400 | The body was sent as JSON but could not be read as JSON. |
invalid_kind | 422 | kind is not one of the seven kinds. |
invalid_media | 422 | media.url is missing, private, unreachable, too large, not an allowed file type, or not the type you said. |
invalid_name | 422 | name is missing or longer than 150 characters. name is missing or too long. |
invalid_notes | 422 | notes is longer than 5,000 characters. notes is longer than 1,000 characters. |
invalid_opted_in | 422 | opted_in isn’t true or false. |
invalid_page | 422 | The content cannot be saved: an empty headline, an unknown design, or a poll with fewer than two options. |
invalid_phone | 422 | The phone number is missing or isn’t 8 to 15 digits with the country code. to has no country code or is not a phone number. |
invalid_price | 422 | price isn’t a whole number above zero. |
invalid_rules | 422 | rules isn’t customer or staff. |
invalid_schedule | 422 | scheduled_at isn’t a time in the future. |
invalid_sku | 422 | sku is longer than 64 characters. |
invalid_start | 422 | start is missing or isn’t a date and time. |
invalid_state | 409 | The broadcast isn’t sending. The broadcast isn’t paused. |
invalid_status | 422 | status isn’t open or closed. status is not one of the entry statuses. |
invalid_stock | 422 | stock isn’t a whole number or null. |
invalid_tag | 422 | Neither tag nor tags was sent. No tag name was sent. |
invalid_text | 422 | text is missing or too long. text is missing or longer than 4,096 characters. |
invalid_type | 422 | type isn’t one of the six, or that type can’t be sent on the conversation’s channel. |
invalid_url | 422 | target_url is missing, too long, can’t be found, or points to a private network. |
message_limit | 403 | This month’s broadcast message allowance is used up. |
message_not_found | 404 | No message with that id in this workspace. |
no_number | 422 | No WhatsApp number is connected, or number_id isn’t one of yours. No WhatsApp number is connected. |
no_sms_account | 422 | No SMS account is connected. |
not_a_bill_page | 422 | That page is not a bill payment page. |
not_a_ticket | 422 | The entry is not an event ticket. |
not_found | 404 | There is no endpoint with that method and path. |
not_in_plan | 403 | API access is not part of the workspace’s plan. Products and orders aren’t part of the workspace’s plan. |
nothing_to_update | 422 | None of the fields was sent. Neither status nor assigned_to was sent. |
opted_out | 422 | The contact has opted out. They can opt back in by replying START. |
order_not_found | 404 | No order with that id in this workspace. |
otp_throttled | 429 | A code went to this number in the last 30 seconds, or five in the last hour. |
page_limit | 403 | The workspace already has 50 pages. |
page_not_found | 404 | No page with that id or link name in this workspace. |
phone_taken | 409 | Another contact already has that phone number. |
plan_inactive | 402 | The workspace’s trial or plan has ended, or the workspace is suspended. |
policy_violation | 422 | The text breaks Meta’s rules for WhatsApp, for example it asks for a full card number or promotes something Meta prohibits. The message says which rule. Nothing was sent. |
product_limit | 403 | The workspace already has 2,000 products. |
product_not_found | 404 | No product with that id in this workspace. |
rate_limited | 429 | More than 120 requests in a minute with this key. Wait for the seconds in Retry-After. |
read_only_key | 403 | A read-only key was used for a request that changes something. |
segment_not_found | 404 | segment_id is not a segment in this workspace. No segment with that id in this workspace. |
send_failed | 502 | The channel refused the message. The message text says why. Nothing was delivered. WhatsApp or the SMS provider refused the message. |
server_error | 500 | Something failed on the server. Safe to retry, with an Idempotency-Key on writes. |
service_not_found | 422 | service_id is missing or not a service in this workspace. |
slot_unavailable | 409 | That time isn’t free: it was taken, is outside opening hours, or breaks the notice rules. |
staff_not_found | 422 | staff_id is not an active staff member. |
tag_limit | 403 | The workspace already has 1,000 tags. |
tag_not_found | 404 | No tag with that id in this workspace. One of the tags doesn’t exist. |
template_not_found | 422 | No approved template with that name and language on the sending number. No template with that id in this workspace. |
ticket_not_valid | 409 | The ticket is unpaid or cancelled. |
too_many | 422 | More than 100 contacts were sent. |
unauthorized | 401 | The Authorization header is missing, or the key is wrong or deleted. |
unknown_starting_point | 422 | template is not one of the starting points. |
window_closed | 422 | Free text or a file was sent more than 24 hours after the customer’s last message. Send a template instead. |
Pagination #
Lists come a page at a time, newest first. Ask for a page with page (starting at 1) and choose its size with limit (1 to 100; 50 when left out). Every paged response ends with the same five fields:
{
"ok": true,
"contacts": [
"…"
],
"page": 2,
"pages": 7,
"total": 312,
"limit": 50,
"has_more": true
}To read everything, keep asking for the next page while has_more is true. A page past the end is an empty list, never an error, so a loop that stops on an empty page also ends.
curl "https://chatilo.me/api/v1/contacts?page=2&limit=100" \
-H "Authorization: Bearer YOUR_API_KEY"<?php
$apiKey = 'YOUR_API_KEY';
$page = 1;
do {
$ch = curl_init('https://chatilo.me/api/v1/contacts?limit=100&page=' . $page);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . $apiKey],
]);
$result = json_decode((string) curl_exec($ch), true);
foreach ($result['contacts'] ?? [] as $contact) {
echo $contact['phone'], "\n";
}
$page++;
} while ($result['has_more'] ?? false);const apiKey = 'YOUR_API_KEY';
let page = 1;
let result;
do {
const response = await fetch(`https://chatilo.me/api/v1/contacts?limit=100&page=${page}`, {
headers: { Authorization: `Bearer ${apiKey}` },
});
result = await response.json();
for (const contact of result.contacts ?? []) {
console.log(contact.phone);
}
page += 1;
} while (result.has_more);import requests
api_key = "YOUR_API_KEY"
page = 1
while True:
result = requests.get(
"https://chatilo.me/api/v1/contacts",
headers={"Authorization": f"Bearer {api_key}"},
params={"limit": 100, "page": page},
timeout=30,
).json()
for contact in result.get("contacts", []):
print(contact["phone"])
if not result.get("has_more"):
break
page += 1New items arrive at the front of a list, so on a busy workspace an item can appear on two pages while you read. Use the item’s id to skip ones you have seen, or filter with since or updated_since where the endpoint has it. A few short lists (tags, templates, numbers, services) are not paged and say so.
Rate limits #
Each key may make 120 requests every 60 seconds. Every response says where you stand:
| Header | Meaning |
|---|---|
X-RateLimit-Limit | How many requests the key gets per window: 120. |
X-RateLimit-Remaining | How many are left in the current window. |
X-RateLimit-Reset | When the window ends and the count starts again, as Unix time in seconds. |
Retry-After | Only on a 429: how many seconds to wait before trying again. |
Past the limit you get 429 rate_limited and nothing is done. Wait the number of seconds in Retry-After, then carry on. Two things keep you well under the limit: use the bulk endpoint to add many contacts in one request, and use webhooks instead of asking again and again whether something has changed.
Sending is also bound by WhatsApp’s own limits on your number, and by your plan’s contact limit and monthly broadcast allowance. Those answer with their own error codes, not with 429.
Idempotency #
Networks fail halfway. If a request to send a message times out, you can’t tell whether it was sent, and sending it again might message the customer twice. An Idempotency-Key makes a retry safe.
Add the header to any request that creates or sends something, with a value that is unique to that one operation: your own order number, or a random UUID you store before the first attempt.
curl -X POST "https://chatilo.me/api/v1/messages" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Idempotency-Key: order-1042-shipped" \
-H "Content-Type: application/json" \
-d '{
"to": "+919876543210",
"type": "template",
"template": {
"name": "order_update",
"language": "en",
"body": [
"Grace",
"#1042"
]
}
}'- The first request with a key does the work. A repeat with the same key within 24 hours does nothing and returns the first answer again, with the header
Idempotent-Replay: true. - Only successes are remembered. If the first attempt failed (a 4xx or 5xx), the same key may be used to try again.
- If the first request is still running when the repeat arrives, the repeat gets
409 idempotency_conflict. Wait a moment and retry. - A key is remembered per API key, not per endpoint. Use a different value for each operation; reusing one for a different request returns the earlier answer.
- Keys can be up to 200 characters.
Endpoints that accept the header are marked Accepts Idempotency-Key in the reference: every create and every send. PUT and DELETE requests, and actions like pausing a broadcast or cancelling a booking, are safe to repeat as they are: doing them twice leaves things as doing them once (the second attempt may answer invalid_state or “not found”).
Versioning and stability #
This is version 1 of the API, and the /v1 in the address is the promise that goes with it. Within version 1:
- We will not remove an endpoint, rename or remove a field, change a field’s type, change what an error code means, or make an optional field required.
- We may add endpoints, add optional request fields and filters, add fields to responses and webhook deliveries, add event types, and add error codes for new situations.
So write clients that ignore fields they don’t know, and that treat an unknown error code like its HTTP status. If a change ever has to break that promise it will be a new version at /v2, and /v1 will keep working alongside it.
The reference is at version 1.3.1. The middle number goes up when endpoints or fields are added; the changelog lists what changed. Because Chatilo is self-hosted, an installation gets new endpoints when whoever runs it installs an update; openapi.json always describes the installation you are talking to.