ChatKomodo Docs Home Sign in

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

POST/auth/registerNo authentication

Self-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

  • namestringrequired
    Business or account name
    1–64 characters
  • phonestringrequired
    Owner phone in international format +<country code><number>; also decides the initial business country, timezone and currency
    8–20 characters
  • langstring
    Language of the OTP / notice messages and the initial dashboard language (default: the request language)
    One of: en, id
  • turnstile_tokenstring
    Token from the Turnstile widget, required when GET /auth/turnstile returns a site key
    Up to 2 048 characters

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
  • 403TURNSTILE_REQUIRED or TURNSTILE_FAILED: the security check (see GET /auth/turnstile) is on and turnstile_token is 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)
Request
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))
}
Response 200
{
  "ok": true
}

Request a sign-in code

POST/auth/request-otpNo authentication

Request 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

  • phonestringrequired
    International format +<country code><number>
    8–20 characters
  • turnstile_tokenstring
    Token from the Turnstile widget, required when GET /auth/turnstile returns a site key
    Up to 2 048 characters

Responses

  • 200Accepted: a code is on its way when the number has an account
    Response fields
    • okbooleanrequired
  • 400Validation error
  • 403TURNSTILE_REQUIRED or TURNSTILE_FAILED: the security check (see GET /auth/turnstile) is on and turnstile_token is missing or invalid
  • 429Too many OTP requests
  • 503The sign-in code sender is offline
Request
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))
}
Response 200
{
  "ok": true
}

Sign in with a one-time code

POST/auth/verify-otpNo authentication

Verify 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

  • phonestringrequired
    8–20 characters
  • codestringrequired
    Exactly 6 characters
  • device_idstring
    Random 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
    16–64 characters

Responses

  • 200Authenticated, or the second step (see schema)
    Response fields
    • tokenstringrequired
      JWT to use in Authorization: Bearer header
    • refresh_tokenstring
      Refresh token (long-lived)
    • rolestringrequired
      One of: admin, agent
    • agent_idstring
    • agent_namestring
  • 401Invalid or expired OTP
Request
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))
}
Response 200
{
  "token": "eyJhbGciOiJIUzI1NiIs…",
  "refresh_token": "eyJhbGciOiJIUzI1NiIs…",
  "role": "admin",
  "agent_id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
  "agent_name": "string"
}

Sign in with the one-tap link from the OTP message

POST/auth/magicNo authentication

Sign 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

  • tokenstringrequired
    The m value of the link
  • device_idstring
    16–64 characters

Responses

  • 200Authenticated, or the second step (see /auth/verify-otp)
    Response fields
    • tokenstringrequired
      JWT to use in Authorization: Bearer header
    • refresh_tokenstring
      Refresh token (long-lived)
    • rolestringrequired
      One of: admin, agent
    • agent_idstring
    • agent_namestring
  • 401Expired or already used (LINK_EXPIRED)
  • 429Too many attempts from this IP address
Request
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))
}
Response 200
{
  "token": "eyJhbGciOiJIUzI1NiIs…",
  "refresh_token": "eyJhbGciOiJIUzI1NiIs…",
  "role": "admin",
  "agent_id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
  "agent_name": "string"
}

Renew a dashboard login

POST/auth/refreshNo authentication

Exchange a valid refresh token for a fresh JWT. The old refresh token is rotated (revoked). Reuse-detection blocks compromised tokens.

Request body

  • refresh_tokenstringrequired
    At least 20 characters

Responses

  • 200Refreshed
    Response fields
    • tokenstringrequired
      JWT to use in Authorization: Bearer header
    • refresh_tokenstring
      Refresh token (long-lived)
    • rolestringrequired
      One of: admin, agent
    • agent_idstring
    • agent_namestring
  • 401Token revoked or compromised
Request
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))
}
Response 200
{
  "token": "eyJhbGciOiJIUzI1NiIs…",
  "refresh_token": "eyJhbGciOiJIUzI1NiIs…",
  "role": "admin",
  "agent_id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
  "agent_name": "string"
}

Security check site key

GET/auth/turnstileNo authentication

Site 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
Request
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))
}
Response 200
{
  "site_key": "uploads/abc123.jpg"
}

Who am I

GET/v1/me

Identity 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_idstringrequired
      Tenant id (__super__ for the platform admin secret)
    • namestringrequired
      Business / account name
    • phonestring | nullrequired
      Owner login number, or the agent's own number for role agent
    • rolestringrequired
      One of: admin, agent, apikey
    • is_superboolean
      true only for the platform admin secret
    • agent_idstring | null
      Role agent only
    • agent_namestring | null
      Role agent only
    • key_idstring
      Role apikey only: id of the key used for this request (a child key has its own id)
    • idle_minutesinteger
      Roles admin and agent: sign out after this many minutes without use (0 = off); set in PUT /v1/security
    • planobject | nullrequired
    • plan.idintegerrequired
    • plan.namestringrequired
    • plan.active_untilinteger | nullrequired
      Unix ms until which the paid plan is active, or null
    • plan.pendingobject | null
      A paid downgrade that takes over when the current period ends
    • plan.pending.idintegerrequired
    • plan.pending.namestringrequired
    • plan.pending.starts_atintegerrequired
    • plan.pending.untilintegerrequired
    • profileobject
      Business profile; same data as GET /v1/profile. Absent for the platform admin secret
    • profile.business_namestring | nullrequired
    • profile.countrystringrequired
      ISO 3166-1 alpha-2 code
    • profile.timezonestringrequired
      IANA timezone
    • profile.localestringrequired
      en or id
    • profile.industrystring | nullrequired
    • profile.currencystringrequired
      Billing currency, IDR or USD
    • profile.configuredbooleanrequired
  • 401Missing, invalid or expired credentials
  • 404Tenant not found (NOT_FOUND)
Request
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))
}
Response 200
{
  "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

POST/auth/loginNo authentication

Dashboard 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

  • codestringrequired
    Access code
    1–128 characters
  • turnstile_tokenstring
    Token from the Turnstile widget, required when GET /auth/turnstile returns a site key
    Up to 2 048 characters
  • device_idstring
    Random 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 the new_device step first
    16–64 characters

Responses

  • 200Signed in, or (owner) one more step: mfa_required with methods (passkey → /auth/passkey/options; totp → /auth/verify-mfa with mfa_token) and reason: new_device
    Response fields
    • tokenstring
      JWT for the Authorization: Bearer header
    • rolestring
      One of: admin, agent
    • agent_idstring
      Role agent only
    • agent_namestring
      Role agent only
    • mfa_requiredboolean
      One of: true
    • reasonstring
      One of: new_device
    • methodsarray of string
    • mfa_tokenstring
  • 400code is missing or longer than 128 characters (no code)
  • 401Invalid access code (no code)
  • 403TURNSTILE_REQUIRED or TURNSTILE_FAILED: the security check is on and turnstile_token is missing or invalid
  • 429Too many attempts from this IP address (no code)
Request
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))
}
Response 200
{
  "token": "eyJhbGciOiJIUzI1NiIs…",
  "role": "admin",
  "agent_id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
  "agent_name": "string",
  "mfa_required": true,
  "reason": "new_device",
  "methods": [
    "passkey"
  ],
  "mfa_token": "eyJhbGciOiJIUzI1NiIs…"
}

Sign out

POST/auth/logout

Ends 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_tokenstring
    Refresh token issued at sign-in
    Up to 256 characters

Responses

  • 200Signed out
    Response fields
    • okbooleanrequired
  • 400Neither a refresh token nor a valid access token was supplied (no code)
Request
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))
}
Response 200
{
  "ok": true
}

Sign in with an authenticator code

POST/auth/verify-totpNo authentication

Fallback 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

  • phonestringrequired
    Owner login number, international format +<country code><number>
  • codestringrequired
    6-digit authenticator code

Responses

  • 200Signed in
    Response fields
    • tokenstringrequired
      JWT for the Authorization: Bearer header
    • rolestringrequired
      One of: admin
    • refresh_tokenstringrequired
      Rotating refresh token, valid 30 days. Exchange it at /auth/refresh
  • 400phone or code missing (no code)
  • 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)
Request
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))
}
Response 200
{
  "token": "eyJhbGciOiJIUzI1NiIs…",
  "role": "admin",
  "refresh_token": "eyJhbGciOiJIUzI1NiIs…"
}

Second sign-in step: authenticator code

POST/auth/verify-mfaNo authentication

When 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_tokenstringrequired
  • codestringrequired
    6-digit authenticator code
  • device_idstring
    Random 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 the new_device step first
    16–64 characters

Responses

  • 200Signed in
    Response fields
    • tokenstringrequired
      JWT for the Authorization: Bearer header (2 hours)
    • rolestringrequired
      One of: admin
    • refresh_tokenstringrequired
      Rotating refresh token, valid 30 days. Exchange it at /auth/refresh
  • 400mfa_token or code missing (no code)
  • 401The ticket expired or was used 5 times, or the code is wrong (no code)
  • 429Too many requests from this IP address (no code)
Request
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))
}
Response 200
{
  "token": "eyJhbGciOiJIUzI1NiIs…",
  "role": "admin",
  "refresh_token": "eyJhbGciOiJIUzI1NiIs…"
}

Start a passkey sign-in

POST/auth/passkey/optionsNo authentication

WebAuthn 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_idstringrequired
    • optionsobjectrequired
      PublicKeyCredentialRequestOptionsJSON
  • 429Too many requests from this IP address (no code)
Request
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))
}
Response 200
{
  "challenge_id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
  "options": {}
}

Finish a passkey sign-in

POST/auth/passkey/verifyNo authentication

Verifies 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_idstringrequired
  • responseobjectrequired
    AuthenticationResponseJSON from the browser
  • device_idstring
    Random id the browser keeps for itself; remembered after this sign-in
    16–64 characters

Responses

  • 200Signed in
    Response fields
    • tokenstringrequired
      JWT for the Authorization: Bearer header (2 hours)
    • rolestringrequired
      One of: admin
    • refresh_tokenstringrequired
      Rotating 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)
Request
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))
}
Response 200
{
  "token": "eyJhbGciOiJIUzI1NiIs…",
  "role": "admin",
  "refresh_token": "eyJhbGciOiJIUzI1NiIs…"
}