ChatKomodo Docs Home Sign in

API reference · Conversations

Agents & assignment

Customer-service agents who work the shared inbox, the queue of unassigned chats, assignment and resolving.

List customer-service agents

GET/v1/cs/agents

Agents of the tenant, ordered by name. Secrets (access code hash, authenticator secret) are never included.

Responses

  • 200Agents
    Response fields
    • agentsarray of objectrequired
    • agents[].idstringrequired
    • agents[].api_key_idstringrequired
      Owning tenant
    • agents[].namestringrequired
    • agents[].rolestringrequired
      Stored as given at creation (default agent)
    • agents[].is_onlineintegerrequired
      1 or 0
    • agents[].max_chatsinteger | nullrequired
      Concurrent chat cap
    • agents[].active_chatsinteger | nullrequired
      Chats currently assigned and unresolved
    • agents[].created_atintegerrequired
      Unix time in milliseconds
    • agents[].phonestring | nullrequired
      Login number, digits with country code
    • agents[].has_access_codebooleanrequired
      Whether an access code is set. The code and its hash are never returned
  • 401Missing, invalid or expired credentials
Request
curl "https://api.chatkomodo.com/v1/cs/agents" \
  -H "Authorization: Bearer $CHATKOMODO_API_KEY"
const res = await fetch('https://api.chatkomodo.com/v1/cs/agents', {
  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/cs/agents",
    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/cs/agents', [
    '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/cs/agents", 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
{
  "agents": [
    {
      "id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
      "api_key_id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
      "name": "Sam Carter",
      "role": "agent",
      "is_online": 1,
      "max_chats": 1,
      "active_chats": 1,
      "created_at": 1767225600000,
      "phone": "+447700900123",
      "has_access_code": true
    }
  ]
}

Create a customer-service agent

POST/v1/cs/agents

Adds an agent who can sign in to the dashboard and work the shared inbox. An agent signs in with a WhatsApp number plus one-time code (phone), or with an access_code. The phone number must not already belong to another agent or to a tenant owner login. A sign-in (phone or access_code) can only be set from the signed-in dashboard: with an API key the request is refused (AGENT_LOGIN_REQUIRES_LOGIN), so a leaked key cannot create logins.

Request body

  • namestringrequired
    Display name; must contain a non-blank value
  • rolestring
    Stored as given (default agent)
  • max_chatsinteger
    Concurrent chat cap (default 10)
  • access_codestring
    Optional login code, 10 to 128 characters. Stored only as a salted hash and never returned
  • phonestring
    WhatsApp number used for one-time-code login; international format, or local format resolved against the business country

Responses

  • 201Created
    Response fields
    • idstringrequired
    • phonestring | nullrequired
      Normalised login number (digits), or null when none was given
  • 400name is missing or blank, or access_code is not 10 to 128 characters (VALIDATION_FAILED)
  • 401Missing, invalid or expired credentials
  • 403phone or access_code sent with an API key (AGENT_LOGIN_REQUIRES_LOGIN)
  • 409The number is already used by another account (PHONE_IN_USE)
Request
curl -X POST "https://api.chatkomodo.com/v1/cs/agents" \
  -H "Authorization: Bearer $CHATKOMODO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "Sam Carter",
  "phone": "+447700900123",
  "max_chats": 10
}'
const res = await fetch('https://api.chatkomodo.com/v1/cs/agents', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.CHATKOMODO_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "name": "Sam Carter",
    "phone": "+447700900123",
    "max_chats": 10
  }),
});
const data = await res.json();
if (!res.ok) throw new Error(`${data.code}: ${data.error}`);
console.log(data);
import os
import requests

res = requests.post(
    "https://api.chatkomodo.com/v1/cs/agents",
    headers={
        "Authorization": f"Bearer {os.environ['CHATKOMODO_API_KEY']}",
    },
    json={
        "name": "Sam Carter",
        "phone": "+447700900123",
        "max_chats": 10,
    },
    timeout=30,
)
res.raise_for_status()
print(res.json())
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();
$res = $client->request('POST', 'https://api.chatkomodo.com/v1/cs/agents', [
    'headers' => [
        'Authorization' => 'Bearer ' . getenv('CHATKOMODO_API_KEY'),
    ],
    'json' => [
        'name' => 'Sam Carter',
        'phone' => '+447700900123',
        'max_chats' => 10,
    ],
]);

print_r(json_decode((string) $res->getBody(), true));
package main

import (
	"fmt"
	"io"
	"net/http"
	"os"
	"strings"
)

func main() {
	body := strings.NewReader(`{
	  "name": "Sam Carter",
	  "phone": "+447700900123",
	  "max_chats": 10
	}`)
	req, err := http.NewRequest("POST", "https://api.chatkomodo.com/v1/cs/agents", 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 201
{
  "id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
  "phone": "+447700900123"
}

Edit a customer-service agent

PATCH/v1/cs/agents/{id}

Changes the name, online flag, chat cap and/or access code of one of the tenant's agents. Send only the fields to change. The phone number cannot be changed here, and a new access code can only be set from the signed-in dashboard (AGENT_LOGIN_REQUIRES_LOGIN with an API key); a new access code signs the agent out everywhere.

Path parameters

  • idstringrequired
    Agent id

Request body

  • namestring
  • is_onlineboolean
  • max_chatsinteger
    Concurrent chat cap
  • access_codestring
    New login code, 10 to 128 characters (ignored when empty). Stored only as a salted hash

Responses

  • 200Updated
    Response fields
    • okbooleanrequired
  • 400A field has the wrong type or length (VALIDATION_FAILED)
  • 401Missing, invalid or expired credentials
  • 403access_code sent with an API key (AGENT_LOGIN_REQUIRES_LOGIN)
  • 404No agent with this id in the tenant (NOT_FOUND)
Request
curl -X PATCH "https://api.chatkomodo.com/v1/cs/agents/ID" \
  -H "Authorization: Bearer $CHATKOMODO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "Sam Carter",
  "is_online": true,
  "max_chats": 1,
  "access_code": "482913"
}'
const res = await fetch('https://api.chatkomodo.com/v1/cs/agents/ID', {
  method: 'PATCH',
  headers: {
    Authorization: `Bearer ${process.env.CHATKOMODO_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "name": "Sam Carter",
    "is_online": true,
    "max_chats": 1,
    "access_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.patch(
    "https://api.chatkomodo.com/v1/cs/agents/ID",
    headers={
        "Authorization": f"Bearer {os.environ['CHATKOMODO_API_KEY']}",
    },
    json={
        "name": "Sam Carter",
        "is_online": True,
        "max_chats": 1,
        "access_code": "482913",
    },
    timeout=30,
)
res.raise_for_status()
print(res.json())
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();
$res = $client->request('PATCH', 'https://api.chatkomodo.com/v1/cs/agents/ID', [
    'headers' => [
        'Authorization' => 'Bearer ' . getenv('CHATKOMODO_API_KEY'),
    ],
    'json' => [
        'name' => 'Sam Carter',
        'is_online' => true,
        'max_chats' => 1,
        'access_code' => '482913',
    ],
]);

print_r(json_decode((string) $res->getBody(), true));
package main

import (
	"fmt"
	"io"
	"net/http"
	"os"
	"strings"
)

func main() {
	body := strings.NewReader(`{
	  "name": "Sam Carter",
	  "is_online": true,
	  "max_chats": 1,
	  "access_code": "482913"
	}`)
	req, err := http.NewRequest("PATCH", "https://api.chatkomodo.com/v1/cs/agents/ID", 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
}

Delete a customer-service agent

DEL/v1/cs/agents/{id}

Deletes the agent. Chats assigned to them become unassigned.

Path parameters

  • idstringrequired
    Agent id

Responses

  • 200Deleted
    Response fields
    • okbooleanrequired
  • 401Missing, invalid or expired credentials
  • 403Forbidden for a customer-service agent login (Agent access is not allowed for this operation) and an API key restricted to specific sessions (KEY_SCOPE_FORBIDDEN)
  • 404Agent not found (no code)
Request
curl -X DELETE "https://api.chatkomodo.com/v1/cs/agents/ID" \
  -H "Authorization: Bearer $CHATKOMODO_API_KEY"
const res = await fetch('https://api.chatkomodo.com/v1/cs/agents/ID', {
  method: 'DELETE',
  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.delete(
    "https://api.chatkomodo.com/v1/cs/agents/ID",
    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('DELETE', 'https://api.chatkomodo.com/v1/cs/agents/ID', [
    '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("DELETE", "https://api.chatkomodo.com/v1/cs/agents/ID", 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
{
  "ok": true
}

Sign an agent out everywhere

POST/v1/cs/agents/{id}/revoke-sessions

Signs the agent out on every device: access tokens already issued stop working at once and refresh tokens are deleted. Setting a new access_code (PATCH) does the same. Recorded in the audit log as agent.revoke_sessions.

Path parameters

  • idstringrequired
    Agent id

Responses

  • 200Revoked
    Response fields
    • okbooleanrequired
    • revokedintegerrequired
      Number of sign-ins ended
  • 401Missing, invalid or expired credentials
  • 403Forbidden for a customer-service agent login (Agent access is not allowed for this operation) and an API key restricted to specific sessions (KEY_SCOPE_FORBIDDEN)
  • 404Agent not found (no code)
Request
curl -X POST "https://api.chatkomodo.com/v1/cs/agents/ID/revoke-sessions" \
  -H "Authorization: Bearer $CHATKOMODO_API_KEY"
const res = await fetch('https://api.chatkomodo.com/v1/cs/agents/ID/revoke-sessions', {
  method: 'POST',
  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.post(
    "https://api.chatkomodo.com/v1/cs/agents/ID/revoke-sessions",
    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('POST', 'https://api.chatkomodo.com/v1/cs/agents/ID/revoke-sessions', [
    '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("POST", "https://api.chatkomodo.com/v1/cs/agents/ID/revoke-sessions", 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
{
  "ok": true,
  "revoked": 1
}

List unassigned open chats

GET/v1/cs/queue

Open chats on the tenant's devices that no agent is assigned to yet, most recent activity first, at most 200. Available to agents as well as the owner.

Responses

  • 200Queue
    Response fields
    • queuearray of objectrequired
    • queue[].idstringrequired
    • queue[].session_idstringrequired
    • queue[].chat_idstringrequired
    • queue[].chat_namestring | nullrequired
    • queue[].last_messagestring | nullrequired
    • queue[].last_message_atinteger | nullrequired
    • queue[].unread_countinteger | nullrequired
    • queue[].is_groupinteger | nullrequired
      1 = group chat
    • queue[].agent_idany | nullrequired
      Always null in the queue
    • queue[].statusstringrequired
      open
  • 401Missing, invalid or expired credentials
Request
curl "https://api.chatkomodo.com/v1/cs/queue" \
  -H "Authorization: Bearer $CHATKOMODO_API_KEY"
const res = await fetch('https://api.chatkomodo.com/v1/cs/queue', {
  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/cs/queue",
    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/cs/queue', [
    '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/cs/queue", 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
{
  "queue": [
    {
      "id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
      "session_id": "YOUR_DEVICE_ID",
      "chat_id": "+447700900123",
      "chat_name": "string",
      "last_message": "Hi Sam, your order has shipped.",
      "last_message_at": 1767225600000,
      "unread_count": 12,
      "is_group": 1,
      "agent_id": null,
      "status": "active"
    }
  ]
}

Alert setting for unanswered chats

GET/v1/cs/reply-alert

A customer waits from their first unanswered message in a 1:1 chat until the team answers: from the dashboard, the API or the phone itself. When the wait reaches minutes, the assigned agent's devices (the owner's for a chat nobody has) get a notification and the chat.unanswered webhook fires; with reassign_minutes, an assigned chat then moves to the next agent in turn.

Responses

  • 200Setting
    Response fields
    • enabledbooleanrequired
    • minutesintegerrequired
      Alert after this many minutes without an answer (1–1440, default 15)
    • reassign_minutesinteger | nullrequired
      Move an assigned chat to the next agent in turn after this many minutes (more than minutes, at most 2880); null = never
    • business_hours_onlybooleanrequired
      Only alert and move chats during business hours (when business hours are on)
    • bots_answerbooleanrequired
      Automatic replies (welcome, auto-reply, flows, AI) count as an answer
  • 401Missing, invalid or expired credentials
Request
curl "https://api.chatkomodo.com/v1/cs/reply-alert" \
  -H "Authorization: Bearer $CHATKOMODO_API_KEY"
const res = await fetch('https://api.chatkomodo.com/v1/cs/reply-alert', {
  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/cs/reply-alert",
    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/cs/reply-alert', [
    '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/cs/reply-alert", 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
{
  "enabled": true,
  "minutes": 1,
  "reassign_minutes": 1,
  "business_hours_only": true,
  "bots_answer": true
}

Set the alert for unanswered chats

PUT/v1/cs/reply-alert

Fields left out take their default. Recorded in the audit log as settings.reply_alert.

Request body

  • enabledbooleanrequired
  • minutesinteger
    Alert after this many minutes without an answer (1–1440, default 15)
  • reassign_minutesinteger | null
    Move an assigned chat to the next agent in turn after this many minutes (more than minutes, at most 2880); null = never
  • business_hours_onlyboolean
    Only alert and move chats during business hours (when business hours are on)
  • bots_answerboolean
    Automatic replies (welcome, auto-reply, flows, AI) count as an answer

Responses

  • 200Saved
    Response fields
    • enabledbooleanrequired
    • minutesintegerrequired
      Alert after this many minutes without an answer (1–1440, default 15)
    • reassign_minutesinteger | nullrequired
      Move an assigned chat to the next agent in turn after this many minutes (more than minutes, at most 2880); null = never
    • business_hours_onlybooleanrequired
      Only alert and move chats during business hours (when business hours are on)
    • bots_answerbooleanrequired
      Automatic replies (welcome, auto-reply, flows, AI) count as an answer
  • 400Body is not valid JSON (INVALID_JSON) or fails validation (VALIDATION_FAILED)
  • 401Missing, invalid or expired credentials
  • 403Forbidden for a customer-service agent login (Agent access is not allowed for this operation)
Request
curl -X PUT "https://api.chatkomodo.com/v1/cs/reply-alert" \
  -H "Authorization: Bearer $CHATKOMODO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "enabled": true,
  "minutes": 1,
  "reassign_minutes": 1
}'
const res = await fetch('https://api.chatkomodo.com/v1/cs/reply-alert', {
  method: 'PUT',
  headers: {
    Authorization: `Bearer ${process.env.CHATKOMODO_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "enabled": true,
    "minutes": 1,
    "reassign_minutes": 1
  }),
});
const data = await res.json();
if (!res.ok) throw new Error(`${data.code}: ${data.error}`);
console.log(data);
import os
import requests

res = requests.put(
    "https://api.chatkomodo.com/v1/cs/reply-alert",
    headers={
        "Authorization": f"Bearer {os.environ['CHATKOMODO_API_KEY']}",
    },
    json={
        "enabled": True,
        "minutes": 1,
        "reassign_minutes": 1,
    },
    timeout=30,
)
res.raise_for_status()
print(res.json())
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();
$res = $client->request('PUT', 'https://api.chatkomodo.com/v1/cs/reply-alert', [
    'headers' => [
        'Authorization' => 'Bearer ' . getenv('CHATKOMODO_API_KEY'),
    ],
    'json' => [
        'enabled' => true,
        'minutes' => 1,
        'reassign_minutes' => 1,
    ],
]);

print_r(json_decode((string) $res->getBody(), true));
package main

import (
	"fmt"
	"io"
	"net/http"
	"os"
	"strings"
)

func main() {
	body := strings.NewReader(`{
	  "enabled": true,
	  "minutes": 1,
	  "reassign_minutes": 1
	}`)
	req, err := http.NewRequest("PUT", "https://api.chatkomodo.com/v1/cs/reply-alert", 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
{
  "enabled": true,
  "minutes": 1,
  "reassign_minutes": 1,
  "business_hours_only": true,
  "bots_answer": true
}

Support team performance

GET/v1/cs/report

For the last days (7, 30 or 90): answers and how long customers waited for them (average, median, share within the alert time), chats assigned and resolved, alerts and chats moved away, and satisfaction (CSAT, by the agent the chat is assigned to), per agent; the row with id: null is the owner and API. waiting_now counts customers waiting right now.

Query parameters

  • daysstring
    One of: 7, 30, 90

Responses

  • 200Report
    Response fields
    • daysintegerrequired
    • sinceintegerrequired
      Unix time in milliseconds
    • target_minutesintegerrequired
    • alerts_enabledbooleanrequired
    • totalsobjectrequired
    • totals.repliesintegerrequired
    • totals.avg_reply_msinteger | nullrequired
    • totals.median_reply_msinteger | nullrequired
    • totals.within_targetnumber | nullrequired
    • totals.waiting_nowintegerrequired
    • totals.oldest_waiting_sinceinteger | nullrequired
      Unix time in milliseconds, or null
    • totals.alertsintegerrequired
    • totals.movedintegerrequired
    • totals.csatnumber | nullrequired
    • agentsarray of objectrequired
    • agents[].idstring | nullrequired
    • agents[].namestring | nullrequired
    • agents[].onlinebooleanrequired
    • agents[].open_chatsintegerrequired
    • agents[].assignedintegerrequired
    • agents[].resolvedintegerrequired
    • agents[].repliesintegerrequired
    • agents[].avg_reply_msinteger | nullrequired
    • agents[].median_reply_msinteger | nullrequired
    • agents[].within_targetnumber | nullrequired
    • agents[].alertsintegerrequired
    • agents[].moved_awayintegerrequired
    • agents[].csatnumber | nullrequired
    • agents[].csat_countintegerrequired
  • 401Missing, invalid or expired credentials
  • 403Forbidden for a customer-service agent login (Agent access is not allowed for this operation)
Request
curl "https://api.chatkomodo.com/v1/cs/report" \
  -H "Authorization: Bearer $CHATKOMODO_API_KEY"
const res = await fetch('https://api.chatkomodo.com/v1/cs/report', {
  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/cs/report",
    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/cs/report', [
    '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/cs/report", 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
{
  "days": 1,
  "since": 1767225600000,
  "target_minutes": 1,
  "alerts_enabled": true,
  "totals": {
    "replies": 1,
    "avg_reply_ms": 1767225600000,
    "median_reply_ms": 1767225600000,
    "within_target": 0.5,
    "waiting_now": 1,
    "oldest_waiting_since": 1767225600000,
    "alerts": 1,
    "moved": 1,
    "csat": 0.5
  },
  "agents": [
    {
      "id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
      "name": "Example",
      "online": true,
      "open_chats": 1,
      "assigned": 1,
      "resolved": 1,
      "replies": 1,
      "avg_reply_ms": 1767225600000,
      "median_reply_ms": 1767225600000,
      "within_target": 0.5,
      "alerts": 1,
      "moved_away": 1,
      "csat": 0.5,
      "csat_count": 12
    }
  ]
}

Assign a chat to an agent

POST/v1/cs/assign

Assigns a chat to one of the tenant's agents (replacing any earlier assignment) and updates the agent's active-chat count. Available to agents as well as the owner. The body is not validated beyond ownership of agent_id and session_id.

Request body

  • chat_idstringrequired
    Chat JID
  • session_idstringrequired
    Device the chat belongs to
  • agent_idstringrequired
    Agent to assign

Responses

  • 200Assigned
    Response fields
    • okbooleanrequired
  • 401Missing, invalid or expired credentials
  • 403The agent or the device is not the tenant's (message Forbidden, no code)
Request
curl -X POST "https://api.chatkomodo.com/v1/cs/assign" \
  -H "Authorization: Bearer $CHATKOMODO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "session_id": "YOUR_DEVICE_ID",
  "chat_id": "447700900123@s.whatsapp.net",
  "agent_id": "01JA5V6Q8M2H7G4K9P3T0R1S2X"
}'
const res = await fetch('https://api.chatkomodo.com/v1/cs/assign', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.CHATKOMODO_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "session_id": "YOUR_DEVICE_ID",
    "chat_id": "447700900123@s.whatsapp.net",
    "agent_id": "01JA5V6Q8M2H7G4K9P3T0R1S2X"
  }),
});
const data = await res.json();
if (!res.ok) throw new Error(`${data.code}: ${data.error}`);
console.log(data);
import os
import requests

res = requests.post(
    "https://api.chatkomodo.com/v1/cs/assign",
    headers={
        "Authorization": f"Bearer {os.environ['CHATKOMODO_API_KEY']}",
    },
    json={
        "session_id": "YOUR_DEVICE_ID",
        "chat_id": "447700900123@s.whatsapp.net",
        "agent_id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
    },
    timeout=30,
)
res.raise_for_status()
print(res.json())
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();
$res = $client->request('POST', 'https://api.chatkomodo.com/v1/cs/assign', [
    'headers' => [
        'Authorization' => 'Bearer ' . getenv('CHATKOMODO_API_KEY'),
    ],
    'json' => [
        'session_id' => 'YOUR_DEVICE_ID',
        'chat_id' => '447700900123@s.whatsapp.net',
        'agent_id' => '01JA5V6Q8M2H7G4K9P3T0R1S2X',
    ],
]);

print_r(json_decode((string) $res->getBody(), true));
package main

import (
	"fmt"
	"io"
	"net/http"
	"os"
	"strings"
)

func main() {
	body := strings.NewReader(`{
	  "session_id": "YOUR_DEVICE_ID",
	  "chat_id": "447700900123@s.whatsapp.net",
	  "agent_id": "01JA5V6Q8M2H7G4K9P3T0R1S2X"
	}`)
	req, err := http.NewRequest("POST", "https://api.chatkomodo.com/v1/cs/assign", 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
}

Mark a chat as resolved

POST/v1/cs/resolve

Marks a chat resolved, which removes it from the open queue, and frees one slot of the assigned agent. Available to agents as well as the owner.

Request body

  • chat_idstringrequired
    Chat JID
  • session_idstringrequired
    Device the chat belongs to

Responses

  • 200Resolved
    Response fields
    • okbooleanrequired
  • 401Missing, invalid or expired credentials
  • 403The device is not the tenant's (message Forbidden, no code)
Request
curl -X POST "https://api.chatkomodo.com/v1/cs/resolve" \
  -H "Authorization: Bearer $CHATKOMODO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "session_id": "YOUR_DEVICE_ID",
  "chat_id": "447700900123@s.whatsapp.net"
}'
const res = await fetch('https://api.chatkomodo.com/v1/cs/resolve', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.CHATKOMODO_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "session_id": "YOUR_DEVICE_ID",
    "chat_id": "447700900123@s.whatsapp.net"
  }),
});
const data = await res.json();
if (!res.ok) throw new Error(`${data.code}: ${data.error}`);
console.log(data);
import os
import requests

res = requests.post(
    "https://api.chatkomodo.com/v1/cs/resolve",
    headers={
        "Authorization": f"Bearer {os.environ['CHATKOMODO_API_KEY']}",
    },
    json={
        "session_id": "YOUR_DEVICE_ID",
        "chat_id": "447700900123@s.whatsapp.net",
    },
    timeout=30,
)
res.raise_for_status()
print(res.json())
<?php
require 'vendor/autoload.php';

$client = new GuzzleHttp\Client();
$res = $client->request('POST', 'https://api.chatkomodo.com/v1/cs/resolve', [
    'headers' => [
        'Authorization' => 'Bearer ' . getenv('CHATKOMODO_API_KEY'),
    ],
    'json' => [
        'session_id' => 'YOUR_DEVICE_ID',
        'chat_id' => '447700900123@s.whatsapp.net',
    ],
]);

print_r(json_decode((string) $res->getBody(), true));
package main

import (
	"fmt"
	"io"
	"net/http"
	"os"
	"strings"
)

func main() {
	body := strings.NewReader(`{
	  "session_id": "YOUR_DEVICE_ID",
	  "chat_id": "447700900123@s.whatsapp.net"
	}`)
	req, err := http.NewRequest("POST", "https://api.chatkomodo.com/v1/cs/resolve", 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
}