. Create an API key under API keys.API reference · Customers
Labels & leads
Labels on people and chats (several per chat, shared with the CRM contact), automatic rules (keywords, new chats, store orders, inactivity, AI, a label being added) that label, assign and follow up, the leads board with your own stages, deal values, owners, follow-ups and notes, and the leads report. See the labels & leads guide.
List labels
/v1/labelsEvery label of the business (used on contacts or chats, or created here) with its colour, description and how many contacts and group chats carry it. A chat with a person shares its labels with that person's CRM contact, so the same labels drive segments, broadcasts and the leads board.
Responses
- 200Labels
Response fields
labelsarray of objectrequiredlabels[].namestringrequiredNormalised name: lowercase, spaces become dasheslabels[].colorstringrequired#RRGGBBlabels[].descriptionstring | nullrequiredlabels[].countintegerrequiredContacts and group chats that carry itcolorsarray of stringrequiredSuggested colours
- 401Missing, invalid or expired credentials
curl "https://api.chatkomodo.com/v1/labels" \
-H "Authorization: Bearer $CHATKOMODO_API_KEY"const res = await fetch('https://api.chatkomodo.com/v1/labels', {
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/labels",
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/labels', [
'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/labels", 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))
}{
"labels": [
{
"name": "Example",
"color": "#0a7350",
"description": "Short description",
"count": 12
}
],
"colors": [
"#0a7350"
]
}Create a label
/v1/labelsAdds a label to the catalogue so it can be picked in the inbox and in rules. Names are normalised (lowercase, spaces become dashes); an existing label is updated instead.
Request body
namestringrequiredcolorstring#RRGGBB (default: picked from the name)descriptionstring | null
Responses
- 201Created
Response fields
labelobjectrequiredlabel.namestringrequiredNormalised name: lowercase, spaces become dasheslabel.colorstringrequired#RRGGBBlabel.descriptionstring | nullrequiredlabel.countintegerrequiredContacts and group chats that carry it
- 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)
curl -X POST "https://api.chatkomodo.com/v1/labels" \
-H "Authorization: Bearer $CHATKOMODO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Example",
"color": "#0a7350",
"description": "Short description"
}'const res = await fetch('https://api.chatkomodo.com/v1/labels', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.CHATKOMODO_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"name": "Example",
"color": "#0a7350",
"description": "Short description"
}),
});
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/labels",
headers={
"Authorization": f"Bearer {os.environ['CHATKOMODO_API_KEY']}",
},
json={
"name": "Example",
"color": "#0a7350",
"description": "Short description",
},
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/labels', [
'headers' => [
'Authorization' => 'Bearer ' . getenv('CHATKOMODO_API_KEY'),
],
'json' => [
'name' => 'Example',
'color' => '#0a7350',
'description' => 'Short description',
],
]);
print_r(json_decode((string) $res->getBody(), true));package main
import (
"fmt"
"io"
"net/http"
"os"
"strings"
)
func main() {
body := strings.NewReader(`{
"name": "Example",
"color": "#0a7350",
"description": "Short description"
}`)
req, err := http.NewRequest("POST", "https://api.chatkomodo.com/v1/labels", 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))
}{
"label": {
"name": "Example",
"color": "#0a7350",
"description": "Short description",
"count": 12
}
}Rename or recolour a label
/v1/labels/{name}A new name renames the label on every contact, group chat and rule.
Path parameters
namestringrequired
Request body
namestringcolorstringdescriptionstring | null
Responses
- 200Saved
Response fields
labelobjectrequiredlabel.namestringrequiredNormalised name: lowercase, spaces become dasheslabel.colorstringrequired#RRGGBBlabel.descriptionstring | nullrequiredlabel.countintegerrequiredContacts and group chats that carry it
- 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) - 404Label not found, or it belongs to another tenant (
NOT_FOUND) - 409A label with the new name already exists (
CONFLICT)
curl -X PATCH "https://api.chatkomodo.com/v1/labels/NAME" \
-H "Authorization: Bearer $CHATKOMODO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Example",
"color": "#0a7350",
"description": "Short description"
}'const res = await fetch('https://api.chatkomodo.com/v1/labels/NAME', {
method: 'PATCH',
headers: {
Authorization: `Bearer ${process.env.CHATKOMODO_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"name": "Example",
"color": "#0a7350",
"description": "Short description"
}),
});
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/labels/NAME",
headers={
"Authorization": f"Bearer {os.environ['CHATKOMODO_API_KEY']}",
},
json={
"name": "Example",
"color": "#0a7350",
"description": "Short description",
},
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/labels/NAME', [
'headers' => [
'Authorization' => 'Bearer ' . getenv('CHATKOMODO_API_KEY'),
],
'json' => [
'name' => 'Example',
'color' => '#0a7350',
'description' => 'Short description',
],
]);
print_r(json_decode((string) $res->getBody(), true));package main
import (
"fmt"
"io"
"net/http"
"os"
"strings"
)
func main() {
body := strings.NewReader(`{
"name": "Example",
"color": "#0a7350",
"description": "Short description"
}`)
req, err := http.NewRequest("PATCH", "https://api.chatkomodo.com/v1/labels/NAME", 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))
}{
"label": {
"name": "Example",
"color": "#0a7350",
"description": "Short description",
"count": 12
}
}Delete a label
/v1/labels/{name}Removes the label from every contact, group chat and rule.
Path parameters
namestringrequired
Responses
- 200Deleted
Response fields
okbooleanrequiredremoved_fromintegerrequired
- 401Missing, invalid or expired credentials
- 403Forbidden for a customer-service agent login (
Agent access is not allowed for this operation) - 404Label not found, or it belongs to another tenant (
NOT_FOUND)
curl -X DELETE "https://api.chatkomodo.com/v1/labels/NAME" \
-H "Authorization: Bearer $CHATKOMODO_API_KEY"const res = await fetch('https://api.chatkomodo.com/v1/labels/NAME', {
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/labels/NAME",
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/labels/NAME', [
'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/labels/NAME", 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))
}{
"ok": true,
"removed_from": 1
}List automatic labelling rules
/v1/labels/rulesRules add or remove labels and move people to a lead stage by themselves: keyword (an incoming message contains the words), first_message (a new chat), store_event (an order from the connected store), inactive (no message for N days, checked hourly), ai (the AI reads the conversation and decides; at most once every 15 minutes per chat, each check uses 1 AI reply of the plan) and label_added (one of the chosen labels is put on a chat by hand, by a rule, the AI or the store; bulk tagging in the CRM does not start it). Rules can also act: assign the chat to an agent and send up to 5 messages after set delays, cancelled when the customer replies (actions). Rules work on chats with a person. A label someone removed by hand is never put back by a rule.
Responses
- 200Rules
Response fields
rulesarray of objectrequiredrules[].idstringrequiredrules[].namestringrequiredrules[].enabledbooleanrequiredrules[].triggerstringrequiredrules[].configobjectrequiredrules[].config.keywordsarray of stringkeyword: words or phrases, matched at the start of a word (hargaalso findsharganya), accents and case ignoredrules[].config.matchstringkeyword: any (default) or all keywordsrules[].config.eventsarray of stringstore_event: which store eventsrules[].config.daysintegerinactive: days without a message (1–365)rules[].config.instructionstringai: when the rule applies, in plain words, e.g. "the customer asks for a price or wants to order"rules[].config.labelsarray of stringlabel_added: the rule runs when one of these labels is put on a chatrules[].add_labelsarray of stringrequiredrules[].remove_labelsarray of stringrequiredrules[].set_stagestring | nullrequiredLead stage to move the person torules[].session_idsarray of string | nullrequiredOnly these devices (null = all)rules[].actionsobjectrequiredrules[].actions.assignobject | nullAssign the chat to a CS agent; the lead gets that owner when it has nonerules[].actions.assign.agent_idstring | nullrequirednull = the next agent in turn (online first, fewest open chats)rules[].actions.messagesarray of objectMessages to send (a follow-up sequence)rules[].actions.messages[].delay_minutesintegerrequired0 – 43 200 (30 days) after the rule applies; a delayed message that would land outside the send window (the blast sending hours) waits until it opensrules[].actions.messages[].textstringrequiredPersonalisation tokens such as{{first_name|there}}workrules[].actions.stop_on_replybooleanMessages still waiting are cancelled when the customer writes (default true)rules[].actions.once_daysintegerActions run at most once per chat in this many days (1–365, default 30)rules[].fire_countintegerrequiredrules[].last_fired_atinteger | nullrequiredUnix time in milliseconds, or nullrules[].created_atintegerrequiredUnix time in millisecondsrules[].updated_atintegerrequiredUnix time in milliseconds
- 401Missing, invalid or expired credentials
curl "https://api.chatkomodo.com/v1/labels/rules" \
-H "Authorization: Bearer $CHATKOMODO_API_KEY"const res = await fetch('https://api.chatkomodo.com/v1/labels/rules', {
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/labels/rules",
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/labels/rules', [
'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/labels/rules", 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))
}{
"rules": [
{
"id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"name": "Example",
"enabled": true,
"trigger": "keyword",
"config": {
"keywords": [
"price"
],
"match": "any",
"events": [
"order_created"
],
"days": 1,
"instruction": "string",
"labels": [
"string"
]
},
"add_labels": [
"string"
],
"remove_labels": [
"string"
],
"set_stage": "vip",
"session_ids": [
"YOUR_DEVICE_ID"
],
"actions": {
"assign": {
"agent_id": "01JA5V6Q8M2H7G4K9P3T0R1S2X"
},
"messages": [
{
"delay_minutes": null,
"text": null
}
],
"stop_on_reply": true,
"once_days": 1
},
"fire_count": 12,
"last_fired_at": 1767225600000,
"created_at": 1767225600000,
"updated_at": 1767225600000
}
]
}Create a rule
/v1/labels/rulesA rule needs labels to add or remove, a lead stage to set, or an action, and the settings of its trigger (see GET /v1/labels/rules). At most 50 rules per business.
Request body
namestringrequiredenabledbooleantriggerstringrequiredconfigobjectconfig.keywordsarray of stringkeyword: words or phrases, matched at the start of a word (hargaalso findsharganya), accents and case ignoredconfig.matchstringkeyword: any (default) or all keywordsconfig.eventsarray of stringstore_event: which store eventsconfig.daysintegerinactive: days without a message (1–365)config.instructionstringai: when the rule applies, in plain words, e.g. "the customer asks for a price or wants to order"config.labelsarray of stringlabel_added: the rule runs when one of these labels is put on a chatadd_labelsarray of stringremove_labelsarray of stringset_stagestring | nullsession_idsarray of string | nullactionsobject | nullactions.assignobject | nullAssign the chat to a CS agent; the lead gets that owner when it has noneactions.assign.agent_idstring | nullrequirednull = the next agent in turn (online first, fewest open chats)actions.messagesarray of objectMessages to send (a follow-up sequence)actions.messages[].delay_minutesintegerrequired0 – 43 200 (30 days) after the rule applies; a delayed message that would land outside the send window (the blast sending hours) waits until it opensactions.messages[].textstringrequiredPersonalisation tokens such as{{first_name|there}}workactions.stop_on_replybooleanMessages still waiting are cancelled when the customer writes (default true)actions.once_daysintegerActions run at most once per chat in this many days (1–365, default 30)
Responses
- 201Created
Response fields
ruleobjectrequiredrule.idstringrequiredrule.namestringrequiredrule.enabledbooleanrequiredrule.triggerstringrequiredrule.configobjectrequiredrule.config.keywordsarray of stringkeyword: words or phrases, matched at the start of a word (hargaalso findsharganya), accents and case ignoredrule.config.matchstringkeyword: any (default) or all keywordsrule.config.eventsarray of stringstore_event: which store eventsrule.config.daysintegerinactive: days without a message (1–365)rule.config.instructionstringai: when the rule applies, in plain words, e.g. "the customer asks for a price or wants to order"rule.config.labelsarray of stringlabel_added: the rule runs when one of these labels is put on a chatrule.add_labelsarray of stringrequiredrule.remove_labelsarray of stringrequiredrule.set_stagestring | nullrequiredLead stage to move the person torule.session_idsarray of string | nullrequiredOnly these devices (null = all)rule.actionsobjectrequiredrule.actions.assignobject | nullAssign the chat to a CS agent; the lead gets that owner when it has nonerule.actions.assign.agent_idstring | nullrequirednull = the next agent in turn (online first, fewest open chats)rule.actions.messagesarray of objectMessages to send (a follow-up sequence)rule.actions.messages[].delay_minutesintegerrequired0 – 43 200 (30 days) after the rule applies; a delayed message that would land outside the send window (the blast sending hours) waits until it opensrule.actions.messages[].textstringrequiredPersonalisation tokens such as{{first_name|there}}workrule.actions.stop_on_replybooleanMessages still waiting are cancelled when the customer writes (default true)rule.actions.once_daysintegerActions run at most once per chat in this many days (1–365, default 30)rule.fire_countintegerrequiredrule.last_fired_atinteger | nullrequiredUnix time in milliseconds, or nullrule.created_atintegerrequiredUnix time in millisecondsrule.updated_atintegerrequiredUnix time in milliseconds
- 400Invalid rule (
VALIDATION_FAILED) or more than 50 rules (LIMIT_REACHED) - 401Missing, invalid or expired credentials
- 403Forbidden for a customer-service agent login (
Agent access is not allowed for this operation)
curl -X POST "https://api.chatkomodo.com/v1/labels/rules" \
-H "Authorization: Bearer $CHATKOMODO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Example",
"enabled": true,
"trigger": "keyword",
"config": {
"keywords": [
"price"
],
"match": "any",
"events": [
"order_created"
],
"days": 1
}
}'const res = await fetch('https://api.chatkomodo.com/v1/labels/rules', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.CHATKOMODO_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"name": "Example",
"enabled": true,
"trigger": "keyword",
"config": {
"keywords": [
"price"
],
"match": "any",
"events": [
"order_created"
],
"days": 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.post(
"https://api.chatkomodo.com/v1/labels/rules",
headers={
"Authorization": f"Bearer {os.environ['CHATKOMODO_API_KEY']}",
},
json={
"name": "Example",
"enabled": True,
"trigger": "keyword",
"config": {
"keywords": [
"price",
],
"match": "any",
"events": [
"order_created",
],
"days": 1,
},
},
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/labels/rules', [
'headers' => [
'Authorization' => 'Bearer ' . getenv('CHATKOMODO_API_KEY'),
],
'json' => [
'name' => 'Example',
'enabled' => true,
'trigger' => 'keyword',
'config' => [
'keywords' => [
'price',
],
'match' => 'any',
'events' => [
'order_created',
],
'days' => 1,
],
],
]);
print_r(json_decode((string) $res->getBody(), true));package main
import (
"fmt"
"io"
"net/http"
"os"
"strings"
)
func main() {
body := strings.NewReader(`{
"name": "Example",
"enabled": true,
"trigger": "keyword",
"config": {
"keywords": [
"price"
],
"match": "any",
"events": [
"order_created"
],
"days": 1
}
}`)
req, err := http.NewRequest("POST", "https://api.chatkomodo.com/v1/labels/rules", 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))
}{
"rule": {
"id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"name": "Example",
"enabled": true,
"trigger": "keyword",
"config": {
"keywords": [
"price"
],
"match": "any",
"events": [
"order_created"
],
"days": 1,
"instruction": "string",
"labels": [
"string"
]
},
"add_labels": [
"string"
],
"remove_labels": [
"string"
],
"set_stage": "vip",
"session_ids": [
"YOUR_DEVICE_ID"
],
"actions": {
"assign": {
"agent_id": "01JA5V6Q8M2H7G4K9P3T0R1S2X"
},
"messages": [
{
"delay_minutes": 1,
"text": "Hi Sam, your order has shipped."
}
],
"stop_on_reply": true,
"once_days": 1
},
"fire_count": 12,
"last_fired_at": 1767225600000,
"created_at": 1767225600000,
"updated_at": 1767225600000
}
}Change a rule
/v1/labels/rules/{id}Fields left out keep their value. enabled: false pauses the rule.
Path parameters
idstringrequiredRule id
Request body
namestringenabledbooleantriggerstringconfigobjectconfig.keywordsarray of stringkeyword: words or phrases, matched at the start of a word (hargaalso findsharganya), accents and case ignoredconfig.matchstringkeyword: any (default) or all keywordsconfig.eventsarray of stringstore_event: which store eventsconfig.daysintegerinactive: days without a message (1–365)config.instructionstringai: when the rule applies, in plain words, e.g. "the customer asks for a price or wants to order"config.labelsarray of stringlabel_added: the rule runs when one of these labels is put on a chatadd_labelsarray of stringremove_labelsarray of stringset_stagestring | nullsession_idsarray of string | nullactionsobject | nullactions.assignobject | nullAssign the chat to a CS agent; the lead gets that owner when it has noneactions.assign.agent_idstring | nullrequirednull = the next agent in turn (online first, fewest open chats)actions.messagesarray of objectMessages to send (a follow-up sequence)actions.messages[].delay_minutesintegerrequired0 – 43 200 (30 days) after the rule applies; a delayed message that would land outside the send window (the blast sending hours) waits until it opensactions.messages[].textstringrequiredPersonalisation tokens such as{{first_name|there}}workactions.stop_on_replybooleanMessages still waiting are cancelled when the customer writes (default true)actions.once_daysintegerActions run at most once per chat in this many days (1–365, default 30)
Responses
- 200Saved
Response fields
ruleobjectrequiredrule.idstringrequiredrule.namestringrequiredrule.enabledbooleanrequiredrule.triggerstringrequiredrule.configobjectrequiredrule.config.keywordsarray of stringkeyword: words or phrases, matched at the start of a word (hargaalso findsharganya), accents and case ignoredrule.config.matchstringkeyword: any (default) or all keywordsrule.config.eventsarray of stringstore_event: which store eventsrule.config.daysintegerinactive: days without a message (1–365)rule.config.instructionstringai: when the rule applies, in plain words, e.g. "the customer asks for a price or wants to order"rule.config.labelsarray of stringlabel_added: the rule runs when one of these labels is put on a chatrule.add_labelsarray of stringrequiredrule.remove_labelsarray of stringrequiredrule.set_stagestring | nullrequiredLead stage to move the person torule.session_idsarray of string | nullrequiredOnly these devices (null = all)rule.actionsobjectrequiredrule.actions.assignobject | nullAssign the chat to a CS agent; the lead gets that owner when it has nonerule.actions.assign.agent_idstring | nullrequirednull = the next agent in turn (online first, fewest open chats)rule.actions.messagesarray of objectMessages to send (a follow-up sequence)rule.actions.messages[].delay_minutesintegerrequired0 – 43 200 (30 days) after the rule applies; a delayed message that would land outside the send window (the blast sending hours) waits until it opensrule.actions.messages[].textstringrequiredPersonalisation tokens such as{{first_name|there}}workrule.actions.stop_on_replybooleanMessages still waiting are cancelled when the customer writes (default true)rule.actions.once_daysintegerActions run at most once per chat in this many days (1–365, default 30)rule.fire_countintegerrequiredrule.last_fired_atinteger | nullrequiredUnix time in milliseconds, or nullrule.created_atintegerrequiredUnix time in millisecondsrule.updated_atintegerrequiredUnix time in milliseconds
- 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) - 404Rule not found, or it belongs to another tenant (
NOT_FOUND)
curl -X PATCH "https://api.chatkomodo.com/v1/labels/rules/ID" \
-H "Authorization: Bearer $CHATKOMODO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Example",
"enabled": true,
"trigger": "keyword",
"config": {
"keywords": [
"price"
],
"match": "any",
"events": [
"order_created"
],
"days": 1
}
}'const res = await fetch('https://api.chatkomodo.com/v1/labels/rules/ID', {
method: 'PATCH',
headers: {
Authorization: `Bearer ${process.env.CHATKOMODO_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"name": "Example",
"enabled": true,
"trigger": "keyword",
"config": {
"keywords": [
"price"
],
"match": "any",
"events": [
"order_created"
],
"days": 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.patch(
"https://api.chatkomodo.com/v1/labels/rules/ID",
headers={
"Authorization": f"Bearer {os.environ['CHATKOMODO_API_KEY']}",
},
json={
"name": "Example",
"enabled": True,
"trigger": "keyword",
"config": {
"keywords": [
"price",
],
"match": "any",
"events": [
"order_created",
],
"days": 1,
},
},
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/labels/rules/ID', [
'headers' => [
'Authorization' => 'Bearer ' . getenv('CHATKOMODO_API_KEY'),
],
'json' => [
'name' => 'Example',
'enabled' => true,
'trigger' => 'keyword',
'config' => [
'keywords' => [
'price',
],
'match' => 'any',
'events' => [
'order_created',
],
'days' => 1,
],
],
]);
print_r(json_decode((string) $res->getBody(), true));package main
import (
"fmt"
"io"
"net/http"
"os"
"strings"
)
func main() {
body := strings.NewReader(`{
"name": "Example",
"enabled": true,
"trigger": "keyword",
"config": {
"keywords": [
"price"
],
"match": "any",
"events": [
"order_created"
],
"days": 1
}
}`)
req, err := http.NewRequest("PATCH", "https://api.chatkomodo.com/v1/labels/rules/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))
}{
"rule": {
"id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"name": "Example",
"enabled": true,
"trigger": "keyword",
"config": {
"keywords": [
"price"
],
"match": "any",
"events": [
"order_created"
],
"days": 1,
"instruction": "string",
"labels": [
"string"
]
},
"add_labels": [
"string"
],
"remove_labels": [
"string"
],
"set_stage": "vip",
"session_ids": [
"YOUR_DEVICE_ID"
],
"actions": {
"assign": {
"agent_id": "01JA5V6Q8M2H7G4K9P3T0R1S2X"
},
"messages": [
{
"delay_minutes": 1,
"text": "Hi Sam, your order has shipped."
}
],
"stop_on_reply": true,
"once_days": 1
},
"fire_count": 12,
"last_fired_at": 1767225600000,
"created_at": 1767225600000,
"updated_at": 1767225600000
}
}Delete a rule
/v1/labels/rules/{id}Labels the rule already applied stay where they are; its messages still waiting to be sent are cancelled.
Path parameters
idstringrequiredRule 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) - 404Rule not found, or it belongs to another tenant (
NOT_FOUND)
curl -X DELETE "https://api.chatkomodo.com/v1/labels/rules/ID" \
-H "Authorization: Bearer $CHATKOMODO_API_KEY"const res = await fetch('https://api.chatkomodo.com/v1/labels/rules/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/labels/rules/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/labels/rules/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/labels/rules/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))
}{
"ok": true
}The leads board
/v1/leadsPeople in a lead stage (at most 1 000, most recently moved first) with their labels, deal value, owner, follow-up and latest chat, plus the business's stages, lead currency and agents. Filter by label, search q (name or number), owner (me, none or an agent id), due=1 (follow-up overdue or due within 24 hours) or source (a link id: people who first came through that click-to-WhatsApp link).
Query parameters
labelstringqstringownerstringduestringsourcestring
Responses
- 200Board
Response fields
stagesarray of objectrequiredstages[].idstringrequiredstages[].namestringrequiredstages[].colorstringrequiredstages[].kindstringrequiredwon/loststages close a lead (reports)leadsarray of objectrequiredleads[].contact_idstringrequiredleads[].namestring | nullrequiredleads[].phonestringrequiredleads[].stagestring | nullrequiredleads[].labelsarray of objectrequiredleads[].labels[].namestringrequiredleads[].labels[].colorstringrequiredleads[].stage_updated_atinteger | nullrequiredUnix time in milliseconds, or nullleads[].deal_valuenumber | nullrequiredIn the lead currency, major units (49.5 = 49.50)leads[].owner_agent_idstring | nullrequiredleads[].owner_namestring | nullrequiredleads[].follow_up_atinteger | nullrequiredUnix time in milliseconds, or nullleads[].follow_up_notestring | nullrequiredleads[].session_idstring | nullrequiredleads[].chat_idstring | nullrequiredleads[].last_messagestring | nullrequiredleads[].last_message_atinteger | nullrequiredUnix time in milliseconds, or nullleads[].unread_countintegerrequiredleads[].sourceobject | nullThe click-to-WhatsApp link (and campaign tags) the person first came through; null when not through a linkleads[].source.namestringrequiredleads[].source.utm_sourcestring | nullrequiredleads[].source.utm_mediumstring | nullrequiredleads[].source.utm_campaignstring | nullrequiredcurrencystringrequiredagentsarray of objectrequiredagents[].idstringrequiredagents[].namestringrequired
- 401Missing, invalid or expired credentials
curl "https://api.chatkomodo.com/v1/leads" \
-H "Authorization: Bearer $CHATKOMODO_API_KEY"const res = await fetch('https://api.chatkomodo.com/v1/leads', {
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/leads",
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/leads', [
'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/leads", 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))
}{
"stages": [
{
"id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"name": "Example",
"color": "#0a7350",
"kind": "open"
}
],
"leads": [
{
"contact_id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"name": "Example",
"phone": "+447700900123",
"stage": "vip",
"labels": [
{
"name": "Example",
"color": "#0a7350"
}
],
"stage_updated_at": 1767225600000,
"deal_value": 0.5,
"owner_agent_id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"owner_name": "string",
"follow_up_at": 1767225600000,
"follow_up_note": "Prefers delivery after 5 pm",
"session_id": "YOUR_DEVICE_ID",
"chat_id": "+447700900123",
"last_message": "Hi Sam, your order has shipped.",
"last_message_at": 1767225600000,
"unread_count": 12,
"source": {
"name": "Example",
"utm_source": "string",
"utm_medium": "string",
"utm_campaign": "string"
}
}
],
"currency": "IDR",
"agents": [
{
"id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"name": "Example"
}
]
}Weekly summary settings
/v1/leads/weekly-summaryEvery Monday from 08:00 in your time zone, the last 7 days next to the 7 before: messages received, chats from chat links, new leads, deals won and their value, QRIS paid and still unpaid. Off until turned on.
Responses
- 200Settings
Response fields
whatsappbooleanrequiredSend it by WhatsApp to the owner's number (from the platform sender)emailbooleanrequiredSend it to the billing notification emailwhatsapp_tostring | nullrequiredemail_tostring | nullrequiredSet in Billing → NotificationspreviewstringrequiredThis week's summary as it would be sent now
- 401Missing, invalid or expired credentials
curl "https://api.chatkomodo.com/v1/leads/weekly-summary" \
-H "Authorization: Bearer $CHATKOMODO_API_KEY"const res = await fetch('https://api.chatkomodo.com/v1/leads/weekly-summary', {
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/leads/weekly-summary",
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/leads/weekly-summary', [
'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/leads/weekly-summary", 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))
}{
"whatsapp": true,
"email": true,
"whatsapp_to": "string",
"email_to": "you@example.com",
"preview": "string"
}Turn the weekly summary on or off
/v1/leads/weekly-summaryDashboard loginSend only what changes. Business owner only. Recorded as reports.weekly_summary.
Request body
whatsappbooleanemailboolean
Responses
- 200Settings
Response fields
whatsappbooleanrequiredSend it by WhatsApp to the owner's number (from the platform sender)emailbooleanrequiredSend it to the billing notification emailwhatsapp_tostring | nullrequiredemail_tostring | nullrequiredSet in Billing → NotificationspreviewstringrequiredThis week's summary as it would be sent now
- 400
VALIDATION_FAILED - 401Missing, invalid or expired credentials
- 403Forbidden for a customer-service agent login (
Agent access is not allowed for this operation)
curl -X PUT "https://api.chatkomodo.com/v1/leads/weekly-summary" \
-H "Authorization: Bearer $CHATKOMODO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"whatsapp": true,
"email": true
}'const res = await fetch('https://api.chatkomodo.com/v1/leads/weekly-summary', {
method: 'PUT',
headers: {
Authorization: `Bearer ${process.env.CHATKOMODO_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"whatsapp": true,
"email": true
}),
});
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/leads/weekly-summary",
headers={
"Authorization": f"Bearer {os.environ['CHATKOMODO_API_KEY']}",
},
json={
"whatsapp": True,
"email": True,
},
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/leads/weekly-summary', [
'headers' => [
'Authorization' => 'Bearer ' . getenv('CHATKOMODO_API_KEY'),
],
'json' => [
'whatsapp' => true,
'email' => true,
],
]);
print_r(json_decode((string) $res->getBody(), true));package main
import (
"fmt"
"io"
"net/http"
"os"
"strings"
)
func main() {
body := strings.NewReader(`{
"whatsapp": true,
"email": true
}`)
req, err := http.NewRequest("PUT", "https://api.chatkomodo.com/v1/leads/weekly-summary", 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))
}{
"whatsapp": true,
"email": true,
"whatsapp_to": "string",
"email_to": "you@example.com",
"preview": "string"
}Send the weekly summary now (test)
/v1/leads/weekly-summary/testSends this week's summary at once through the channels that are on. At most once every 10 minutes.
Responses
- 200Sent
Response fields
sentobjectrequiredsent.whatsappbooleanrequiredsent.emailbooleanrequired
- 401Missing, invalid or expired credentials
- 403Forbidden for a customer-service agent login (
Agent access is not allowed for this operation) - 429
RATE_LIMITED
curl -X POST "https://api.chatkomodo.com/v1/leads/weekly-summary/test" \
-H "Authorization: Bearer $CHATKOMODO_API_KEY"const res = await fetch('https://api.chatkomodo.com/v1/leads/weekly-summary/test', {
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/leads/weekly-summary/test",
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/leads/weekly-summary/test', [
'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/leads/weekly-summary/test", 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))
}{
"sent": {
"whatsapp": true,
"email": true
}
}Leads report
/v1/leads/reportFor the last days (7, 30, 90 or 365): leads that came on the board, won and lost (still in a won / lost stage), win rate, conversion of new leads, average days to win, value won and open, how far new leads got through the stages, a daily (weekly for 365) series, labels added (by hand, rule, AI, store), the rules at work, per agent: open leads, won, value won and overdue follow-ups, per click-to-WhatsApp link: chats, new leads and won, and QRIS invoices paid.
Query parameters
daysstring
Responses
- 200Report
Response fields
daysintegerrequiredsinceintegerrequiredUnix time in millisecondscurrencystringrequiredstagesarray of objectrequiredstages[].idstringrequiredstages[].namestringrequiredstages[].colorstringrequiredstages[].kindstringrequiredwon/loststages close a lead (reports)stages[].countintegerrequiredstages[].valuenumberrequiredtotalsobjectrequiredtotals.new_leadsintegerrequiredtotals.wonintegerrequiredtotals.lostintegerrequiredtotals.win_ratenumber | nullrequiredtotals.conversionnumber | nullrequiredtotals.avg_days_to_winnumber | nullrequiredtotals.won_valuenumberrequiredtotals.open_valuenumberrequiredtotals.follow_ups_dueintegerrequiredtotals.follow_ups_overdueintegerrequiredfunnelarray of objectrequiredfunnel[].idstringrequiredfunnel[].namestringrequiredfunnel[].colorstringrequiredfunnel[].reachedintegerrequiredfunnel[].ratenumber | nullrequiredShare of the previous stageseriesarray of objectrequiredseries[].datestringrequiredseries[].newintegerrequiredseries[].wonintegerrequiredlabelsarray of objectrequiredlabels[].namestringrequiredlabels[].colorstringrequiredlabels[].totalintegerrequiredlabels[].manualintegerrequiredlabels[].ruleintegerrequiredlabels[].aiintegerrequiredlabels[].storeintegerrequiredrulesarray of objectrequiredrules[].idstringrequiredrules[].namestringrequiredrules[].chatsintegerrequiredagentsarray of objectrequiredagents[].idstring | nullrequirednull = leads without an owneragents[].namestring | nullrequiredagents[].openintegerrequiredagents[].wonintegerrequiredagents[].won_valuenumberrequiredagents[].overdueintegerrequiredsourcesarray of objectrequiredPer click-to-WhatsApp link: chats in the period, new leads that first came through it, of them won, and their valuesources[].idstringrequiredsources[].namestringrequiredsources[].chatsintegerrequiredsources[].leadsintegerrequiredsources[].wonintegerrequiredsources[].won_valuenumberrequiredpaymentsobjectrequiredQRIS invoices paid in the period (sandbox excluded)payments.paidintegerrequiredpayments.amountintegerrequiredRupiah
- 401Missing, invalid or expired credentials
curl "https://api.chatkomodo.com/v1/leads/report" \
-H "Authorization: Bearer $CHATKOMODO_API_KEY"const res = await fetch('https://api.chatkomodo.com/v1/leads/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/leads/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/leads/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/leads/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))
}{
"days": 1,
"since": 1767225600000,
"currency": "IDR",
"stages": [
{
"id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"name": "Example",
"color": "#0a7350",
"kind": "open",
"count": 12,
"value": 0.5
}
],
"totals": {
"new_leads": 1,
"won": 1,
"lost": 1,
"win_rate": 0.5,
"conversion": 0.5,
"avg_days_to_win": 0.5,
"won_value": 0.5,
"open_value": 0.5,
"follow_ups_due": 1,
"follow_ups_overdue": 1
},
"funnel": [
{
"id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"name": "Example",
"color": "#0a7350",
"reached": 1,
"rate": 0.5
}
],
"series": [
{
"date": "string",
"new": 1,
"won": 1
}
],
"labels": [
{
"name": "Example",
"color": "#0a7350",
"total": 12,
"manual": 1,
"rule": 1,
"ai": 1,
"store": 1
}
],
"rules": [
{
"id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"name": "Example",
"chats": 1
}
],
"agents": [
{
"id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"name": "Example",
"open": 1,
"won": 1,
"won_value": 0.5,
"overdue": 1
}
],
"sources": [
{
"id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"name": "Example",
"chats": 1,
"leads": 1,
"won": 1,
"won_value": 0.5
}
],
"payments": {
"paid": 1,
"amount": 150000
}
}Export the leads board (CSV)
/v1/leads/exportThe board as a CSV file (UTF-8 with BOM, at most 20 000 rows), with the same filters as GET /v1/leads. Columns: name, phone, stage, stage_id, deal_value, currency, owner, follow_up, follow_up_note, labels, stage_since, created — the import reads the same columns. Cells a spreadsheet would run as a formula start with an apostrophe.
Query parameters
labelstringqstringownerstringduestring
Responses
- 200CSV file
- 401Missing, invalid or expired credentials
- 403Forbidden for a customer-service agent login (
Agent access is not allowed for this operation)
curl "https://api.chatkomodo.com/v1/leads/export" \
-H "Authorization: Bearer $CHATKOMODO_API_KEY"const res = await fetch('https://api.chatkomodo.com/v1/leads/export', {
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/leads/export",
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/leads/export', [
'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/leads/export", 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))
}text/csv — the file itself.
Import leads
/v1/leads/importPuts people on the leads board, at most 2 000 rows per call. Each row: phone (required; local numbers use your country), name, stage (id or name; empty = default_stage or the first stage), deal_value ("1.500.000", "49,90" and "49.90" are understood), labels (comma separated or a list; added to the ones the person has), owner (agent name or id), follow_up (a date or date-time), follow_up_note, note (a team note). People are matched by number. Importing does not start "a label is added" rules, so no messages go out; label and lead webhooks do fire.
Request body
rowsarray of objectrequiredrows[].phonestring | numberrequiredrows[].namestringrows[].stagestringrows[].deal_valuestring | numberrows[].labelsstring | array of stringrows[].ownerstringrows[].follow_upstringrows[].follow_up_notestringrows[].notestringdefault_stagestring | null
Responses
- 200Imported
Response fields
createdintegerrequiredupdatedintegerrequiredfailedarray of objectrequiredfailed[].rowintegerrequired1-basedfailed[].errorstringrequired
- 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)
curl -X POST "https://api.chatkomodo.com/v1/leads/import" \
-H "Authorization: Bearer $CHATKOMODO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"rows": [
{
"phone": "+447700900123",
"name": "Example",
"stage": "vip"
}
],
"default_stage": "vip"
}'const res = await fetch('https://api.chatkomodo.com/v1/leads/import', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.CHATKOMODO_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"rows": [
{
"phone": "+447700900123",
"name": "Example",
"stage": "vip"
}
],
"default_stage": "vip"
}),
});
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/leads/import",
headers={
"Authorization": f"Bearer {os.environ['CHATKOMODO_API_KEY']}",
},
json={
"rows": [
{
"phone": "+447700900123",
"name": "Example",
"stage": "vip",
},
],
"default_stage": "vip",
},
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/leads/import', [
'headers' => [
'Authorization' => 'Bearer ' . getenv('CHATKOMODO_API_KEY'),
],
'json' => [
'rows' => [
[
'phone' => '+447700900123',
'name' => 'Example',
'stage' => 'vip',
],
],
'default_stage' => 'vip',
],
]);
print_r(json_decode((string) $res->getBody(), true));package main
import (
"fmt"
"io"
"net/http"
"os"
"strings"
)
func main() {
body := strings.NewReader(`{
"rows": [
{
"phone": "+447700900123",
"name": "Example",
"stage": "vip"
}
],
"default_stage": "vip"
}`)
req, err := http.NewRequest("POST", "https://api.chatkomodo.com/v1/leads/import", 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))
}{
"created": 1,
"updated": 1,
"failed": [
{
"row": 1,
"error": "string"
}
]
}Set the lead currency
/v1/leads/settingsThe currency of deal values. Values already entered keep their amount.
Request body
currencystringrequired
Responses
- 200Saved
Response fields
currencystringrequired
- 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)
curl -X PUT "https://api.chatkomodo.com/v1/leads/settings" \
-H "Authorization: Bearer $CHATKOMODO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"currency": "IDR"
}'const res = await fetch('https://api.chatkomodo.com/v1/leads/settings', {
method: 'PUT',
headers: {
Authorization: `Bearer ${process.env.CHATKOMODO_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"currency": "IDR"
}),
});
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/leads/settings",
headers={
"Authorization": f"Bearer {os.environ['CHATKOMODO_API_KEY']}",
},
json={
"currency": "IDR",
},
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/leads/settings', [
'headers' => [
'Authorization' => 'Bearer ' . getenv('CHATKOMODO_API_KEY'),
],
'json' => [
'currency' => 'IDR',
],
]);
print_r(json_decode((string) $res->getBody(), true));package main
import (
"fmt"
"io"
"net/http"
"os"
"strings"
)
func main() {
body := strings.NewReader(`{
"currency": "IDR"
}`)
req, err := http.NewRequest("PUT", "https://api.chatkomodo.com/v1/leads/settings", 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))
}{
"currency": "IDR"
}Set the lead stages
/v1/leads/stages1–12 stages in board order, each open, won or lost (for reports). People in a stage that is removed move to the first stage; rules that set it stop setting a stage.
Request body
stagesarray of objectrequiredstages[].idstringKept when renaming; default: from the namestages[].namestringrequiredstages[].colorstringstages[].kindstring
Responses
- 200Saved
Response fields
stagesarray of objectrequiredstages[].idstringrequiredstages[].namestringrequiredstages[].colorstringrequiredstages[].kindstringrequiredwon/loststages close a lead (reports)
- 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)
curl -X PUT "https://api.chatkomodo.com/v1/leads/stages" \
-H "Authorization: Bearer $CHATKOMODO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"stages": [
{
"id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"name": "Example",
"color": "#0a7350"
}
]
}'const res = await fetch('https://api.chatkomodo.com/v1/leads/stages', {
method: 'PUT',
headers: {
Authorization: `Bearer ${process.env.CHATKOMODO_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"stages": [
{
"id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"name": "Example",
"color": "#0a7350"
}
]
}),
});
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/leads/stages",
headers={
"Authorization": f"Bearer {os.environ['CHATKOMODO_API_KEY']}",
},
json={
"stages": [
{
"id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"name": "Example",
"color": "#0a7350",
},
],
},
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/leads/stages', [
'headers' => [
'Authorization' => 'Bearer ' . getenv('CHATKOMODO_API_KEY'),
],
'json' => [
'stages' => [
[
'id' => '01JA5V6Q8M2H7G4K9P3T0R1S2X',
'name' => 'Example',
'color' => '#0a7350',
],
],
],
]);
print_r(json_decode((string) $res->getBody(), true));package main
import (
"fmt"
"io"
"net/http"
"os"
"strings"
)
func main() {
body := strings.NewReader(`{
"stages": [
{
"id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"name": "Example",
"color": "#0a7350"
}
]
}`)
req, err := http.NewRequest("PUT", "https://api.chatkomodo.com/v1/leads/stages", 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))
}{
"stages": [
{
"id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"name": "Example",
"color": "#0a7350",
"kind": "open"
}
]
}A lead with notes and history
/v1/leads/{contactId}The lead, its notes (newest first) and the latest 30 changes of its labels, stage, value, owner and follow-up.
Path parameters
contactIdstringrequired
Responses
- 200Lead
Response fields
leadobjectrequiredlead.contact_idstringrequiredlead.namestring | nullrequiredlead.phonestringrequiredlead.stagestring | nullrequiredlead.labelsarray of objectrequiredlead.labels[].namestringrequiredlead.labels[].colorstringrequiredlead.stage_updated_atinteger | nullrequiredUnix time in milliseconds, or nulllead.deal_valuenumber | nullrequiredIn the lead currency, major units (49.5 = 49.50)lead.owner_agent_idstring | nullrequiredlead.owner_namestring | nullrequiredlead.follow_up_atinteger | nullrequiredUnix time in milliseconds, or nulllead.follow_up_notestring | nullrequiredlead.session_idstring | nullrequiredlead.chat_idstring | nullrequiredlead.last_messagestring | nullrequiredlead.last_message_atinteger | nullrequiredUnix time in milliseconds, or nulllead.unread_countintegerrequiredlead.sourceobject | nullThe click-to-WhatsApp link (and campaign tags) the person first came through; null when not through a linklead.source.namestringrequiredlead.source.utm_sourcestring | nullrequiredlead.source.utm_mediumstring | nullrequiredlead.source.utm_campaignstring | nullrequirednotesarray of objectrequirednotes[].idstringrequirednotes[].bodystringrequirednotes[].actorstring | nullrequirednotes[].created_atintegerrequiredUnix time in millisecondshistoryarray of objectrequiredhistory[].labelstringrequiredThe label, or the new stage / value / owner id / follow-up timehistory[].actionstringrequiredhistory[].sourcestringrequiredlink: a click-to-WhatsApp link (rule_idis the link,rule_nameits name);payment: a paid QRIS invoice (rule_idis the invoice)history[].rule_idstring | nullrequiredhistory[].rule_namestring | nullrequiredhistory[].actorstring | nullrequiredhistory[].atintegerrequiredUnix time in millisecondscurrencystringrequiredstagesarray of objectrequiredstages[].idstringrequiredstages[].namestringrequiredstages[].colorstringrequiredstages[].kindstringrequiredwon/loststages close a lead (reports)agentsarray of objectrequiredagents[].idstringrequiredagents[].namestringrequiredoutcomeobject | nullrequiredLatest loss of this lead (null: never lost)outcome.activebooleanrequiredStill lost (false after the lead moved back to an open stage)outcome.lost_atintegerrequiredUnix time in millisecondsoutcome.stagestring | nullrequiredoutcome.deal_valuenumber | nullrequiredWhen it was lost, lead currencyoutcome.reasonstring | nullrequiredThe reason the team gaveoutcome.notestring | nullrequiredoutcome.reason_bystring | nullrequiredoutcome.reason_atinteger | nullrequiredUnix time in milliseconds, or nulloutcome.guessobject | nullrequiredA suggestion until someone confirms a reasonoutcome.guess.reasonstringrequiredoutcome.guess.bystring | nullrequiredoutcome.guess.confidencenumber | nullrequiredoutcome.guess.evidencestring | nullrequiredWhat the customer wrote that points to itoutcome.summarystring | nullrequiredAI: why the customer did not buyoutcome.reviewstring | nullrequiredAI: how the business answeredoutcome.analysisobjectrequiredoutcome.analysis.statusstringrequiredoutcome.analysis.errorstring | nullrequiredoutcome.analysis.atinteger | nullrequiredUnix time in milliseconds, or nullreviewobject | nullrequiredHow the chat was handled over the last 30 days (up to the loss for a lost lead)review.messagesobjectrequiredreview.messages.from_customerintegerrequiredreview.messages.aiintegerrequiredreview.messages.automaticintegerrequiredreview.messages.teamintegerrequiredreview.aiobjectrequiredreview.ai.repliesintegerrequiredreview.ai.unsureintegerrequiredReplies where the AI did not knowreview.ai.handoffsintegerrequiredreview.ai.unansweredarray of objectrequiredreview.ai.unanswered[].questionstringrequiredreview.ai.unanswered[].countintegerrequiredreview.ai.unanswered[].statusstringrequiredreview.waitobjectrequiredreview.wait.median_minnumber | nullrequiredreview.wait.longest_minnumber | nullrequiredreview.wait.unansweredintegerrequiredCustomer messages never answeredreview.lastobject | nullrequiredreview.last.fromstringrequiredreview.last.atintegerrequiredUnix time in millisecondsreview.flagsarray of stringrequiredlost_reasonsarray of stringrequired
- 401Missing, invalid or expired credentials
- 404Contact not found, or it belongs to another tenant (
NOT_FOUND)
curl "https://api.chatkomodo.com/v1/leads/CONTACT_ID" \
-H "Authorization: Bearer $CHATKOMODO_API_KEY"const res = await fetch('https://api.chatkomodo.com/v1/leads/CONTACT_ID', {
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/leads/CONTACT_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('GET', 'https://api.chatkomodo.com/v1/leads/CONTACT_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("GET", "https://api.chatkomodo.com/v1/leads/CONTACT_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))
}{
"lead": {
"contact_id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"name": "Example",
"phone": "+447700900123",
"stage": "vip",
"labels": [
{
"name": "Example",
"color": "#0a7350"
}
],
"stage_updated_at": 1767225600000,
"deal_value": 0.5,
"owner_agent_id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"owner_name": "string",
"follow_up_at": 1767225600000,
"follow_up_note": "Prefers delivery after 5 pm",
"session_id": "YOUR_DEVICE_ID",
"chat_id": "+447700900123",
"last_message": "Hi Sam, your order has shipped.",
"last_message_at": 1767225600000,
"unread_count": 12,
"source": {
"name": "Example",
"utm_source": "string",
"utm_medium": "string",
"utm_campaign": "string"
}
},
"notes": [
{
"id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"body": "Hi Sam, your order has shipped.",
"actor": "string",
"created_at": 1767225600000
}
],
"history": [
{
"label": "string",
"action": "add",
"source": "manual",
"rule_id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"rule_name": "string",
"actor": "string",
"at": 1767225600000
}
],
"currency": "IDR",
"stages": [
{
"id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"name": "Example",
"color": "#0a7350",
"kind": "open"
}
],
"agents": [
{
"id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"name": "Example"
}
],
"outcome": {
"active": true,
"lost_at": 1767225600000,
"stage": "vip",
"deal_value": 0.5,
"reason": "price",
"note": "Prefers delivery after 5 pm",
"reason_by": "string",
"reason_at": 1767225600000,
"guess": {
"reason": "string",
"by": "ai",
"confidence": 0.5,
"evidence": "string"
},
"summary": "string",
"review": "string",
"analysis": {
"status": "none",
"error": "string",
"at": 1767225600000
}
},
"review": {
"messages": {
"from_customer": 1,
"ai": 1,
"automatic": 1,
"team": 1
},
"ai": {
"replies": 1,
"unsure": 1,
"handoffs": 1,
"unanswered": [
{
"question": "Do you deliver on Sunday?",
"count": 12,
"status": "active"
}
]
},
"wait": {
"median_min": 0.5,
"longest_min": 0.5,
"unanswered": 1
},
"last": {
"from": "customer",
"at": 1767225600000
},
"flags": [
"slow_first_reply"
]
},
"lost_reasons": [
"price"
]
}Change a lead
/v1/leads/{contactId}Any of: stage (null takes the person off the board), deal_value (lead currency, major units), owner_agent_id, follow_up_at (ms; the owner — or the business owner when nobody owns the lead — gets a notification when it is due) and follow_up_note. Agents can take a lead nobody owns or let go of their own; only the business owner gives a lead to another agent.
Path parameters
contactIdstringrequired
Request body
stagestring | nulldeal_valuenumber | nullowner_agent_idstring | nullfollow_up_atinteger | nullfollow_up_notestring | nulllost_reasonstring | nullWhy it was lost; used when the lead is (or moves) in a lost stagelost_notestring | null
Responses
- 200Saved
Response fields
leadobjectrequiredlead.contact_idstringrequiredlead.namestring | nullrequiredlead.phonestringrequiredlead.stagestring | nullrequiredlead.labelsarray of objectrequiredlead.labels[].namestringrequiredlead.labels[].colorstringrequiredlead.stage_updated_atinteger | nullrequiredUnix time in milliseconds, or nulllead.deal_valuenumber | nullrequiredIn the lead currency, major units (49.5 = 49.50)lead.owner_agent_idstring | nullrequiredlead.owner_namestring | nullrequiredlead.follow_up_atinteger | nullrequiredUnix time in milliseconds, or nulllead.follow_up_notestring | nullrequiredlead.session_idstring | nullrequiredlead.chat_idstring | nullrequiredlead.last_messagestring | nullrequiredlead.last_message_atinteger | nullrequiredUnix time in milliseconds, or nulllead.unread_countintegerrequiredlead.sourceobject | nullThe click-to-WhatsApp link (and campaign tags) the person first came through; null when not through a linklead.source.namestringrequiredlead.source.utm_sourcestring | nullrequiredlead.source.utm_mediumstring | nullrequiredlead.source.utm_campaignstring | nullrequirednotesarray of objectrequirednotes[].idstringrequirednotes[].bodystringrequirednotes[].actorstring | nullrequirednotes[].created_atintegerrequiredUnix time in millisecondshistoryarray of objectrequiredhistory[].labelstringrequiredThe label, or the new stage / value / owner id / follow-up timehistory[].actionstringrequiredhistory[].sourcestringrequiredlink: a click-to-WhatsApp link (rule_idis the link,rule_nameits name);payment: a paid QRIS invoice (rule_idis the invoice)history[].rule_idstring | nullrequiredhistory[].rule_namestring | nullrequiredhistory[].actorstring | nullrequiredhistory[].atintegerrequiredUnix time in millisecondscurrencystringrequiredstagesarray of objectrequiredstages[].idstringrequiredstages[].namestringrequiredstages[].colorstringrequiredstages[].kindstringrequiredwon/loststages close a lead (reports)agentsarray of objectrequiredagents[].idstringrequiredagents[].namestringrequiredoutcomeobject | nullrequiredLatest loss of this lead (null: never lost)outcome.activebooleanrequiredStill lost (false after the lead moved back to an open stage)outcome.lost_atintegerrequiredUnix time in millisecondsoutcome.stagestring | nullrequiredoutcome.deal_valuenumber | nullrequiredWhen it was lost, lead currencyoutcome.reasonstring | nullrequiredThe reason the team gaveoutcome.notestring | nullrequiredoutcome.reason_bystring | nullrequiredoutcome.reason_atinteger | nullrequiredUnix time in milliseconds, or nulloutcome.guessobject | nullrequiredA suggestion until someone confirms a reasonoutcome.guess.reasonstringrequiredoutcome.guess.bystring | nullrequiredoutcome.guess.confidencenumber | nullrequiredoutcome.guess.evidencestring | nullrequiredWhat the customer wrote that points to itoutcome.summarystring | nullrequiredAI: why the customer did not buyoutcome.reviewstring | nullrequiredAI: how the business answeredoutcome.analysisobjectrequiredoutcome.analysis.statusstringrequiredoutcome.analysis.errorstring | nullrequiredoutcome.analysis.atinteger | nullrequiredUnix time in milliseconds, or nullreviewobject | nullrequiredHow the chat was handled over the last 30 days (up to the loss for a lost lead)review.messagesobjectrequiredreview.messages.from_customerintegerrequiredreview.messages.aiintegerrequiredreview.messages.automaticintegerrequiredreview.messages.teamintegerrequiredreview.aiobjectrequiredreview.ai.repliesintegerrequiredreview.ai.unsureintegerrequiredReplies where the AI did not knowreview.ai.handoffsintegerrequiredreview.ai.unansweredarray of objectrequiredreview.ai.unanswered[].questionstringrequiredreview.ai.unanswered[].countintegerrequiredreview.ai.unanswered[].statusstringrequiredreview.waitobjectrequiredreview.wait.median_minnumber | nullrequiredreview.wait.longest_minnumber | nullrequiredreview.wait.unansweredintegerrequiredCustomer messages never answeredreview.lastobject | nullrequiredreview.last.fromstringrequiredreview.last.atintegerrequiredUnix time in millisecondsreview.flagsarray of stringrequiredlost_reasonsarray of stringrequiredokbooleanrequired
- 400Unknown stage or agent, invalid amount or date (
VALIDATION_FAILED) - 401Missing, invalid or expired credentials
- 403An agent giving a lead to someone else (
FORBIDDEN) - 404Contact not found, or it belongs to another tenant (
NOT_FOUND)
curl -X PATCH "https://api.chatkomodo.com/v1/leads/CONTACT_ID" \
-H "Authorization: Bearer $CHATKOMODO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"stage": "vip",
"deal_value": 0.5,
"owner_agent_id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"follow_up_at": 1767225600000
}'const res = await fetch('https://api.chatkomodo.com/v1/leads/CONTACT_ID', {
method: 'PATCH',
headers: {
Authorization: `Bearer ${process.env.CHATKOMODO_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"stage": "vip",
"deal_value": 0.5,
"owner_agent_id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"follow_up_at": 1767225600000
}),
});
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/leads/CONTACT_ID",
headers={
"Authorization": f"Bearer {os.environ['CHATKOMODO_API_KEY']}",
},
json={
"stage": "vip",
"deal_value": 0.5,
"owner_agent_id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"follow_up_at": 1767225600000,
},
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/leads/CONTACT_ID', [
'headers' => [
'Authorization' => 'Bearer ' . getenv('CHATKOMODO_API_KEY'),
],
'json' => [
'stage' => 'vip',
'deal_value' => 0.5,
'owner_agent_id' => '01JA5V6Q8M2H7G4K9P3T0R1S2X',
'follow_up_at' => 1767225600000,
],
]);
print_r(json_decode((string) $res->getBody(), true));package main
import (
"fmt"
"io"
"net/http"
"os"
"strings"
)
func main() {
body := strings.NewReader(`{
"stage": "vip",
"deal_value": 0.5,
"owner_agent_id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"follow_up_at": 1767225600000
}`)
req, err := http.NewRequest("PATCH", "https://api.chatkomodo.com/v1/leads/CONTACT_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))
}{
"lead": {
"contact_id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"name": "Example",
"phone": "+447700900123",
"stage": "vip",
"labels": [
{
"name": "Example",
"color": "#0a7350"
}
],
"stage_updated_at": 1767225600000,
"deal_value": 0.5,
"owner_agent_id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"owner_name": "string",
"follow_up_at": 1767225600000,
"follow_up_note": "Prefers delivery after 5 pm",
"session_id": "YOUR_DEVICE_ID",
"chat_id": "+447700900123",
"last_message": "Hi Sam, your order has shipped.",
"last_message_at": 1767225600000,
"unread_count": 12,
"source": {
"name": "Example",
"utm_source": "string",
"utm_medium": "string",
"utm_campaign": "string"
}
},
"notes": [
{
"id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"body": "Hi Sam, your order has shipped.",
"actor": "string",
"created_at": 1767225600000
}
],
"history": [
{
"label": "string",
"action": "add",
"source": "manual",
"rule_id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"rule_name": "string",
"actor": "string",
"at": 1767225600000
}
],
"currency": "IDR",
"stages": [
{
"id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"name": "Example",
"color": "#0a7350",
"kind": "open"
}
],
"agents": [
{
"id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"name": "Example"
}
],
"outcome": {
"active": true,
"lost_at": 1767225600000,
"stage": "vip",
"deal_value": 0.5,
"reason": "price",
"note": "Prefers delivery after 5 pm",
"reason_by": "string",
"reason_at": 1767225600000,
"guess": {
"reason": "string",
"by": "ai",
"confidence": 0.5,
"evidence": "string"
},
"summary": "string",
"review": "string",
"analysis": {
"status": "none",
"error": "string",
"at": 1767225600000
}
},
"review": {
"messages": {
"from_customer": 1,
"ai": 1,
"automatic": 1,
"team": 1
},
"ai": {
"replies": 1,
"unsure": 1,
"handoffs": 1,
"unanswered": [
{
"question": "Do you deliver on Sunday?",
"count": 12,
"status": "active"
}
]
},
"wait": {
"median_min": 0.5,
"longest_min": 0.5,
"unanswered": 1
},
"last": {
"from": "customer",
"at": 1767225600000
},
"flags": [
"slow_first_reply"
]
},
"lost_reasons": [
"price"
],
"ok": true
}Add a note to a lead
/v1/leads/{contactId}/notesA note for the team (not sent to the customer).
Path parameters
contactIdstringrequired
Request body
bodystringrequired
Responses
- 201Added
Response fields
noteobjectrequirednote.idstringrequirednote.bodystringrequirednote.actorstring | nullrequirednote.created_atintegerrequiredUnix time in milliseconds
- 400Body is not valid JSON (
INVALID_JSON) or fails validation (VALIDATION_FAILED) - 401Missing, invalid or expired credentials
- 404Contact not found, or it belongs to another tenant (
NOT_FOUND)
curl -X POST "https://api.chatkomodo.com/v1/leads/CONTACT_ID/notes" \
-H "Authorization: Bearer $CHATKOMODO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"body": "Hi Sam, your order has shipped."
}'const res = await fetch('https://api.chatkomodo.com/v1/leads/CONTACT_ID/notes', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.CHATKOMODO_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"body": "Hi Sam, your order has shipped."
}),
});
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/leads/CONTACT_ID/notes",
headers={
"Authorization": f"Bearer {os.environ['CHATKOMODO_API_KEY']}",
},
json={
"body": "Hi Sam, your order has shipped.",
},
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/leads/CONTACT_ID/notes', [
'headers' => [
'Authorization' => 'Bearer ' . getenv('CHATKOMODO_API_KEY'),
],
'json' => [
'body' => 'Hi Sam, your order has shipped.',
],
]);
print_r(json_decode((string) $res->getBody(), true));package main
import (
"fmt"
"io"
"net/http"
"os"
"strings"
)
func main() {
body := strings.NewReader(`{
"body": "Hi Sam, your order has shipped."
}`)
req, err := http.NewRequest("POST", "https://api.chatkomodo.com/v1/leads/CONTACT_ID/notes", 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))
}{
"note": {
"id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"body": "Hi Sam, your order has shipped.",
"actor": "string",
"created_at": 1767225600000
}
}Delete a note
/v1/leads/{contactId}/notes/{noteId}Agents can delete only their own notes.
Path parameters
contactIdstringrequirednoteIdstringrequired
Responses
- 200Deleted
Response fields
okbooleanrequired
- 401Missing, invalid or expired credentials
- 403Someone else's note (
FORBIDDEN) - 404Note not found, or it belongs to another tenant (
NOT_FOUND)
curl -X DELETE "https://api.chatkomodo.com/v1/leads/CONTACT_ID/notes/NOTE_ID" \
-H "Authorization: Bearer $CHATKOMODO_API_KEY"const res = await fetch('https://api.chatkomodo.com/v1/leads/CONTACT_ID/notes/NOTE_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/leads/CONTACT_ID/notes/NOTE_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/leads/CONTACT_ID/notes/NOTE_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/leads/CONTACT_ID/notes/NOTE_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))
}{
"ok": true
}Say why a lead was lost
/v1/leads/{contactId}/lost-reasonFor a lead in a lost stage: the reason (price, not_now, competitor, no_reply, product, shipping, trust, slow_reply, other; null clears it) and an optional note. Sends lead.updated with changes.lost_reason. A lead lost before reasons existed gets its outcome now.
Path parameters
contactIdstringrequired
Request body
reasonstring | nullrequirednotestring | null
Responses
- 200Lead
Response fields
leadobjectrequiredlead.contact_idstringrequiredlead.namestring | nullrequiredlead.phonestringrequiredlead.stagestring | nullrequiredlead.labelsarray of objectrequiredlead.labels[].namestringrequiredlead.labels[].colorstringrequiredlead.stage_updated_atinteger | nullrequiredUnix time in milliseconds, or nulllead.deal_valuenumber | nullrequiredIn the lead currency, major units (49.5 = 49.50)lead.owner_agent_idstring | nullrequiredlead.owner_namestring | nullrequiredlead.follow_up_atinteger | nullrequiredUnix time in milliseconds, or nulllead.follow_up_notestring | nullrequiredlead.session_idstring | nullrequiredlead.chat_idstring | nullrequiredlead.last_messagestring | nullrequiredlead.last_message_atinteger | nullrequiredUnix time in milliseconds, or nulllead.unread_countintegerrequiredlead.sourceobject | nullThe click-to-WhatsApp link (and campaign tags) the person first came through; null when not through a linklead.source.namestringrequiredlead.source.utm_sourcestring | nullrequiredlead.source.utm_mediumstring | nullrequiredlead.source.utm_campaignstring | nullrequirednotesarray of objectrequirednotes[].idstringrequirednotes[].bodystringrequirednotes[].actorstring | nullrequirednotes[].created_atintegerrequiredUnix time in millisecondshistoryarray of objectrequiredhistory[].labelstringrequiredThe label, or the new stage / value / owner id / follow-up timehistory[].actionstringrequiredhistory[].sourcestringrequiredlink: a click-to-WhatsApp link (rule_idis the link,rule_nameits name);payment: a paid QRIS invoice (rule_idis the invoice)history[].rule_idstring | nullrequiredhistory[].rule_namestring | nullrequiredhistory[].actorstring | nullrequiredhistory[].atintegerrequiredUnix time in millisecondscurrencystringrequiredstagesarray of objectrequiredstages[].idstringrequiredstages[].namestringrequiredstages[].colorstringrequiredstages[].kindstringrequiredwon/loststages close a lead (reports)agentsarray of objectrequiredagents[].idstringrequiredagents[].namestringrequiredoutcomeobject | nullrequiredLatest loss of this lead (null: never lost)outcome.activebooleanrequiredStill lost (false after the lead moved back to an open stage)outcome.lost_atintegerrequiredUnix time in millisecondsoutcome.stagestring | nullrequiredoutcome.deal_valuenumber | nullrequiredWhen it was lost, lead currencyoutcome.reasonstring | nullrequiredThe reason the team gaveoutcome.notestring | nullrequiredoutcome.reason_bystring | nullrequiredoutcome.reason_atinteger | nullrequiredUnix time in milliseconds, or nulloutcome.guessobject | nullrequiredA suggestion until someone confirms a reasonoutcome.guess.reasonstringrequiredoutcome.guess.bystring | nullrequiredoutcome.guess.confidencenumber | nullrequiredoutcome.guess.evidencestring | nullrequiredWhat the customer wrote that points to itoutcome.summarystring | nullrequiredAI: why the customer did not buyoutcome.reviewstring | nullrequiredAI: how the business answeredoutcome.analysisobjectrequiredoutcome.analysis.statusstringrequiredoutcome.analysis.errorstring | nullrequiredoutcome.analysis.atinteger | nullrequiredUnix time in milliseconds, or nullreviewobject | nullrequiredHow the chat was handled over the last 30 days (up to the loss for a lost lead)review.messagesobjectrequiredreview.messages.from_customerintegerrequiredreview.messages.aiintegerrequiredreview.messages.automaticintegerrequiredreview.messages.teamintegerrequiredreview.aiobjectrequiredreview.ai.repliesintegerrequiredreview.ai.unsureintegerrequiredReplies where the AI did not knowreview.ai.handoffsintegerrequiredreview.ai.unansweredarray of objectrequiredreview.ai.unanswered[].questionstringrequiredreview.ai.unanswered[].countintegerrequiredreview.ai.unanswered[].statusstringrequiredreview.waitobjectrequiredreview.wait.median_minnumber | nullrequiredreview.wait.longest_minnumber | nullrequiredreview.wait.unansweredintegerrequiredCustomer messages never answeredreview.lastobject | nullrequiredreview.last.fromstringrequiredreview.last.atintegerrequiredUnix time in millisecondsreview.flagsarray of stringrequiredlost_reasonsarray of stringrequired
- 400Body is not valid JSON (
INVALID_JSON) or fails validation (VALIDATION_FAILED) - 401Missing, invalid or expired credentials
- 404Contact not found, or it belongs to another tenant (
NOT_FOUND) - 409The lead is not in a lost stage (
CONFLICT)
curl -X PUT "https://api.chatkomodo.com/v1/leads/CONTACT_ID/lost-reason" \
-H "Authorization: Bearer $CHATKOMODO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"reason": "price",
"note": "Prefers delivery after 5 pm"
}'const res = await fetch('https://api.chatkomodo.com/v1/leads/CONTACT_ID/lost-reason', {
method: 'PUT',
headers: {
Authorization: `Bearer ${process.env.CHATKOMODO_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"reason": "price",
"note": "Prefers delivery after 5 pm"
}),
});
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/leads/CONTACT_ID/lost-reason",
headers={
"Authorization": f"Bearer {os.environ['CHATKOMODO_API_KEY']}",
},
json={
"reason": "price",
"note": "Prefers delivery after 5 pm",
},
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/leads/CONTACT_ID/lost-reason', [
'headers' => [
'Authorization' => 'Bearer ' . getenv('CHATKOMODO_API_KEY'),
],
'json' => [
'reason' => 'price',
'note' => 'Prefers delivery after 5 pm',
],
]);
print_r(json_decode((string) $res->getBody(), true));package main
import (
"fmt"
"io"
"net/http"
"os"
"strings"
)
func main() {
body := strings.NewReader(`{
"reason": "price",
"note": "Prefers delivery after 5 pm"
}`)
req, err := http.NewRequest("PUT", "https://api.chatkomodo.com/v1/leads/CONTACT_ID/lost-reason", 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))
}{
"lead": {
"contact_id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"name": "Example",
"phone": "+447700900123",
"stage": "vip",
"labels": [
{
"name": "Example",
"color": "#0a7350"
}
],
"stage_updated_at": 1767225600000,
"deal_value": 0.5,
"owner_agent_id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"owner_name": "string",
"follow_up_at": 1767225600000,
"follow_up_note": "Prefers delivery after 5 pm",
"session_id": "YOUR_DEVICE_ID",
"chat_id": "+447700900123",
"last_message": "Hi Sam, your order has shipped.",
"last_message_at": 1767225600000,
"unread_count": 12,
"source": {
"name": "Example",
"utm_source": "string",
"utm_medium": "string",
"utm_campaign": "string"
}
},
"notes": [
{
"id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"body": "Hi Sam, your order has shipped.",
"actor": "string",
"created_at": 1767225600000
}
],
"history": [
{
"label": "string",
"action": "add",
"source": "manual",
"rule_id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"rule_name": "string",
"actor": "string",
"at": 1767225600000
}
],
"currency": "IDR",
"stages": [
{
"id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"name": "Example",
"color": "#0a7350",
"kind": "open"
}
],
"agents": [
{
"id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"name": "Example"
}
],
"outcome": {
"active": true,
"lost_at": 1767225600000,
"stage": "vip",
"deal_value": 0.5,
"reason": "price",
"note": "Prefers delivery after 5 pm",
"reason_by": "string",
"reason_at": 1767225600000,
"guess": {
"reason": "string",
"by": "ai",
"confidence": 0.5,
"evidence": "string"
},
"summary": "string",
"review": "string",
"analysis": {
"status": "none",
"error": "string",
"at": 1767225600000
}
},
"review": {
"messages": {
"from_customer": 1,
"ai": 1,
"automatic": 1,
"team": 1
},
"ai": {
"replies": 1,
"unsure": 1,
"handoffs": 1,
"unanswered": [
{
"question": "Do you deliver on Sunday?",
"count": 12,
"status": "active"
}
]
},
"wait": {
"median_min": 0.5,
"longest_min": 0.5,
"unanswered": 1
},
"last": {
"from": "customer",
"at": 1767225600000
},
"flags": [
"slow_first_reply"
]
},
"lost_reasons": [
"price"
]
}Let the AI read why a lead was lost
/v1/leads/{contactId}/lost-reason/analyzeThe AI reads the chat (last 30 days up to the loss) and fills outcome.guess (reason, confidence, the customer's words), outcome.summary and outcome.review (how the AI assistant, automatic messages and the team answered), and proposes up to 2 lessons (GET /v1/leads/lessons). Also runs by itself when a lead becomes lost (see PUT /v1/leads/lessons/settings). Counts as one AI reply of the plan.
Path parameters
contactIdstringrequired
Responses
- 200Lead
Response fields
leadobjectrequiredlead.contact_idstringrequiredlead.namestring | nullrequiredlead.phonestringrequiredlead.stagestring | nullrequiredlead.labelsarray of objectrequiredlead.labels[].namestringrequiredlead.labels[].colorstringrequiredlead.stage_updated_atinteger | nullrequiredUnix time in milliseconds, or nulllead.deal_valuenumber | nullrequiredIn the lead currency, major units (49.5 = 49.50)lead.owner_agent_idstring | nullrequiredlead.owner_namestring | nullrequiredlead.follow_up_atinteger | nullrequiredUnix time in milliseconds, or nulllead.follow_up_notestring | nullrequiredlead.session_idstring | nullrequiredlead.chat_idstring | nullrequiredlead.last_messagestring | nullrequiredlead.last_message_atinteger | nullrequiredUnix time in milliseconds, or nulllead.unread_countintegerrequiredlead.sourceobject | nullThe click-to-WhatsApp link (and campaign tags) the person first came through; null when not through a linklead.source.namestringrequiredlead.source.utm_sourcestring | nullrequiredlead.source.utm_mediumstring | nullrequiredlead.source.utm_campaignstring | nullrequirednotesarray of objectrequirednotes[].idstringrequirednotes[].bodystringrequirednotes[].actorstring | nullrequirednotes[].created_atintegerrequiredUnix time in millisecondshistoryarray of objectrequiredhistory[].labelstringrequiredThe label, or the new stage / value / owner id / follow-up timehistory[].actionstringrequiredhistory[].sourcestringrequiredlink: a click-to-WhatsApp link (rule_idis the link,rule_nameits name);payment: a paid QRIS invoice (rule_idis the invoice)history[].rule_idstring | nullrequiredhistory[].rule_namestring | nullrequiredhistory[].actorstring | nullrequiredhistory[].atintegerrequiredUnix time in millisecondscurrencystringrequiredstagesarray of objectrequiredstages[].idstringrequiredstages[].namestringrequiredstages[].colorstringrequiredstages[].kindstringrequiredwon/loststages close a lead (reports)agentsarray of objectrequiredagents[].idstringrequiredagents[].namestringrequiredoutcomeobject | nullrequiredLatest loss of this lead (null: never lost)outcome.activebooleanrequiredStill lost (false after the lead moved back to an open stage)outcome.lost_atintegerrequiredUnix time in millisecondsoutcome.stagestring | nullrequiredoutcome.deal_valuenumber | nullrequiredWhen it was lost, lead currencyoutcome.reasonstring | nullrequiredThe reason the team gaveoutcome.notestring | nullrequiredoutcome.reason_bystring | nullrequiredoutcome.reason_atinteger | nullrequiredUnix time in milliseconds, or nulloutcome.guessobject | nullrequiredA suggestion until someone confirms a reasonoutcome.guess.reasonstringrequiredoutcome.guess.bystring | nullrequiredoutcome.guess.confidencenumber | nullrequiredoutcome.guess.evidencestring | nullrequiredWhat the customer wrote that points to itoutcome.summarystring | nullrequiredAI: why the customer did not buyoutcome.reviewstring | nullrequiredAI: how the business answeredoutcome.analysisobjectrequiredoutcome.analysis.statusstringrequiredoutcome.analysis.errorstring | nullrequiredoutcome.analysis.atinteger | nullrequiredUnix time in milliseconds, or nullreviewobject | nullrequiredHow the chat was handled over the last 30 days (up to the loss for a lost lead)review.messagesobjectrequiredreview.messages.from_customerintegerrequiredreview.messages.aiintegerrequiredreview.messages.automaticintegerrequiredreview.messages.teamintegerrequiredreview.aiobjectrequiredreview.ai.repliesintegerrequiredreview.ai.unsureintegerrequiredReplies where the AI did not knowreview.ai.handoffsintegerrequiredreview.ai.unansweredarray of objectrequiredreview.ai.unanswered[].questionstringrequiredreview.ai.unanswered[].countintegerrequiredreview.ai.unanswered[].statusstringrequiredreview.waitobjectrequiredreview.wait.median_minnumber | nullrequiredreview.wait.longest_minnumber | nullrequiredreview.wait.unansweredintegerrequiredCustomer messages never answeredreview.lastobject | nullrequiredreview.last.fromstringrequiredreview.last.atintegerrequiredUnix time in millisecondsreview.flagsarray of stringrequiredlost_reasonsarray of stringrequired
- 401Missing, invalid or expired credentials
- 402AI allowance used up (
AI_QUOTA) - 404Contact not found, or it belongs to another tenant (
NOT_FOUND) - 409Not lost, or already being read (
CONFLICT,BUSY) - 502The model failed (
AI_ERROR) - 503No AI on the platform (
AI_UNCONFIGURED)
curl -X POST "https://api.chatkomodo.com/v1/leads/CONTACT_ID/lost-reason/analyze" \
-H "Authorization: Bearer $CHATKOMODO_API_KEY"const res = await fetch('https://api.chatkomodo.com/v1/leads/CONTACT_ID/lost-reason/analyze', {
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/leads/CONTACT_ID/lost-reason/analyze",
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/leads/CONTACT_ID/lost-reason/analyze', [
'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/leads/CONTACT_ID/lost-reason/analyze", 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))
}{
"lead": {
"contact_id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"name": "Example",
"phone": "+447700900123",
"stage": "vip",
"labels": [
{
"name": "Example",
"color": "#0a7350"
}
],
"stage_updated_at": 1767225600000,
"deal_value": 0.5,
"owner_agent_id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"owner_name": "string",
"follow_up_at": 1767225600000,
"follow_up_note": "Prefers delivery after 5 pm",
"session_id": "YOUR_DEVICE_ID",
"chat_id": "+447700900123",
"last_message": "Hi Sam, your order has shipped.",
"last_message_at": 1767225600000,
"unread_count": 12,
"source": {
"name": "Example",
"utm_source": "string",
"utm_medium": "string",
"utm_campaign": "string"
}
},
"notes": [
{
"id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"body": "Hi Sam, your order has shipped.",
"actor": "string",
"created_at": 1767225600000
}
],
"history": [
{
"label": "string",
"action": "add",
"source": "manual",
"rule_id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"rule_name": "string",
"actor": "string",
"at": 1767225600000
}
],
"currency": "IDR",
"stages": [
{
"id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"name": "Example",
"color": "#0a7350",
"kind": "open"
}
],
"agents": [
{
"id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"name": "Example"
}
],
"outcome": {
"active": true,
"lost_at": 1767225600000,
"stage": "vip",
"deal_value": 0.5,
"reason": "price",
"note": "Prefers delivery after 5 pm",
"reason_by": "string",
"reason_at": 1767225600000,
"guess": {
"reason": "string",
"by": "ai",
"confidence": 0.5,
"evidence": "string"
},
"summary": "string",
"review": "string",
"analysis": {
"status": "none",
"error": "string",
"at": 1767225600000
}
},
"review": {
"messages": {
"from_customer": 1,
"ai": 1,
"automatic": 1,
"team": 1
},
"ai": {
"replies": 1,
"unsure": 1,
"handoffs": 1,
"unanswered": [
{
"question": "Do you deliver on Sunday?",
"count": 12,
"status": "active"
}
]
},
"wait": {
"median_min": 0.5,
"longest_min": 0.5,
"unanswered": 1
},
"last": {
"from": "customer",
"at": 1767225600000
},
"flags": [
"slow_first_reply"
]
},
"lost_reasons": [
"price"
]
}Why leads were lost, and lessons
/v1/leads/lessonsLeads lost in the last days (7, 30, 90 or 365; still in a lost stage): per reason (confirmed by the team or only guessed), per agent and per chat link, value lost, how the lost chats were handled (slow first answer, never answered, AI unsure, handed over), the questions the AI could not answer in them, and the lessons: suggestions waiting for the owner and the applied ones.
Query parameters
daysstring
Responses
- 200Lessons
Response fields
daysintegerrequiredsinceintegerrequiredUnix time in millisecondscurrencystringrequiredtotalsobjectrequiredtotals.lostintegerrequiredtotals.lost_value_minorintegerrequiredtotals.lost_valuenumber | nullrequiredtotals.confirmedintegerrequiredtotals.guessedintegerrequiredtotals.unknownintegerrequiredtotals.reopenedintegerrequiredreasonsarray of objectrequiredreasons[].idstringrequiredreasons[].confirmedintegerrequiredreasons[].guessedintegerrequiredreasons[].value_minorintegerrequiredreasons[].valuenumber | nullrequiredagentsarray of objectrequiredagents[].idstring | nullrequiredagents[].namestring | nullrequiredagents[].lostintegerrequiredagents[].top_reasonstring | nullrequiredsourcesarray of objectrequiredsources[].idstringrequiredsources[].namestringrequiredsources[].lostintegerrequiredsources[].top_reasonstring | nullrequiredhandlingobjectrequiredhandling.analysedintegerrequiredhandling.slow_first_replyintegerrequiredhandling.never_answeredintegerrequiredhandling.ai_unsureintegerrequiredhandling.handed_overintegerrequiredquestionsarray of objectrequiredquestions[].questionstringrequiredquestions[].countintegerrequiredsuggestionsarray of objectrequiredsuggestions[].idstringrequiredsuggestions[].kindstringrequiredsuggestions[].questionstring | nullrequiredfaq: the customer questionsuggestions[].textstring | nullrequiredfaq: the answer (may be empty until written); guidance: the instructionsuggestions[].reasonstring | nullrequiredsuggestions[].countintegerrequiredLost leads that suggested itsuggestions[].contactsarray of stringrequiredsuggestions[].statusstringrequiredsuggestions[].faq_idstring | nullrequiredsuggestions[].created_atintegerrequiredUnix time in millisecondssuggestions[].updated_atintegerrequiredUnix time in millisecondssuggestions[].applied_atinteger | nullrequiredUnix time in milliseconds, or nullappliedarray of objectrequiredapplied[].idstringrequiredapplied[].kindstringrequiredapplied[].questionstring | nullrequiredfaq: the customer questionapplied[].textstring | nullrequiredfaq: the answer (may be empty until written); guidance: the instructionapplied[].reasonstring | nullrequiredapplied[].countintegerrequiredLost leads that suggested itapplied[].contactsarray of stringrequiredapplied[].statusstringrequiredapplied[].faq_idstring | nullrequiredapplied[].created_atintegerrequiredUnix time in millisecondsapplied[].updated_atintegerrequiredUnix time in millisecondsapplied[].applied_atinteger | nullrequiredUnix time in milliseconds, or nullauto_analyzebooleanrequiredai_availablebooleanrequired
- 401Missing, invalid or expired credentials
curl "https://api.chatkomodo.com/v1/leads/lessons" \
-H "Authorization: Bearer $CHATKOMODO_API_KEY"const res = await fetch('https://api.chatkomodo.com/v1/leads/lessons', {
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/leads/lessons",
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/leads/lessons', [
'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/leads/lessons", 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))
}{
"days": 1,
"since": 1767225600000,
"currency": "IDR",
"totals": {
"lost": 1,
"lost_value_minor": 1,
"lost_value": 0.5,
"confirmed": 1,
"guessed": 1,
"unknown": 1,
"reopened": 1
},
"reasons": [
{
"id": "price",
"confirmed": 1,
"guessed": 1,
"value_minor": 1,
"value": 0.5
}
],
"agents": [
{
"id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"name": "Example",
"lost": 1,
"top_reason": "string"
}
],
"sources": [
{
"id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"name": "Example",
"lost": 1,
"top_reason": "string"
}
],
"handling": {
"analysed": 1,
"slow_first_reply": 1,
"never_answered": 1,
"ai_unsure": 1,
"handed_over": 1
},
"questions": [
{
"question": "Do you deliver on Sunday?",
"count": 12
}
],
"suggestions": [
{
"id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"kind": "faq",
"question": "Do you deliver on Sunday?",
"text": "Hi Sam, your order has shipped.",
"reason": "string",
"count": 12,
"contacts": [
"string"
],
"status": "proposed",
"faq_id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"created_at": 1767225600000,
"updated_at": 1767225600000,
"applied_at": 1767225600000
}
],
"applied": [
{
"id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"kind": "faq",
"question": "Do you deliver on Sunday?",
"text": "Hi Sam, your order has shipped.",
"reason": "string",
"count": 12,
"contacts": [
"string"
],
"status": "proposed",
"faq_id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"created_at": 1767225600000,
"updated_at": 1767225600000,
"applied_at": 1767225600000
}
],
"auto_analyze": true,
"ai_available": true
}Let the AI read every lost lead
/v1/leads/lessons/settingsOn (default): when a lead becomes lost, the AI reads its chat once (one AI reply of the plan each). Recorded as leads.lost_auto_analyze.
Request body
auto_analyzebooleanrequired
Responses
- 200Saved
Response fields
auto_analyzebooleanrequired
- 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)
curl -X PUT "https://api.chatkomodo.com/v1/leads/lessons/settings" \
-H "Authorization: Bearer $CHATKOMODO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"auto_analyze": true
}'const res = await fetch('https://api.chatkomodo.com/v1/leads/lessons/settings', {
method: 'PUT',
headers: {
Authorization: `Bearer ${process.env.CHATKOMODO_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"auto_analyze": true
}),
});
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/leads/lessons/settings",
headers={
"Authorization": f"Bearer {os.environ['CHATKOMODO_API_KEY']}",
},
json={
"auto_analyze": True,
},
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/leads/lessons/settings', [
'headers' => [
'Authorization' => 'Bearer ' . getenv('CHATKOMODO_API_KEY'),
],
'json' => [
'auto_analyze' => true,
],
]);
print_r(json_decode((string) $res->getBody(), true));package main
import (
"fmt"
"io"
"net/http"
"os"
"strings"
)
func main() {
body := strings.NewReader(`{
"auto_analyze": true
}`)
req, err := http.NewRequest("PUT", "https://api.chatkomodo.com/v1/leads/lessons/settings", 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))
}{
"auto_analyze": true
}Apply a lesson
/v1/leads/lessons/{id}/applyA faq becomes a saved answer of the AI knowledge (send the text you checked; required when the suggestion has no answer). A guidance is added to the AI assistant's instructions (at most 15 applied, newest first; edit it with text). Nothing changes before this. Recorded as leads.lesson_applied.
Path parameters
idstringrequired
Request body
questionstringtextstring
Responses
- 200Applied
Response fields
lessonobjectrequiredlesson.idstringrequiredlesson.kindstringrequiredlesson.questionstring | nullrequiredfaq: the customer questionlesson.textstring | nullrequiredfaq: the answer (may be empty until written); guidance: the instructionlesson.reasonstring | nullrequiredlesson.countintegerrequiredLost leads that suggested itlesson.contactsarray of stringrequiredlesson.statusstringrequiredlesson.faq_idstring | nullrequiredlesson.created_atintegerrequiredUnix time in millisecondslesson.updated_atintegerrequiredUnix time in millisecondslesson.applied_atinteger | nullrequiredUnix time in milliseconds, or null
- 400No answer or guideline (
VALIDATION_FAILED) - 401Missing, invalid or expired credentials
- 403Forbidden for a customer-service agent login (
Agent access is not allowed for this operation) - 404Suggestion not found, or it belongs to another tenant (
NOT_FOUND)
curl -X POST "https://api.chatkomodo.com/v1/leads/lessons/ID/apply" \
-H "Authorization: Bearer $CHATKOMODO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"question": "Do you deliver on Sunday?",
"text": "Hi Sam, your order has shipped."
}'const res = await fetch('https://api.chatkomodo.com/v1/leads/lessons/ID/apply', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.CHATKOMODO_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"question": "Do you deliver on Sunday?",
"text": "Hi Sam, your order has shipped."
}),
});
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/leads/lessons/ID/apply",
headers={
"Authorization": f"Bearer {os.environ['CHATKOMODO_API_KEY']}",
},
json={
"question": "Do you deliver on Sunday?",
"text": "Hi Sam, your order has shipped.",
},
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/leads/lessons/ID/apply', [
'headers' => [
'Authorization' => 'Bearer ' . getenv('CHATKOMODO_API_KEY'),
],
'json' => [
'question' => 'Do you deliver on Sunday?',
'text' => 'Hi Sam, your order has shipped.',
],
]);
print_r(json_decode((string) $res->getBody(), true));package main
import (
"fmt"
"io"
"net/http"
"os"
"strings"
)
func main() {
body := strings.NewReader(`{
"question": "Do you deliver on Sunday?",
"text": "Hi Sam, your order has shipped."
}`)
req, err := http.NewRequest("POST", "https://api.chatkomodo.com/v1/leads/lessons/ID/apply", 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))
}{
"lesson": {
"id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"kind": "faq",
"question": "Do you deliver on Sunday?",
"text": "Hi Sam, your order has shipped.",
"reason": "string",
"count": 12,
"contacts": [
"string"
],
"status": "proposed",
"faq_id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"created_at": 1767225600000,
"updated_at": 1767225600000,
"applied_at": 1767225600000
}
}Dismiss a lesson
/v1/leads/lessons/{id}/dismissIt is not proposed again.
Path parameters
idstringrequired
Responses
- 200Dismissed
Response fields
okbooleanrequired
- 401Missing, invalid or expired credentials
- 403Forbidden for a customer-service agent login (
Agent access is not allowed for this operation) - 404Suggestion not found, or it belongs to another tenant (
NOT_FOUND)
curl -X POST "https://api.chatkomodo.com/v1/leads/lessons/ID/dismiss" \
-H "Authorization: Bearer $CHATKOMODO_API_KEY"const res = await fetch('https://api.chatkomodo.com/v1/leads/lessons/ID/dismiss', {
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/leads/lessons/ID/dismiss",
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/leads/lessons/ID/dismiss', [
'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/leads/lessons/ID/dismiss", 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))
}{
"ok": true
}Stop using an applied lesson
/v1/leads/lessons/{id}A guideline leaves the AI assistant's instructions. A saved answer stays in the AI knowledge (remove it there). Recorded as leads.lesson_removed.
Path parameters
idstringrequired
Responses
- 200Removed
Response fields
okbooleanrequired
- 401Missing, invalid or expired credentials
- 403Forbidden for a customer-service agent login (
Agent access is not allowed for this operation) - 404Suggestion not found, or it belongs to another tenant (
NOT_FOUND)
curl -X DELETE "https://api.chatkomodo.com/v1/leads/lessons/ID" \
-H "Authorization: Bearer $CHATKOMODO_API_KEY"const res = await fetch('https://api.chatkomodo.com/v1/leads/lessons/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/leads/lessons/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/leads/lessons/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/leads/lessons/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))
}{
"ok": true
}Labels and stage of a chat
/v1/sessions/{sid}/inbox/{chatId}/labelsA chat can carry several labels (up to 20). For a chat with a person they are that person's contact labels, shared across devices.
Path parameters
sidstringrequiredSession (device) idchatIdstringrequiredChat id (JID), URL-encoded
Responses
- 200Labels
Response fields
labelsarray of objectrequiredlabels[].namestringrequiredlabels[].colorstringrequiredstagestring | nullrequiredLead stage (chats with a person only)stagesarray of objectrequiredstages[].idstringrequiredstages[].namestringrequiredstages[].colorstringrequiredstages[].kindstringrequiredwon/loststages close a lead (reports)personbooleanrequiredThe chat is with a person (labels live on their contact)historyarray of objectrequiredLatest 20 changeshistory[].labelstringrequiredThe label, or the new stage / value / owner id / follow-up timehistory[].actionstringrequiredhistory[].sourcestringrequiredlink: a click-to-WhatsApp link (rule_idis the link,rule_nameits name);payment: a paid QRIS invoice (rule_idis the invoice)history[].rule_idstring | nullrequiredhistory[].rule_namestring | nullrequiredhistory[].actorstring | nullrequiredhistory[].atintegerrequiredUnix time in millisecondsleadobject | nullrequiredThe person's lead details (null: not a contact yet)lead.contact_idstringrequiredlead.deal_valuenumber | nullrequiredlead.currencystringrequiredlead.owner_agent_idstring | nullrequiredlead.owner_namestring | nullrequiredlead.follow_up_atinteger | nullrequiredUnix time in milliseconds, or nulllead.follow_up_notestring | nullrequired
- 401Missing, invalid or expired credentials
curl "https://api.chatkomodo.com/v1/sessions/YOUR_DEVICE_ID/inbox/447700900123%40s.whatsapp.net/labels" \
-H "Authorization: Bearer $CHATKOMODO_API_KEY"const res = await fetch('https://api.chatkomodo.com/v1/sessions/YOUR_DEVICE_ID/inbox/447700900123%40s.whatsapp.net/labels', {
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/sessions/YOUR_DEVICE_ID/inbox/447700900123%40s.whatsapp.net/labels",
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/sessions/YOUR_DEVICE_ID/inbox/447700900123%40s.whatsapp.net/labels', [
'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/sessions/YOUR_DEVICE_ID/inbox/447700900123%40s.whatsapp.net/labels", 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))
}{
"labels": [
{
"name": "Example",
"color": "#0a7350"
}
],
"stage": "vip",
"stages": [
{
"id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"name": "Example",
"color": "#0a7350",
"kind": "open"
}
],
"person": true,
"history": [
{
"label": "string",
"action": "add",
"source": "manual",
"rule_id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"rule_name": "string",
"actor": "string",
"at": 1767225600000
}
],
"lead": {
"contact_id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"deal_value": 0.5,
"currency": "IDR",
"owner_agent_id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"owner_name": "string",
"follow_up_at": 1767225600000,
"follow_up_note": "Prefers delivery after 5 pm"
}
}Add or remove labels on a chat
/v1/sessions/{sid}/inbox/{chatId}/labelsAdds and removes some labels, keeping the others. Adding a label by hand lifts an earlier manual removal, so rules may add it again later.
Path parameters
sidstringrequiredSession (device) idchatIdstringrequiredChat id (JID), URL-encoded
Request body
addarray of stringremovearray of string
Responses
- 200Saved
Response fields
labelsarray of objectrequiredlabels[].namestringrequiredlabels[].colorstringrequiredstagestring | nullrequiredLead stage (chats with a person only)stagesarray of objectrequiredstages[].idstringrequiredstages[].namestringrequiredstages[].colorstringrequiredstages[].kindstringrequiredwon/loststages close a lead (reports)personbooleanrequiredThe chat is with a person (labels live on their contact)historyarray of objectrequiredLatest 20 changeshistory[].labelstringrequiredThe label, or the new stage / value / owner id / follow-up timehistory[].actionstringrequiredhistory[].sourcestringrequiredlink: a click-to-WhatsApp link (rule_idis the link,rule_nameits name);payment: a paid QRIS invoice (rule_idis the invoice)history[].rule_idstring | nullrequiredhistory[].rule_namestring | nullrequiredhistory[].actorstring | nullrequiredhistory[].atintegerrequiredUnix time in millisecondsleadobject | nullrequiredThe person's lead details (null: not a contact yet)lead.contact_idstringrequiredlead.deal_valuenumber | nullrequiredlead.currencystringrequiredlead.owner_agent_idstring | nullrequiredlead.owner_namestring | nullrequiredlead.follow_up_atinteger | nullrequiredUnix time in milliseconds, or nulllead.follow_up_notestring | nullrequired
- 400Invalid body or more than 20 labels (
LIMIT_REACHED) - 401Missing, invalid or expired credentials
curl -X POST "https://api.chatkomodo.com/v1/sessions/YOUR_DEVICE_ID/inbox/447700900123%40s.whatsapp.net/labels" \
-H "Authorization: Bearer $CHATKOMODO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"add": [
"string"
],
"remove": [
"string"
]
}'const res = await fetch('https://api.chatkomodo.com/v1/sessions/YOUR_DEVICE_ID/inbox/447700900123%40s.whatsapp.net/labels', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.CHATKOMODO_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"add": [
"string"
],
"remove": [
"string"
]
}),
});
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/sessions/YOUR_DEVICE_ID/inbox/447700900123%40s.whatsapp.net/labels",
headers={
"Authorization": f"Bearer {os.environ['CHATKOMODO_API_KEY']}",
},
json={
"add": [
"string",
],
"remove": [
"string",
],
},
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/sessions/YOUR_DEVICE_ID/inbox/447700900123%40s.whatsapp.net/labels', [
'headers' => [
'Authorization' => 'Bearer ' . getenv('CHATKOMODO_API_KEY'),
],
'json' => [
'add' => [
'string',
],
'remove' => [
'string',
],
],
]);
print_r(json_decode((string) $res->getBody(), true));package main
import (
"fmt"
"io"
"net/http"
"os"
"strings"
)
func main() {
body := strings.NewReader(`{
"add": [
"string"
],
"remove": [
"string"
]
}`)
req, err := http.NewRequest("POST", "https://api.chatkomodo.com/v1/sessions/YOUR_DEVICE_ID/inbox/447700900123%40s.whatsapp.net/labels", 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))
}{
"labels": [
{
"name": "Example",
"color": "#0a7350"
}
],
"stage": "vip",
"stages": [
{
"id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"name": "Example",
"color": "#0a7350",
"kind": "open"
}
],
"person": true,
"history": [
{
"label": "string",
"action": "add",
"source": "manual",
"rule_id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"rule_name": "string",
"actor": "string",
"at": 1767225600000
}
],
"lead": {
"contact_id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"deal_value": 0.5,
"currency": "IDR",
"owner_agent_id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"owner_name": "string",
"follow_up_at": 1767225600000,
"follow_up_note": "Prefers delivery after 5 pm"
}
}Replace the labels of a chat
/v1/sessions/{sid}/inbox/{chatId}/labelsLabelling a person who is not a contact yet saves them as a contact. Removing a label by hand stops rules and the AI from adding it again to this person.
Path parameters
sidstringrequiredSession (device) idchatIdstringrequiredChat id (JID), URL-encoded
Request body
labelsarray of stringrequired
Responses
- 200Saved
Response fields
labelsarray of objectrequiredlabels[].namestringrequiredlabels[].colorstringrequiredstagestring | nullrequiredLead stage (chats with a person only)stagesarray of objectrequiredstages[].idstringrequiredstages[].namestringrequiredstages[].colorstringrequiredstages[].kindstringrequiredwon/loststages close a lead (reports)personbooleanrequiredThe chat is with a person (labels live on their contact)historyarray of objectrequiredLatest 20 changeshistory[].labelstringrequiredThe label, or the new stage / value / owner id / follow-up timehistory[].actionstringrequiredhistory[].sourcestringrequiredlink: a click-to-WhatsApp link (rule_idis the link,rule_nameits name);payment: a paid QRIS invoice (rule_idis the invoice)history[].rule_idstring | nullrequiredhistory[].rule_namestring | nullrequiredhistory[].actorstring | nullrequiredhistory[].atintegerrequiredUnix time in millisecondsleadobject | nullrequiredThe person's lead details (null: not a contact yet)lead.contact_idstringrequiredlead.deal_valuenumber | nullrequiredlead.currencystringrequiredlead.owner_agent_idstring | nullrequiredlead.owner_namestring | nullrequiredlead.follow_up_atinteger | nullrequiredUnix time in milliseconds, or nulllead.follow_up_notestring | nullrequired
- 400Invalid body or more than 20 labels (
LIMIT_REACHED) - 401Missing, invalid or expired credentials
curl -X PUT "https://api.chatkomodo.com/v1/sessions/YOUR_DEVICE_ID/inbox/447700900123%40s.whatsapp.net/labels" \
-H "Authorization: Bearer $CHATKOMODO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"labels": [
"string"
]
}'const res = await fetch('https://api.chatkomodo.com/v1/sessions/YOUR_DEVICE_ID/inbox/447700900123%40s.whatsapp.net/labels', {
method: 'PUT',
headers: {
Authorization: `Bearer ${process.env.CHATKOMODO_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"labels": [
"string"
]
}),
});
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/sessions/YOUR_DEVICE_ID/inbox/447700900123%40s.whatsapp.net/labels",
headers={
"Authorization": f"Bearer {os.environ['CHATKOMODO_API_KEY']}",
},
json={
"labels": [
"string",
],
},
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/sessions/YOUR_DEVICE_ID/inbox/447700900123%40s.whatsapp.net/labels', [
'headers' => [
'Authorization' => 'Bearer ' . getenv('CHATKOMODO_API_KEY'),
],
'json' => [
'labels' => [
'string',
],
],
]);
print_r(json_decode((string) $res->getBody(), true));package main
import (
"fmt"
"io"
"net/http"
"os"
"strings"
)
func main() {
body := strings.NewReader(`{
"labels": [
"string"
]
}`)
req, err := http.NewRequest("PUT", "https://api.chatkomodo.com/v1/sessions/YOUR_DEVICE_ID/inbox/447700900123%40s.whatsapp.net/labels", 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))
}{
"labels": [
{
"name": "Example",
"color": "#0a7350"
}
],
"stage": "vip",
"stages": [
{
"id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"name": "Example",
"color": "#0a7350",
"kind": "open"
}
],
"person": true,
"history": [
{
"label": "string",
"action": "add",
"source": "manual",
"rule_id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"rule_name": "string",
"actor": "string",
"at": 1767225600000
}
],
"lead": {
"contact_id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"deal_value": 0.5,
"currency": "IDR",
"owner_agent_id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"owner_name": "string",
"follow_up_at": 1767225600000,
"follow_up_note": "Prefers delivery after 5 pm"
}
}Set the lead stage of a chat
/v1/sessions/{sid}/inbox/{chatId}/stagePuts the person on the leads board in this stage (null takes them off). The person is saved as a contact when needed.
Path parameters
sidstringrequiredSession (device) idchatIdstringrequiredChat id (JID), URL-encoded
Request body
stagestring | nullrequired
Responses
- 200Saved
Response fields
labelsarray of objectrequiredlabels[].namestringrequiredlabels[].colorstringrequiredstagestring | nullrequiredLead stage (chats with a person only)stagesarray of objectrequiredstages[].idstringrequiredstages[].namestringrequiredstages[].colorstringrequiredstages[].kindstringrequiredwon/loststages close a lead (reports)personbooleanrequiredThe chat is with a person (labels live on their contact)historyarray of objectrequiredLatest 20 changeshistory[].labelstringrequiredThe label, or the new stage / value / owner id / follow-up timehistory[].actionstringrequiredhistory[].sourcestringrequiredlink: a click-to-WhatsApp link (rule_idis the link,rule_nameits name);payment: a paid QRIS invoice (rule_idis the invoice)history[].rule_idstring | nullrequiredhistory[].rule_namestring | nullrequiredhistory[].actorstring | nullrequiredhistory[].atintegerrequiredUnix time in millisecondsleadobject | nullrequiredThe person's lead details (null: not a contact yet)lead.contact_idstringrequiredlead.deal_valuenumber | nullrequiredlead.currencystringrequiredlead.owner_agent_idstring | nullrequiredlead.owner_namestring | nullrequiredlead.follow_up_atinteger | nullrequiredUnix time in milliseconds, or nulllead.follow_up_notestring | nullrequired
- 400Not a chat with a person, or an unknown stage (
VALIDATION_FAILED) - 401Missing, invalid or expired credentials
curl -X PUT "https://api.chatkomodo.com/v1/sessions/YOUR_DEVICE_ID/inbox/447700900123%40s.whatsapp.net/stage" \
-H "Authorization: Bearer $CHATKOMODO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"stage": "vip"
}'const res = await fetch('https://api.chatkomodo.com/v1/sessions/YOUR_DEVICE_ID/inbox/447700900123%40s.whatsapp.net/stage', {
method: 'PUT',
headers: {
Authorization: `Bearer ${process.env.CHATKOMODO_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"stage": "vip"
}),
});
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/sessions/YOUR_DEVICE_ID/inbox/447700900123%40s.whatsapp.net/stage",
headers={
"Authorization": f"Bearer {os.environ['CHATKOMODO_API_KEY']}",
},
json={
"stage": "vip",
},
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/sessions/YOUR_DEVICE_ID/inbox/447700900123%40s.whatsapp.net/stage', [
'headers' => [
'Authorization' => 'Bearer ' . getenv('CHATKOMODO_API_KEY'),
],
'json' => [
'stage' => 'vip',
],
]);
print_r(json_decode((string) $res->getBody(), true));package main
import (
"fmt"
"io"
"net/http"
"os"
"strings"
)
func main() {
body := strings.NewReader(`{
"stage": "vip"
}`)
req, err := http.NewRequest("PUT", "https://api.chatkomodo.com/v1/sessions/YOUR_DEVICE_ID/inbox/447700900123%40s.whatsapp.net/stage", 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))
}{
"labels": [
{
"name": "Example",
"color": "#0a7350"
}
],
"stage": "vip",
"stages": [
{
"id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"name": "Example",
"color": "#0a7350",
"kind": "open"
}
],
"person": true,
"history": [
{
"label": "string",
"action": "add",
"source": "manual",
"rule_id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"rule_name": "string",
"actor": "string",
"at": 1767225600000
}
],
"lead": {
"contact_id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"deal_value": 0.5,
"currency": "IDR",
"owner_agent_id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"owner_name": "string",
"follow_up_at": 1767225600000,
"follow_up_note": "Prefers delivery after 5 pm"
}
}Run the AI rules on a chat now
/v1/sessions/{sid}/inbox/{chatId}/labels/aiLets the AI rules check this conversation immediately (normally they run after incoming messages, at most every 15 minutes per chat). Uses 1 AI reply of the plan; nothing happens without AI rules, an AI provider or AI quota.
Path parameters
sidstringrequiredSession (device) idchatIdstringrequiredChat id (JID), URL-encoded
Responses
- 200Checked
Response fields
labelsarray of objectrequiredlabels[].namestringrequiredlabels[].colorstringrequiredstagestring | nullrequiredLead stage (chats with a person only)stagesarray of objectrequiredstages[].idstringrequiredstages[].namestringrequiredstages[].colorstringrequiredstages[].kindstringrequiredwon/loststages close a lead (reports)personbooleanrequiredThe chat is with a person (labels live on their contact)historyarray of objectrequiredLatest 20 changeshistory[].labelstringrequiredThe label, or the new stage / value / owner id / follow-up timehistory[].actionstringrequiredhistory[].sourcestringrequiredlink: a click-to-WhatsApp link (rule_idis the link,rule_nameits name);payment: a paid QRIS invoice (rule_idis the invoice)history[].rule_idstring | nullrequiredhistory[].rule_namestring | nullrequiredhistory[].actorstring | nullrequiredhistory[].atintegerrequiredUnix time in millisecondsleadobject | nullrequiredThe person's lead details (null: not a contact yet)lead.contact_idstringrequiredlead.deal_valuenumber | nullrequiredlead.currencystringrequiredlead.owner_agent_idstring | nullrequiredlead.owner_namestring | nullrequiredlead.follow_up_atinteger | nullrequiredUnix time in milliseconds, or nulllead.follow_up_notestring | nullrequiredfiredarray of stringrequiredIds of the rules that applied
- 400Not a chat with a person (
VALIDATION_FAILED) - 401Missing, invalid or expired credentials
- 403Forbidden for a customer-service agent login (
Agent access is not allowed for this operation)
curl -X POST "https://api.chatkomodo.com/v1/sessions/YOUR_DEVICE_ID/inbox/447700900123%40s.whatsapp.net/labels/ai" \
-H "Authorization: Bearer $CHATKOMODO_API_KEY"const res = await fetch('https://api.chatkomodo.com/v1/sessions/YOUR_DEVICE_ID/inbox/447700900123%40s.whatsapp.net/labels/ai', {
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/sessions/YOUR_DEVICE_ID/inbox/447700900123%40s.whatsapp.net/labels/ai",
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/sessions/YOUR_DEVICE_ID/inbox/447700900123%40s.whatsapp.net/labels/ai', [
'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/sessions/YOUR_DEVICE_ID/inbox/447700900123%40s.whatsapp.net/labels/ai", 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))
}{
"labels": [
{
"name": "Example",
"color": "#0a7350"
}
],
"stage": "vip",
"stages": [
{
"id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"name": "Example",
"color": "#0a7350",
"kind": "open"
}
],
"person": true,
"history": [
{
"label": "string",
"action": "add",
"source": "manual",
"rule_id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"rule_name": "string",
"actor": "string",
"at": 1767225600000
}
],
"lead": {
"contact_id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"deal_value": 0.5,
"currency": "IDR",
"owner_agent_id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"owner_name": "string",
"follow_up_at": 1767225600000,
"follow_up_note": "Prefers delivery after 5 pm"
},
"fired": [
"string"
]
}