. Create an API key under API keys.API reference · Account
Sign-in & account
Sign-up and dashboard sign-in (one-time code over WhatsApp, access code, authenticator) and GET /v1/me. Integrations use an API key instead.
Sign up a new business
/auth/registerNo authenticationSelf-service tenant signup. Creates a new tenant with the Free plan; the business profile (country, timezone, language, billing currency) is inferred from the phone number. Phone number must be unique across all tenants.
Request body
namestringrequiredBusiness or account namephonestringrequiredOwner phone in international format+<country code><number>; also decides the initial business country, timezone and currencylangstringLanguage of the OTP / notice messages and the initial dashboard language (default: the request language)turnstile_tokenstringToken from the Turnstile widget, required whenGET /auth/turnstilereturns a site key
Responses
- 200Tenant created and a one-time code sent over WhatsApp. Sign in with
POST /auth/verify-otp.Response fields
okbooleanrequired
- 400Name or number missing or invalid
- 403
TURNSTILE_REQUIREDorTURNSTILE_FAILED: the security check (seeGET /auth/turnstile) is on andturnstile_tokenis missing or invalid - 409Phone already registered — sign in instead
- 429Rate limited
- 502The code could not be delivered over WhatsApp
- 503Registration is temporarily unavailable (the sender device is offline)
curl -X POST "https://api.chatkomodo.com/auth/register" \
-H "Content-Type: application/json" \
-d '{
"name": "Acme Dental",
"phone": "+447700900123",
"lang": "en",
"turnstile_token": "eyJhbGciOiJIUzI1NiIs…"
}'const res = await fetch('https://api.chatkomodo.com/auth/register', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
"name": "Acme Dental",
"phone": "+447700900123",
"lang": "en",
"turnstile_token": "eyJhbGciOiJIUzI1NiIs…"
}),
});
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/auth/register",
json={
"name": "Acme Dental",
"phone": "+447700900123",
"lang": "en",
"turnstile_token": "eyJhbGciOiJIUzI1NiIs…",
},
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/auth/register', [
'json' => [
'name' => 'Acme Dental',
'phone' => '+447700900123',
'lang' => 'en',
'turnstile_token' => 'eyJhbGciOiJIUzI1NiIs…',
],
]);
print_r(json_decode((string) $res->getBody(), true));package main
import (
"fmt"
"io"
"net/http"
"strings"
)
func main() {
body := strings.NewReader(`{
"name": "Acme Dental",
"phone": "+447700900123",
"lang": "en",
"turnstile_token": "eyJhbGciOiJIUzI1NiIs…"
}`)
req, err := http.NewRequest("POST", "https://api.chatkomodo.com/auth/register", body)
if err != nil {
panic(err)
}
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))
}{
"ok": true
}Request a sign-in code
/auth/request-otpNo authenticationRequest a one-time password (OTP) for the given phone. At most 5 codes per 15 minutes and 20 per day per number, 8 requests per 10 minutes per address; after 15 wrong codes in a day the number cannot sign in with a code until the next day (UTC). The answer is the same whether or not the number has an account, and a repeat within 30 seconds sends nothing new (the code already sent stays valid).
Request body
phonestringrequiredInternational format+<country code><number>turnstile_tokenstringToken from the Turnstile widget, required whenGET /auth/turnstilereturns a site key
Responses
- 200Accepted: a code is on its way when the number has an account
Response fields
okbooleanrequired
- 400Validation error
- 403
TURNSTILE_REQUIREDorTURNSTILE_FAILED: the security check (seeGET /auth/turnstile) is on andturnstile_tokenis missing or invalid - 429Too many OTP requests
- 503The sign-in code sender is offline
curl -X POST "https://api.chatkomodo.com/auth/request-otp" \
-H "Content-Type: application/json" \
-d '{
"phone": "+447700900123"
}'const res = await fetch('https://api.chatkomodo.com/auth/request-otp', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
"phone": "+447700900123"
}),
});
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/auth/request-otp",
json={
"phone": "+447700900123",
},
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/auth/request-otp', [
'json' => [
'phone' => '+447700900123',
],
]);
print_r(json_decode((string) $res->getBody(), true));package main
import (
"fmt"
"io"
"net/http"
"strings"
)
func main() {
body := strings.NewReader(`{
"phone": "+447700900123"
}`)
req, err := http.NewRequest("POST", "https://api.chatkomodo.com/auth/request-otp", body)
if err != nil {
panic(err)
}
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))
}{
"ok": true
}Sign in with a one-time code
/auth/verify-otpNo authenticationVerify the 6-digit OTP. Usually returns a JWT (2 hour expiry) and a rotating refresh token (30 days). For an owner, when the authenticator is required at every sign-in, or when the browser is new (reason: "new_device", keyed by device_id), it instead returns the second-step object: finish with POST /auth/verify-mfa or a passkey.
Request body
phonestringrequiredcodestringrequireddevice_idstringRandom id the browser keeps for itself. An owner with a passkey or authenticator app signing in from a device id never seen before (or not for 180 days) gets{ mfa_required, reason: "new_device", methods }first
Responses
- 200Authenticated, or the second step (see schema)
Response fields
tokenstringrequiredJWT to use in Authorization: Bearer headerrefresh_tokenstringRefresh token (long-lived)rolestringrequiredagent_idstringagent_namestring
- 401Invalid or expired OTP
curl -X POST "https://api.chatkomodo.com/auth/verify-otp" \
-H "Content-Type: application/json" \
-d '{
"phone": "+447700900123",
"code": "482913"
}'const res = await fetch('https://api.chatkomodo.com/auth/verify-otp', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
"phone": "+447700900123",
"code": "482913"
}),
});
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/auth/verify-otp",
json={
"phone": "+447700900123",
"code": "482913",
},
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/auth/verify-otp', [
'json' => [
'phone' => '+447700900123',
'code' => '482913',
],
]);
print_r(json_decode((string) $res->getBody(), true));package main
import (
"fmt"
"io"
"net/http"
"strings"
)
func main() {
body := strings.NewReader(`{
"phone": "+447700900123",
"code": "482913"
}`)
req, err := http.NewRequest("POST", "https://api.chatkomodo.com/auth/verify-otp", body)
if err != nil {
panic(err)
}
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))
}{
"token": "eyJhbGciOiJIUzI1NiIs…",
"refresh_token": "eyJhbGciOiJIUzI1NiIs…",
"role": "admin",
"agent_id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"agent_name": "string"
}Sign in with the one-tap link from the OTP message
/auth/magicNo authenticationSign in with the one-tap link sent in the same WhatsApp message as the code (https://<dashboard>/login?m=<token>). The token is single use and lives as long as the code (5 minutes); using the link ends the code and the other way round. Same answer as /auth/verify-otp (tokens, or the authenticator step). Recorded as auth.login with detail otp-link.
Request body
tokenstringrequiredThemvalue of the linkdevice_idstringAs for/auth/verify-otp
Responses
- 200Authenticated, or the second step (see
/auth/verify-otp)Response fields
tokenstringrequiredJWT to use in Authorization: Bearer headerrefresh_tokenstringRefresh token (long-lived)rolestringrequiredagent_idstringagent_namestring
- 401Expired or already used (
LINK_EXPIRED) - 429Too many attempts from this IP address
curl -X POST "https://api.chatkomodo.com/auth/magic" \
-H "Content-Type: application/json" \
-d '{
"token": "Zq3xM8vP1kR7tY2wN5bL0aC9dE4fG6hJ",
"device_id": "k3Jd8xQ2vLp9TzR1aBcD4e"
}'const res = await fetch('https://api.chatkomodo.com/auth/magic', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
"token": "Zq3xM8vP1kR7tY2wN5bL0aC9dE4fG6hJ",
"device_id": "k3Jd8xQ2vLp9TzR1aBcD4e"
}),
});
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/auth/magic",
json={
"token": "Zq3xM8vP1kR7tY2wN5bL0aC9dE4fG6hJ",
"device_id": "k3Jd8xQ2vLp9TzR1aBcD4e",
},
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/auth/magic', [
'json' => [
'token' => 'Zq3xM8vP1kR7tY2wN5bL0aC9dE4fG6hJ',
'device_id' => 'k3Jd8xQ2vLp9TzR1aBcD4e',
],
]);
print_r(json_decode((string) $res->getBody(), true));package main
import (
"fmt"
"io"
"net/http"
"strings"
)
func main() {
body := strings.NewReader(`{
"token": "Zq3xM8vP1kR7tY2wN5bL0aC9dE4fG6hJ",
"device_id": "k3Jd8xQ2vLp9TzR1aBcD4e"
}`)
req, err := http.NewRequest("POST", "https://api.chatkomodo.com/auth/magic", body)
if err != nil {
panic(err)
}
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))
}{
"token": "eyJhbGciOiJIUzI1NiIs…",
"refresh_token": "eyJhbGciOiJIUzI1NiIs…",
"role": "admin",
"agent_id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"agent_name": "string"
}Renew a dashboard login
/auth/refreshNo authenticationExchange a valid refresh token for a fresh JWT. The old refresh token is rotated (revoked). Reuse-detection blocks compromised tokens.
Request body
refresh_tokenstringrequired
Responses
- 200Refreshed
Response fields
tokenstringrequiredJWT to use in Authorization: Bearer headerrefresh_tokenstringRefresh token (long-lived)rolestringrequiredagent_idstringagent_namestring
- 401Token revoked or compromised
curl -X POST "https://api.chatkomodo.com/auth/refresh" \
-H "Content-Type: application/json" \
-d '{
"refresh_token": "eyJhbGciOiJIUzI1NiIs…"
}'const res = await fetch('https://api.chatkomodo.com/auth/refresh', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
"refresh_token": "eyJhbGciOiJIUzI1NiIs…"
}),
});
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/auth/refresh",
json={
"refresh_token": "eyJhbGciOiJIUzI1NiIs…",
},
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/auth/refresh', [
'json' => [
'refresh_token' => 'eyJhbGciOiJIUzI1NiIs…',
],
]);
print_r(json_decode((string) $res->getBody(), true));package main
import (
"fmt"
"io"
"net/http"
"strings"
)
func main() {
body := strings.NewReader(`{
"refresh_token": "eyJhbGciOiJIUzI1NiIs…"
}`)
req, err := http.NewRequest("POST", "https://api.chatkomodo.com/auth/refresh", body)
if err != nil {
panic(err)
}
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))
}{
"token": "eyJhbGciOiJIUzI1NiIs…",
"refresh_token": "eyJhbGciOiJIUzI1NiIs…",
"role": "admin",
"agent_id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"agent_name": "string"
}Security check site key
/auth/turnstileNo authenticationSite key of the Cloudflare Turnstile check on POST /auth/request-otp and POST /auth/register (null when the check is off). When it is on, those requests need turnstile_token from the widget (rendered with action login or register); without a valid token they answer 403 TURNSTILE_REQUIRED or TURNSTILE_FAILED. Requests from an agency's own activated domain are exempt.
Responses
- 200Site key
Response fields
site_keystring | nullrequired
curl "https://api.chatkomodo.com/auth/turnstile"const res = await fetch('https://api.chatkomodo.com/auth/turnstile', {
method: 'GET',
});
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/auth/turnstile",
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/auth/turnstile', [
]);
print_r(json_decode((string) $res->getBody(), true));package main
import (
"fmt"
"io"
"net/http"
)
func main() {
req, err := http.NewRequest("GET", "https://api.chatkomodo.com/auth/turnstile", nil)
if err != nil {
panic(err)
}
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))
}{
"site_key": "uploads/abc123.jpg"
}Who am I
/v1/meDashboard loginIdentity of the caller: the tenant, its plan and business profile, and whether the credential is the owner login (admin), a customer-service agent (agent) or an API key (apikey). With the platform admin secret it returns is_super: true and no plan.
Responses
- 200Caller identity
Response fields
tenant_idstringrequiredTenant id (__super__for the platform admin secret)namestringrequiredBusiness / account namephonestring | nullrequiredOwner login number, or the agent's own number for roleagentrolestringrequiredis_superbooleantrueonly for the platform admin secretagent_idstring | nullRoleagentonlyagent_namestring | nullRoleagentonlykey_idstringRoleapikeyonly: id of the key used for this request (a child key has its own id)idle_minutesintegerRolesadminandagent: sign out after this many minutes without use (0 = off); set inPUT /v1/securityplanobject | nullrequiredplan.idintegerrequiredplan.namestringrequiredplan.active_untilinteger | nullrequiredUnix ms until which the paid plan is active, or nullplan.pendingobject | nullA paid downgrade that takes over when the current period endsplan.pending.idintegerrequiredplan.pending.namestringrequiredplan.pending.starts_atintegerrequiredplan.pending.untilintegerrequiredprofileobjectBusiness profile; same data asGET /v1/profile. Absent for the platform admin secretprofile.business_namestring | nullrequiredprofile.countrystringrequiredISO 3166-1 alpha-2 codeprofile.timezonestringrequiredIANA timezoneprofile.localestringrequiredenoridprofile.industrystring | nullrequiredprofile.currencystringrequiredBilling currency,IDRorUSDprofile.configuredbooleanrequired
- 401Missing, invalid or expired credentials
- 404Tenant not found (
NOT_FOUND)
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))
}{
"tenant_id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"name": "Example",
"phone": "+447700900123",
"role": "admin",
"is_super": true,
"agent_id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"agent_name": "string",
"key_id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"idle_minutes": 1,
"plan": {
"id": 1,
"name": "Example",
"active_until": 1767225600000,
"pending": {
"id": 1,
"name": "Example",
"starts_at": 1767225600000,
"until": 1767225600000
}
},
"profile": {
"business_name": "string",
"country": "GB",
"timezone": "Asia/Jakarta",
"locale": "en",
"industry": "string",
"currency": "IDR",
"configured": true
}
}Sign in with an access code
/auth/loginNo authenticationDashboard sign-in with the tenant owner's or a customer-service agent's access code. Returns a JWT valid for 2 hours, to be sent as Authorization: Bearer <token>. No refresh token is issued here (sign in with a one-time code via /auth/verify-otp to get one). Limited to 10 attempts per 10 minutes per IP address (an IPv6 address counts by its /64). When GET /auth/turnstile returns a site key, turnstile_token from the Turnstile widget is required, as for /auth/request-otp.
Request body
codestringrequiredAccess codeturnstile_tokenstringToken from the Turnstile widget, required whenGET /auth/turnstilereturns a site keydevice_idstringRandom id the browser keeps for itself (letters, digits,_,-). An owner with a passkey or authenticator app signing in from a device id never seen before (or not for 180 days) gets thenew_devicestep first
Responses
- 200Signed in, or (owner) one more step:
mfa_requiredwithmethods(passkey→/auth/passkey/options;totp→/auth/verify-mfawithmfa_token) andreason: new_deviceResponse fields
tokenstringJWT for theAuthorization: Bearerheaderrolestringagent_idstringRoleagentonlyagent_namestringRoleagentonlymfa_requiredbooleanreasonstringmethodsarray of stringmfa_tokenstring
- 400
codeis missing or longer than 128 characters (nocode) - 401Invalid access code (no
code) - 403
TURNSTILE_REQUIREDorTURNSTILE_FAILED: the security check is on andturnstile_tokenis missing or invalid - 429Too many attempts from this IP address (no
code)
curl -X POST "https://api.chatkomodo.com/auth/login" \
-H "Content-Type: application/json" \
-d '{
"code": "a1b2c3d4e5f6",
"device_id": "k3Jd8xQ2vLp9TzR1aBcD4e"
}'const res = await fetch('https://api.chatkomodo.com/auth/login', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
"code": "a1b2c3d4e5f6",
"device_id": "k3Jd8xQ2vLp9TzR1aBcD4e"
}),
});
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/auth/login",
json={
"code": "a1b2c3d4e5f6",
"device_id": "k3Jd8xQ2vLp9TzR1aBcD4e",
},
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/auth/login', [
'json' => [
'code' => 'a1b2c3d4e5f6',
'device_id' => 'k3Jd8xQ2vLp9TzR1aBcD4e',
],
]);
print_r(json_decode((string) $res->getBody(), true));package main
import (
"fmt"
"io"
"net/http"
"strings"
)
func main() {
body := strings.NewReader(`{
"code": "a1b2c3d4e5f6",
"device_id": "k3Jd8xQ2vLp9TzR1aBcD4e"
}`)
req, err := http.NewRequest("POST", "https://api.chatkomodo.com/auth/login", body)
if err != nil {
panic(err)
}
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))
}{
"token": "eyJhbGciOiJIUzI1NiIs…",
"role": "admin",
"agent_id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"agent_name": "string",
"mfa_required": true,
"reason": "new_device",
"methods": [
"passkey"
],
"mfa_token": "eyJhbGciOiJIUzI1NiIs…"
}Sign out
/auth/logoutEnds a dashboard login (owner or agent). Send the refresh token in the body, the access token as Authorization: Bearer, or both; at least one is required. The refresh token is deleted and the login session is revoked, so the access token stops working immediately. Idempotent. The bearer token is optional here and only a JWT counts (an API key is ignored).
Request body
refresh_tokenstringRefresh token issued at sign-in
Responses
- 200Signed out
Response fields
okbooleanrequired
- 400Neither a refresh token nor a valid access token was supplied (no
code)
curl -X POST "https://api.chatkomodo.com/auth/logout" \
-H "Authorization: Bearer $CHATKOMODO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"refresh_token": "eyJhbGciOiJIUzI1NiIs…"
}'const res = await fetch('https://api.chatkomodo.com/auth/logout', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.CHATKOMODO_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"refresh_token": "eyJhbGciOiJIUzI1NiIs…"
}),
});
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/auth/logout",
headers={
"Authorization": f"Bearer {os.environ['CHATKOMODO_API_KEY']}",
},
json={
"refresh_token": "eyJhbGciOiJIUzI1NiIs…",
},
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/auth/logout', [
'headers' => [
'Authorization' => 'Bearer ' . getenv('CHATKOMODO_API_KEY'),
],
'json' => [
'refresh_token' => 'eyJhbGciOiJIUzI1NiIs…',
],
]);
print_r(json_decode((string) $res->getBody(), true));package main
import (
"fmt"
"io"
"net/http"
"os"
"strings"
)
func main() {
body := strings.NewReader(`{
"refresh_token": "eyJhbGciOiJIUzI1NiIs…"
}`)
req, err := http.NewRequest("POST", "https://api.chatkomodo.com/auth/logout", 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))
}{
"ok": true
}Sign in with an authenticator code
/auth/verify-totpNo authenticationFallback sign-in for a tenant owner when the WhatsApp one-time code cannot be delivered. Needs two-factor authentication to be set up on the account. Accepts the 6-digit code of the previous, current or next 30-second window. Failed codes lock the account for increasing periods (3 failures: 5 minutes, 5: 1 hour, 10: 24 hours) and each IP address is limited to 8 requests per 10 minutes (counted together with /auth/request-otp and /auth/register). Returns a 2-hour JWT and a refresh token. Customer-service agents cannot use this endpoint.
Request body
phonestringrequiredOwner login number, international format+<country code><number>codestringrequired6-digit authenticator code
Responses
- 200Signed in
Response fields
tokenstringrequiredJWT for theAuthorization: Bearerheaderrolestringrequiredrefresh_tokenstringrequiredRotating refresh token, valid 30 days. Exchange it at/auth/refresh
- 400
phoneorcodemissing (nocode) - 4012FA is not enabled for this account (also returned for an unknown number), or the code is wrong (no
code) - 429Too many requests from this IP address, or the account is locked after repeated wrong codes (no
code)
curl -X POST "https://api.chatkomodo.com/auth/verify-totp" \
-H "Content-Type: application/json" \
-d '{
"phone": "+447700900123",
"code": "482913"
}'const res = await fetch('https://api.chatkomodo.com/auth/verify-totp', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
"phone": "+447700900123",
"code": "482913"
}),
});
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/auth/verify-totp",
json={
"phone": "+447700900123",
"code": "482913",
},
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/auth/verify-totp', [
'json' => [
'phone' => '+447700900123',
'code' => '482913',
],
]);
print_r(json_decode((string) $res->getBody(), true));package main
import (
"fmt"
"io"
"net/http"
"strings"
)
func main() {
body := strings.NewReader(`{
"phone": "+447700900123",
"code": "482913"
}`)
req, err := http.NewRequest("POST", "https://api.chatkomodo.com/auth/verify-totp", body)
if err != nil {
panic(err)
}
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))
}{
"token": "eyJhbGciOiJIUzI1NiIs…",
"role": "admin",
"refresh_token": "eyJhbGciOiJIUzI1NiIs…"
}Second sign-in step: authenticator code
/auth/verify-mfaNo authenticationWhen the owner turned on "authenticator code at every sign-in" (PUT /v1/security), /auth/verify-otp and /auth/login answer { mfa_required: true, mfa_token } instead of tokens. Send that ticket with the 6-digit code from the authenticator app to finish signing in. Recorded as auth.login with detail otp+totp.
Request body
mfa_tokenstringrequiredcodestringrequired6-digit authenticator codedevice_idstringRandom id the browser keeps for itself (letters, digits,_,-). Remembered after this sign-in. An owner with a passkey or authenticator app signing in from a device id never seen before (or not for 180 days) gets thenew_devicestep first
Responses
- 200Signed in
Response fields
tokenstringrequiredJWT for theAuthorization: Bearerheader (2 hours)rolestringrequiredrefresh_tokenstringrequiredRotating refresh token, valid 30 days. Exchange it at/auth/refresh
- 400
mfa_tokenorcodemissing (nocode) - 401The ticket expired or was used 5 times, or the code is wrong (no
code) - 429Too many requests from this IP address (no
code)
curl -X POST "https://api.chatkomodo.com/auth/verify-mfa" \
-H "Content-Type: application/json" \
-d '{
"mfa_token": "mfa_7Gx2Kp9Qr4",
"code": "123456",
"device_id": "k3Jd8xQ2vLp9TzR1aBcD4e"
}'const res = await fetch('https://api.chatkomodo.com/auth/verify-mfa', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
"mfa_token": "mfa_7Gx2Kp9Qr4",
"code": "123456",
"device_id": "k3Jd8xQ2vLp9TzR1aBcD4e"
}),
});
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/auth/verify-mfa",
json={
"mfa_token": "mfa_7Gx2Kp9Qr4",
"code": "123456",
"device_id": "k3Jd8xQ2vLp9TzR1aBcD4e",
},
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/auth/verify-mfa', [
'json' => [
'mfa_token' => 'mfa_7Gx2Kp9Qr4',
'code' => '123456',
'device_id' => 'k3Jd8xQ2vLp9TzR1aBcD4e',
],
]);
print_r(json_decode((string) $res->getBody(), true));package main
import (
"fmt"
"io"
"net/http"
"strings"
)
func main() {
body := strings.NewReader(`{
"mfa_token": "mfa_7Gx2Kp9Qr4",
"code": "123456",
"device_id": "k3Jd8xQ2vLp9TzR1aBcD4e"
}`)
req, err := http.NewRequest("POST", "https://api.chatkomodo.com/auth/verify-mfa", body)
if err != nil {
panic(err)
}
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))
}{
"token": "eyJhbGciOiJIUzI1NiIs…",
"role": "admin",
"refresh_token": "eyJhbGciOiJIUzI1NiIs…"
}Start a passkey sign-in
/auth/passkey/optionsNo authenticationWebAuthn authentication options for the owner's passkey (registered in Settings → Security, POST /v1/security/passkeys). Pass options to the browser (navigator.credentials.get / @simplewebauthn/browser startAuthentication) and send the result with challenge_id to /auth/passkey/verify within 5 minutes. No phone number needed: passkeys are discoverable.
Responses
- 200Options
Response fields
challenge_idstringrequiredoptionsobjectrequiredPublicKeyCredentialRequestOptionsJSON
- 429Too many requests from this IP address (no
code)
curl -X POST "https://api.chatkomodo.com/auth/passkey/options"const res = await fetch('https://api.chatkomodo.com/auth/passkey/options', {
method: 'POST',
});
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/auth/passkey/options",
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/auth/passkey/options', [
]);
print_r(json_decode((string) $res->getBody(), true));package main
import (
"fmt"
"io"
"net/http"
)
func main() {
req, err := http.NewRequest("POST", "https://api.chatkomodo.com/auth/passkey/options", nil)
if err != nil {
panic(err)
}
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))
}{
"challenge_id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"options": {}
}Finish a passkey sign-in
/auth/passkey/verifyNo authenticationVerifies the browser's passkey response and signs the owner in (a passkey is a strong factor on its own: no authenticator code is asked even when it is required for WhatsApp-code sign-ins). Recorded as auth.login with detail passkey.
Request body
challenge_idstringrequiredresponseobjectrequiredAuthenticationResponseJSON from the browserdevice_idstringRandom id the browser keeps for itself; remembered after this sign-in
Responses
- 200Signed in
Response fields
tokenstringrequiredJWT for theAuthorization: Bearerheader (2 hours)rolestringrequiredrefresh_tokenstringrequiredRotating refresh token, valid 30 days. Exchange it at/auth/refresh
- 400Missing fields, or the request expired (
CHALLENGE_EXPIRED) - 401Unknown passkey (
PASSKEY_UNKNOWN) or a failed verification (PASSKEY_INVALID)
curl -X POST "https://api.chatkomodo.com/auth/passkey/verify" \
-H "Content-Type: application/json" \
-d '{
"challenge_id": "c1h2a3l4l5e6n7g8e9",
"response": {
"id": "credential-id",
"rawId": "credential-id",
"type": "public-key",
"response": {}
},
"device_id": "k3Jd8xQ2vLp9TzR1aBcD4e"
}'const res = await fetch('https://api.chatkomodo.com/auth/passkey/verify', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
"challenge_id": "c1h2a3l4l5e6n7g8e9",
"response": {
"id": "credential-id",
"rawId": "credential-id",
"type": "public-key",
"response": {}
},
"device_id": "k3Jd8xQ2vLp9TzR1aBcD4e"
}),
});
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/auth/passkey/verify",
json={
"challenge_id": "c1h2a3l4l5e6n7g8e9",
"response": {
"id": "credential-id",
"rawId": "credential-id",
"type": "public-key",
"response": {},
},
"device_id": "k3Jd8xQ2vLp9TzR1aBcD4e",
},
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/auth/passkey/verify', [
'json' => [
'challenge_id' => 'c1h2a3l4l5e6n7g8e9',
'response' => [
'id' => 'credential-id',
'rawId' => 'credential-id',
'type' => 'public-key',
'response' => [],
],
'device_id' => 'k3Jd8xQ2vLp9TzR1aBcD4e',
],
]);
print_r(json_decode((string) $res->getBody(), true));package main
import (
"fmt"
"io"
"net/http"
"strings"
)
func main() {
body := strings.NewReader(`{
"challenge_id": "c1h2a3l4l5e6n7g8e9",
"response": {
"id": "credential-id",
"rawId": "credential-id",
"type": "public-key",
"response": {}
},
"device_id": "k3Jd8xQ2vLp9TzR1aBcD4e"
}`)
req, err := http.NewRequest("POST", "https://api.chatkomodo.com/auth/passkey/verify", body)
if err != nil {
panic(err)
}
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))
}{
"token": "eyJhbGciOiJIUzI1NiIs…",
"role": "admin",
"refresh_token": "eyJhbGciOiJIUzI1NiIs…"
}