. Create an API key under API keys.Guide
Authentication
API keys
Send your key as a bearer token on every request to /v1:
Authorization: Bearer <your API key>A key acts as your business: it can use all of your devices, contacts and settings, within your plan. Keys are random 43-character strings, shown once when created, and stored by ChatKomodo only as a hash.
- Keep keys on your server. The API does not accept cross-origin calls from other websites, and a key in a web page or app can be copied.
- A key that leaked: create a new one, deploy it, then revoke the old one in API keys.
- Five wrong keys from the same address lock that address out for 15 minutes (
429).
Child keys for separate integrations
Give each integration its own key (POST /v1/api-keys): it acts as your business but has its own request limit and can be revoked alone. A child key can also be limited to some devices. Such a scoped key only reaches what is listed below; everything else, including endpoints added later, answers 403 KEY_SCOPE_FORBIDDEN:
| Scoped key | Endpoints |
|---|---|
| Allowed | Everything under its own devices (/v1/sessions/{sessionId}/…), media uploads and files by key (/v1/media/upload-url, /v1/media/upload, /v1/media/{key}), link previews |
| Read only | The device list (only its own devices), account (/v1/me), usage, billing, business profile, settings, templates, rotators, agents, AI assistant settings (GET /v1/ai-reply) |
| Not allowed | Everything else, among them business-wide lists that show every device (message history across devices, inbox, analytics, broadcasts, scheduled messages, /v1/sessions/all/…), the live event stream, API keys, webhooks, CRM, contacts, consent, privacy and store connections |
Keys are created and revoked from a dashboard login (an API key cannot create keys).
Keeping keys safe
- Allowed IPs: limit a key to the addresses of your servers (single addresses or CIDR ranges, up to 50). A request from anywhere else answers
403 IP_NOT_ALLOWEDand is recorded in the activity log. - Expiry: give a key an end date; afterwards it answers
401 KEY_EXPIRED. You get a reminder a week before. - Rotation:
POST /v1/api-keys/{id}/rotategives the key a new secret and keeps its name, limit and rules. The old secret keeps working forgrace_hours(default 24, up to 168, or 0 to stop it at once), so you can switch servers without downtime. Keys in use that were not rotated for 90 days get a reminder. - New country alert: the first request with a key from a country it was never used from sends a notification to your devices and is recorded as
api_key.new_location. The key list shows the last address and the countries a key was used from.
Signed requests (optional)
For extra protection against replay, add two headers. ChatKomodo then checks that the body was not changed and that the request is less than 5 minutes old:
X-Timestamp: the current time in Unix millisecondsX-API-Signature: hex HMAC-SHA256, with your API key as the secret, of<timestamp>.<hex SHA-256 of the raw body>(an empty body hashes the empty string)
import { createHash, createHmac } from 'node:crypto';
const key = process.env.CHATKOMODO_API_KEY;
const body = JSON.stringify({ chat_id: '+447700900123', type: 'text', body: 'Signed hello' });
const ts = String(Date.now());
const bodyHash = createHash('sha256').update(body).digest('hex');
const signature = createHmac('sha256', key).update(`${ts}.${bodyHash}`).digest('hex');
await fetch('https://api.chatkomodo.com/v1/sessions/YOUR_DEVICE_ID/messages', {
method: 'POST',
headers: {
Authorization: `Bearer ${key}`,
'Content-Type': 'application/json',
'X-Timestamp': ts,
'X-API-Signature': signature,
},
body,
});Send exactly the bytes you hashed. A wrong signature or an old timestamp returns 401.
Dashboard logins
The dashboard signs people in with a one-time code sent over WhatsApp (POST /auth/request-otp, POST /auth/verify-otp) and uses the returned token the same way: Authorization: Bearer <token>. Tokens last 2 hours and are renewed with POST /auth/refresh. A few endpoints are meant for people, not integrations, and need the owner's dashboard login — they are marked Dashboard login in the reference (for example creating API keys, editing AI documents and connecting stores).
Sign-in protection for the owner: an authenticator code can be required after the WhatsApp code (the sign-in then answers { "mfa_required": true, "mfa_token": … }; finish it with POST /auth/verify-mfa), passkeys sign in without a code (POST /auth/passkey/options, POST /auth/passkey/verify), and every signed-in device is listed and can be signed out (GET /v1/security/sessions). A sign-in from a new device notifies the owner.
New-browser check. Send a stable random device_id (16–64 characters, kept in the browser) with POST /auth/verify-otp and POST /auth/magic. When an owner who has a passkey or authenticator signs in from a device_id never seen before (or not for 180 days), the response is the second step with reason: "new_device" and a methods list (totp and/or passkey) instead of the tokens; finish it exactly as the authenticator step above. A known browser, an owner without a second factor, and agents are unaffected. The attempt is audited as auth.step_up.
Check a credential
curl "https://api.chatkomodo.com/v1/me" \
-H "Authorization: Bearer $CHATKOMODO_API_KEY"const res = await fetch('https://api.chatkomodo.com/v1/me', {
method: 'GET',
headers: {
Authorization: `Bearer ${process.env.CHATKOMODO_API_KEY}`,
},
});
const data = await res.json();
if (!res.ok) throw new Error(`${data.code}: ${data.error}`);
console.log(data);import os
import requests
res = requests.get(
"https://api.chatkomodo.com/v1/me",
headers={
"Authorization": f"Bearer {os.environ['CHATKOMODO_API_KEY']}",
},
timeout=30,
)
res.raise_for_status()
print(res.json())<?php
require 'vendor/autoload.php';
$client = new GuzzleHttp\Client();
$res = $client->request('GET', 'https://api.chatkomodo.com/v1/me', [
'headers' => [
'Authorization' => 'Bearer ' . getenv('CHATKOMODO_API_KEY'),
],
]);
print_r(json_decode((string) $res->getBody(), true));package main
import (
"fmt"
"io"
"net/http"
"os"
)
func main() {
req, err := http.NewRequest("GET", "https://api.chatkomodo.com/v1/me", nil)
if err != nil {
panic(err)
}
req.Header.Set("Authorization", "Bearer "+os.Getenv("CHATKOMODO_API_KEY"))
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))
}GET /v1/me says which business the credential belongs to, its plan, and whether it is an API key, the owner's login or an agent.