ChatKomodo Docs Home Sign in

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

GET/v1/labels

Every 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 objectrequired
    • labels[].namestringrequired
      Normalised name: lowercase, spaces become dashes
    • labels[].colorstringrequired
      #RRGGBB
    • labels[].descriptionstring | nullrequired
    • labels[].countintegerrequired
      Contacts and group chats that carry it
    • colorsarray of stringrequired
      Suggested colours
  • 401Missing, invalid or expired credentials
Request
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))
}
Response 200
{
  "labels": [
    {
      "name": "Example",
      "color": "#0a7350",
      "description": "Short description",
      "count": 12
    }
  ],
  "colors": [
    "#0a7350"
  ]
}

Create a label

POST/v1/labels

Adds 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

  • namestringrequired
    Up to 60 characters
  • colorstring
    #RRGGBB (default: picked from the name)
  • descriptionstring | null
    Up to 300 characters

Responses

  • 201Created
    Response fields
    • labelobjectrequired
    • label.namestringrequired
      Normalised name: lowercase, spaces become dashes
    • label.colorstringrequired
      #RRGGBB
    • label.descriptionstring | nullrequired
    • label.countintegerrequired
      Contacts 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)
Request
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))
}
Response 201
{
  "label": {
    "name": "Example",
    "color": "#0a7350",
    "description": "Short description",
    "count": 12
  }
}

Rename or recolour a label

PATCH/v1/labels/{name}

A new name renames the label on every contact, group chat and rule.

Path parameters

  • namestringrequired

Request body

  • namestring
    Up to 60 characters
  • colorstring
  • descriptionstring | null
    Up to 300 characters

Responses

  • 200Saved
    Response fields
    • labelobjectrequired
    • label.namestringrequired
      Normalised name: lowercase, spaces become dashes
    • label.colorstringrequired
      #RRGGBB
    • label.descriptionstring | nullrequired
    • label.countintegerrequired
      Contacts 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)
Request
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))
}
Response 200
{
  "label": {
    "name": "Example",
    "color": "#0a7350",
    "description": "Short description",
    "count": 12
  }
}

Delete a label

DEL/v1/labels/{name}

Removes the label from every contact, group chat and rule.

Path parameters

  • namestringrequired

Responses

  • 200Deleted
    Response fields
    • okbooleanrequired
    • removed_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)
Request
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))
}
Response 200
{
  "ok": true,
  "removed_from": 1
}

List automatic labelling rules

GET/v1/labels/rules

Rules 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 objectrequired
    • rules[].idstringrequired
    • rules[].namestringrequired
    • rules[].enabledbooleanrequired
    • rules[].triggerstringrequired
      One of: keyword, first_message, store_event, inactive, ai, label_added
    • rules[].configobjectrequired
    • rules[].config.keywordsarray of string
      keyword: words or phrases, matched at the start of a word (harga also finds harganya), accents and case ignored
    • rules[].config.matchstring
      keyword: any (default) or all keywords
      One of: any, all
    • rules[].config.eventsarray of string
      store_event: which store events
    • rules[].config.daysinteger
      inactive: days without a message (1–365)
    • rules[].config.instructionstring
      ai: when the rule applies, in plain words, e.g. "the customer asks for a price or wants to order"
    • rules[].config.labelsarray of string
      label_added: the rule runs when one of these labels is put on a chat
    • rules[].add_labelsarray of stringrequired
    • rules[].remove_labelsarray of stringrequired
    • rules[].set_stagestring | nullrequired
      Lead stage to move the person to
    • rules[].session_idsarray of string | nullrequired
      Only these devices (null = all)
    • rules[].actionsobjectrequired
    • rules[].actions.assignobject | null
      Assign the chat to a CS agent; the lead gets that owner when it has none
    • rules[].actions.assign.agent_idstring | nullrequired
      null = the next agent in turn (online first, fewest open chats)
    • rules[].actions.messagesarray of object
      Messages to send (a follow-up sequence)
      Up to 5 items
    • rules[].actions.messages[].delay_minutesintegerrequired
      0 – 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 opens
    • rules[].actions.messages[].textstringrequired
      Personalisation tokens such as {{first_name|there}} work
      Up to 4 000 characters
    • rules[].actions.stop_on_replyboolean
      Messages still waiting are cancelled when the customer writes (default true)
    • rules[].actions.once_daysinteger
      Actions run at most once per chat in this many days (1–365, default 30)
    • rules[].fire_countintegerrequired
    • rules[].last_fired_atinteger | nullrequired
      Unix time in milliseconds, or null
    • rules[].created_atintegerrequired
      Unix time in milliseconds
    • rules[].updated_atintegerrequired
      Unix time in milliseconds
  • 401Missing, invalid or expired credentials
Request
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))
}
Response 200
{
  "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

POST/v1/labels/rules

A 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

  • namestringrequired
    Up to 80 characters
  • enabledboolean
  • triggerstringrequired
    One of: keyword, first_message, store_event, inactive, ai, label_added
  • configobject
  • config.keywordsarray of string
    keyword: words or phrases, matched at the start of a word (harga also finds harganya), accents and case ignored
  • config.matchstring
    keyword: any (default) or all keywords
    One of: any, all
  • config.eventsarray of string
    store_event: which store events
  • config.daysinteger
    inactive: days without a message (1–365)
  • config.instructionstring
    ai: when the rule applies, in plain words, e.g. "the customer asks for a price or wants to order"
  • config.labelsarray of string
    label_added: the rule runs when one of these labels is put on a chat
  • add_labelsarray of string
  • remove_labelsarray of string
  • set_stagestring | null
  • session_idsarray of string | null
  • actionsobject | null
  • actions.assignobject | null
    Assign the chat to a CS agent; the lead gets that owner when it has none
  • actions.assign.agent_idstring | nullrequired
    null = the next agent in turn (online first, fewest open chats)
  • actions.messagesarray of object
    Messages to send (a follow-up sequence)
    Up to 5 items
  • actions.messages[].delay_minutesintegerrequired
    0 – 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 opens
  • actions.messages[].textstringrequired
    Personalisation tokens such as {{first_name|there}} work
    Up to 4 000 characters
  • actions.stop_on_replyboolean
    Messages still waiting are cancelled when the customer writes (default true)
  • actions.once_daysinteger
    Actions run at most once per chat in this many days (1–365, default 30)

Responses

  • 201Created
    Response fields
    • ruleobjectrequired
    • rule.idstringrequired
    • rule.namestringrequired
    • rule.enabledbooleanrequired
    • rule.triggerstringrequired
      One of: keyword, first_message, store_event, inactive, ai, label_added
    • rule.configobjectrequired
    • rule.config.keywordsarray of string
      keyword: words or phrases, matched at the start of a word (harga also finds harganya), accents and case ignored
    • rule.config.matchstring
      keyword: any (default) or all keywords
      One of: any, all
    • rule.config.eventsarray of string
      store_event: which store events
    • rule.config.daysinteger
      inactive: days without a message (1–365)
    • rule.config.instructionstring
      ai: when the rule applies, in plain words, e.g. "the customer asks for a price or wants to order"
    • rule.config.labelsarray of string
      label_added: the rule runs when one of these labels is put on a chat
    • rule.add_labelsarray of stringrequired
    • rule.remove_labelsarray of stringrequired
    • rule.set_stagestring | nullrequired
      Lead stage to move the person to
    • rule.session_idsarray of string | nullrequired
      Only these devices (null = all)
    • rule.actionsobjectrequired
    • rule.actions.assignobject | null
      Assign the chat to a CS agent; the lead gets that owner when it has none
    • rule.actions.assign.agent_idstring | nullrequired
      null = the next agent in turn (online first, fewest open chats)
    • rule.actions.messagesarray of object
      Messages to send (a follow-up sequence)
      Up to 5 items
    • rule.actions.messages[].delay_minutesintegerrequired
      0 – 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 opens
    • rule.actions.messages[].textstringrequired
      Personalisation tokens such as {{first_name|there}} work
      Up to 4 000 characters
    • rule.actions.stop_on_replyboolean
      Messages still waiting are cancelled when the customer writes (default true)
    • rule.actions.once_daysinteger
      Actions run at most once per chat in this many days (1–365, default 30)
    • rule.fire_countintegerrequired
    • rule.last_fired_atinteger | nullrequired
      Unix time in milliseconds, or null
    • rule.created_atintegerrequired
      Unix time in milliseconds
    • rule.updated_atintegerrequired
      Unix 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)
Request
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))
}
Response 201
{
  "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

PATCH/v1/labels/rules/{id}

Fields left out keep their value. enabled: false pauses the rule.

Path parameters

  • idstringrequired
    Rule id

Request body

  • namestring
    Up to 80 characters
  • enabledboolean
  • triggerstring
    One of: keyword, first_message, store_event, inactive, ai, label_added
  • configobject
  • config.keywordsarray of string
    keyword: words or phrases, matched at the start of a word (harga also finds harganya), accents and case ignored
  • config.matchstring
    keyword: any (default) or all keywords
    One of: any, all
  • config.eventsarray of string
    store_event: which store events
  • config.daysinteger
    inactive: days without a message (1–365)
  • config.instructionstring
    ai: when the rule applies, in plain words, e.g. "the customer asks for a price or wants to order"
  • config.labelsarray of string
    label_added: the rule runs when one of these labels is put on a chat
  • add_labelsarray of string
  • remove_labelsarray of string
  • set_stagestring | null
  • session_idsarray of string | null
  • actionsobject | null
  • actions.assignobject | null
    Assign the chat to a CS agent; the lead gets that owner when it has none
  • actions.assign.agent_idstring | nullrequired
    null = the next agent in turn (online first, fewest open chats)
  • actions.messagesarray of object
    Messages to send (a follow-up sequence)
    Up to 5 items
  • actions.messages[].delay_minutesintegerrequired
    0 – 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 opens
  • actions.messages[].textstringrequired
    Personalisation tokens such as {{first_name|there}} work
    Up to 4 000 characters
  • actions.stop_on_replyboolean
    Messages still waiting are cancelled when the customer writes (default true)
  • actions.once_daysinteger
    Actions run at most once per chat in this many days (1–365, default 30)

Responses

  • 200Saved
    Response fields
    • ruleobjectrequired
    • rule.idstringrequired
    • rule.namestringrequired
    • rule.enabledbooleanrequired
    • rule.triggerstringrequired
      One of: keyword, first_message, store_event, inactive, ai, label_added
    • rule.configobjectrequired
    • rule.config.keywordsarray of string
      keyword: words or phrases, matched at the start of a word (harga also finds harganya), accents and case ignored
    • rule.config.matchstring
      keyword: any (default) or all keywords
      One of: any, all
    • rule.config.eventsarray of string
      store_event: which store events
    • rule.config.daysinteger
      inactive: days without a message (1–365)
    • rule.config.instructionstring
      ai: when the rule applies, in plain words, e.g. "the customer asks for a price or wants to order"
    • rule.config.labelsarray of string
      label_added: the rule runs when one of these labels is put on a chat
    • rule.add_labelsarray of stringrequired
    • rule.remove_labelsarray of stringrequired
    • rule.set_stagestring | nullrequired
      Lead stage to move the person to
    • rule.session_idsarray of string | nullrequired
      Only these devices (null = all)
    • rule.actionsobjectrequired
    • rule.actions.assignobject | null
      Assign the chat to a CS agent; the lead gets that owner when it has none
    • rule.actions.assign.agent_idstring | nullrequired
      null = the next agent in turn (online first, fewest open chats)
    • rule.actions.messagesarray of object
      Messages to send (a follow-up sequence)
      Up to 5 items
    • rule.actions.messages[].delay_minutesintegerrequired
      0 – 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 opens
    • rule.actions.messages[].textstringrequired
      Personalisation tokens such as {{first_name|there}} work
      Up to 4 000 characters
    • rule.actions.stop_on_replyboolean
      Messages still waiting are cancelled when the customer writes (default true)
    • rule.actions.once_daysinteger
      Actions run at most once per chat in this many days (1–365, default 30)
    • rule.fire_countintegerrequired
    • rule.last_fired_atinteger | nullrequired
      Unix time in milliseconds, or null
    • rule.created_atintegerrequired
      Unix time in milliseconds
    • rule.updated_atintegerrequired
      Unix 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)
Request
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))
}
Response 200
{
  "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

DEL/v1/labels/rules/{id}

Labels the rule already applied stay where they are; its messages still waiting to be sent are cancelled.

Path parameters

  • idstringrequired
    Rule 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)
Request
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))
}
Response 200
{
  "ok": true
}

The leads board

GET/v1/leads

People 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

  • labelstring
  • qstring
  • ownerstring
  • duestring
    One of: 1
  • sourcestring

Responses

  • 200Board
    Response fields
    • stagesarray of objectrequired
    • stages[].idstringrequired
    • stages[].namestringrequired
    • stages[].colorstringrequired
    • stages[].kindstringrequired
      won / lost stages close a lead (reports)
      One of: open, won, lost
    • leadsarray of objectrequired
    • leads[].contact_idstringrequired
    • leads[].namestring | nullrequired
    • leads[].phonestringrequired
    • leads[].stagestring | nullrequired
    • leads[].labelsarray of objectrequired
    • leads[].labels[].namestringrequired
    • leads[].labels[].colorstringrequired
    • leads[].stage_updated_atinteger | nullrequired
      Unix time in milliseconds, or null
    • leads[].deal_valuenumber | nullrequired
      In the lead currency, major units (49.5 = 49.50)
    • leads[].owner_agent_idstring | nullrequired
    • leads[].owner_namestring | nullrequired
    • leads[].follow_up_atinteger | nullrequired
      Unix time in milliseconds, or null
    • leads[].follow_up_notestring | nullrequired
    • leads[].session_idstring | nullrequired
    • leads[].chat_idstring | nullrequired
    • leads[].last_messagestring | nullrequired
    • leads[].last_message_atinteger | nullrequired
      Unix time in milliseconds, or null
    • leads[].unread_countintegerrequired
    • leads[].sourceobject | null
      The click-to-WhatsApp link (and campaign tags) the person first came through; null when not through a link
    • leads[].source.namestringrequired
    • leads[].source.utm_sourcestring | nullrequired
    • leads[].source.utm_mediumstring | nullrequired
    • leads[].source.utm_campaignstring | nullrequired
    • currencystringrequired
    • agentsarray of objectrequired
    • agents[].idstringrequired
    • agents[].namestringrequired
  • 401Missing, invalid or expired credentials
Request
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))
}
Response 200
{
  "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

GET/v1/leads/weekly-summary

Every 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
    • whatsappbooleanrequired
      Send it by WhatsApp to the owner's number (from the platform sender)
    • emailbooleanrequired
      Send it to the billing notification email
    • whatsapp_tostring | nullrequired
    • email_tostring | nullrequired
      Set in Billing → Notifications
    • previewstringrequired
      This week's summary as it would be sent now
  • 401Missing, invalid or expired credentials
Request
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))
}
Response 200
{
  "whatsapp": true,
  "email": true,
  "whatsapp_to": "string",
  "email_to": "you@example.com",
  "preview": "string"
}

Turn the weekly summary on or off

PUT/v1/leads/weekly-summary

Send only what changes. Business owner only. Recorded as reports.weekly_summary.

Request body

  • whatsappboolean
  • emailboolean

Responses

  • 200Settings
    Response fields
    • whatsappbooleanrequired
      Send it by WhatsApp to the owner's number (from the platform sender)
    • emailbooleanrequired
      Send it to the billing notification email
    • whatsapp_tostring | nullrequired
    • email_tostring | nullrequired
      Set in Billing → Notifications
    • previewstringrequired
      This week's summary as it would be sent now
  • 400VALIDATION_FAILED
  • 401Missing, invalid or expired credentials
  • 403Forbidden for a customer-service agent login (Agent access is not allowed for this operation)
Request
curl -X PUT "https://api.chatkomodo.com/v1/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))
}
Response 200
{
  "whatsapp": true,
  "email": true,
  "whatsapp_to": "string",
  "email_to": "you@example.com",
  "preview": "string"
}

Send the weekly summary now (test)

POST/v1/leads/weekly-summary/test

Sends this week's summary at once through the channels that are on. At most once every 10 minutes.

Responses

  • 200Sent
    Response fields
    • sentobjectrequired
    • sent.whatsappbooleanrequired
    • sent.emailbooleanrequired
  • 401Missing, invalid or expired credentials
  • 403Forbidden for a customer-service agent login (Agent access is not allowed for this operation)
  • 429RATE_LIMITED
Request
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))
}
Response 200
{
  "sent": {
    "whatsapp": true,
    "email": true
  }
}

Leads report

GET/v1/leads/report

For 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
    One of: 7, 30, 90, 365

Responses

  • 200Report
    Response fields
    • daysintegerrequired
    • sinceintegerrequired
      Unix time in milliseconds
    • currencystringrequired
    • stagesarray of objectrequired
    • stages[].idstringrequired
    • stages[].namestringrequired
    • stages[].colorstringrequired
    • stages[].kindstringrequired
      won / lost stages close a lead (reports)
      One of: open, won, lost
    • stages[].countintegerrequired
    • stages[].valuenumberrequired
    • totalsobjectrequired
    • totals.new_leadsintegerrequired
    • totals.wonintegerrequired
    • totals.lostintegerrequired
    • totals.win_ratenumber | nullrequired
    • totals.conversionnumber | nullrequired
    • totals.avg_days_to_winnumber | nullrequired
    • totals.won_valuenumberrequired
    • totals.open_valuenumberrequired
    • totals.follow_ups_dueintegerrequired
    • totals.follow_ups_overdueintegerrequired
    • funnelarray of objectrequired
    • funnel[].idstringrequired
    • funnel[].namestringrequired
    • funnel[].colorstringrequired
    • funnel[].reachedintegerrequired
    • funnel[].ratenumber | nullrequired
      Share of the previous stage
    • seriesarray of objectrequired
    • series[].datestringrequired
    • series[].newintegerrequired
    • series[].wonintegerrequired
    • labelsarray of objectrequired
    • labels[].namestringrequired
    • labels[].colorstringrequired
    • labels[].totalintegerrequired
    • labels[].manualintegerrequired
    • labels[].ruleintegerrequired
    • labels[].aiintegerrequired
    • labels[].storeintegerrequired
    • rulesarray of objectrequired
    • rules[].idstringrequired
    • rules[].namestringrequired
    • rules[].chatsintegerrequired
    • agentsarray of objectrequired
    • agents[].idstring | nullrequired
      null = leads without an owner
    • agents[].namestring | nullrequired
    • agents[].openintegerrequired
    • agents[].wonintegerrequired
    • agents[].won_valuenumberrequired
    • agents[].overdueintegerrequired
    • sourcesarray of objectrequired
      Per click-to-WhatsApp link: chats in the period, new leads that first came through it, of them won, and their value
    • sources[].idstringrequired
    • sources[].namestringrequired
    • sources[].chatsintegerrequired
    • sources[].leadsintegerrequired
    • sources[].wonintegerrequired
    • sources[].won_valuenumberrequired
    • paymentsobjectrequired
      QRIS invoices paid in the period (sandbox excluded)
    • payments.paidintegerrequired
    • payments.amountintegerrequired
      Rupiah
  • 401Missing, invalid or expired credentials
Request
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))
}
Response 200
{
  "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)

GET/v1/leads/export

The 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

  • labelstring
  • qstring
  • ownerstring
  • duestring
    One of: 1

Responses

  • 200CSV file
  • 401Missing, invalid or expired credentials
  • 403Forbidden for a customer-service agent login (Agent access is not allowed for this operation)
Request
curl "https://api.chatkomodo.com/v1/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))
}
Response 200

text/csv — the file itself.

Import leads

POST/v1/leads/import

Puts 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 objectrequired
    Up to 2 000 items
  • rows[].phonestring | numberrequired
  • rows[].namestring
  • rows[].stagestring
  • rows[].deal_valuestring | number
  • rows[].labelsstring | array of string
  • rows[].ownerstring
  • rows[].follow_upstring
  • rows[].follow_up_notestring
  • rows[].notestring
  • default_stagestring | null

Responses

  • 200Imported
    Response fields
    • createdintegerrequired
    • updatedintegerrequired
    • failedarray of objectrequired
    • failed[].rowintegerrequired
      1-based
    • failed[].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)
Request
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))
}
Response 200
{
  "created": 1,
  "updated": 1,
  "failed": [
    {
      "row": 1,
      "error": "string"
    }
  ]
}

Set the lead currency

PUT/v1/leads/settings

The currency of deal values. Values already entered keep their amount.

Request body

  • currencystringrequired
    One of: IDR, USD, EUR, GBP, SGD, MYR, AUD, JPY, INR, PHP, THB, VND, SAR, AED

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)
Request
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))
}
Response 200
{
  "currency": "IDR"
}

Set the lead stages

PUT/v1/leads/stages

1–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 objectrequired
  • stages[].idstring
    Kept when renaming; default: from the name
  • stages[].namestringrequired
  • stages[].colorstring
  • stages[].kindstring
    One of: open, won, lost

Responses

  • 200Saved
    Response fields
    • stagesarray of objectrequired
    • stages[].idstringrequired
    • stages[].namestringrequired
    • stages[].colorstringrequired
    • stages[].kindstringrequired
      won / lost stages close a lead (reports)
      One of: open, won, lost
  • 400Body is not valid JSON (INVALID_JSON) or fails validation (VALIDATION_FAILED)
  • 401Missing, invalid or expired credentials
  • 403Forbidden for a customer-service agent login (Agent access is not allowed for this operation)
Request
curl -X PUT "https://api.chatkomodo.com/v1/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))
}
Response 200
{
  "stages": [
    {
      "id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
      "name": "Example",
      "color": "#0a7350",
      "kind": "open"
    }
  ]
}

A lead with notes and history

GET/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
    • leadobjectrequired
    • lead.contact_idstringrequired
    • lead.namestring | nullrequired
    • lead.phonestringrequired
    • lead.stagestring | nullrequired
    • lead.labelsarray of objectrequired
    • lead.labels[].namestringrequired
    • lead.labels[].colorstringrequired
    • lead.stage_updated_atinteger | nullrequired
      Unix time in milliseconds, or null
    • lead.deal_valuenumber | nullrequired
      In the lead currency, major units (49.5 = 49.50)
    • lead.owner_agent_idstring | nullrequired
    • lead.owner_namestring | nullrequired
    • lead.follow_up_atinteger | nullrequired
      Unix time in milliseconds, or null
    • lead.follow_up_notestring | nullrequired
    • lead.session_idstring | nullrequired
    • lead.chat_idstring | nullrequired
    • lead.last_messagestring | nullrequired
    • lead.last_message_atinteger | nullrequired
      Unix time in milliseconds, or null
    • lead.unread_countintegerrequired
    • lead.sourceobject | null
      The click-to-WhatsApp link (and campaign tags) the person first came through; null when not through a link
    • lead.source.namestringrequired
    • lead.source.utm_sourcestring | nullrequired
    • lead.source.utm_mediumstring | nullrequired
    • lead.source.utm_campaignstring | nullrequired
    • notesarray of objectrequired
    • notes[].idstringrequired
    • notes[].bodystringrequired
    • notes[].actorstring | nullrequired
    • notes[].created_atintegerrequired
      Unix time in milliseconds
    • historyarray of objectrequired
    • history[].labelstringrequired
      The label, or the new stage / value / owner id / follow-up time
    • history[].actionstringrequired
      One of: add, remove, stage, value, owner, follow_up
    • history[].sourcestringrequired
      link: a click-to-WhatsApp link (rule_id is the link, rule_name its name); payment: a paid QRIS invoice (rule_id is the invoice)
      One of: manual, rule, ai, store, link, payment
    • history[].rule_idstring | nullrequired
    • history[].rule_namestring | nullrequired
    • history[].actorstring | nullrequired
    • history[].atintegerrequired
      Unix time in milliseconds
    • currencystringrequired
    • stagesarray of objectrequired
    • stages[].idstringrequired
    • stages[].namestringrequired
    • stages[].colorstringrequired
    • stages[].kindstringrequired
      won / lost stages close a lead (reports)
      One of: open, won, lost
    • agentsarray of objectrequired
    • agents[].idstringrequired
    • agents[].namestringrequired
    • outcomeobject | nullrequired
      Latest loss of this lead (null: never lost)
    • outcome.activebooleanrequired
      Still lost (false after the lead moved back to an open stage)
    • outcome.lost_atintegerrequired
      Unix time in milliseconds
    • outcome.stagestring | nullrequired
    • outcome.deal_valuenumber | nullrequired
      When it was lost, lead currency
    • outcome.reasonstring | nullrequired
      The reason the team gave
      One of: price, not_now, competitor, no_reply, product, shipping, trust, slow_reply, other
    • outcome.notestring | nullrequired
    • outcome.reason_bystring | nullrequired
    • outcome.reason_atinteger | nullrequired
      Unix time in milliseconds, or null
    • outcome.guessobject | nullrequired
      A suggestion until someone confirms a reason
    • outcome.guess.reasonstringrequired
    • outcome.guess.bystring | nullrequired
      One of: ai, rules
    • outcome.guess.confidencenumber | nullrequired
    • outcome.guess.evidencestring | nullrequired
      What the customer wrote that points to it
    • outcome.summarystring | nullrequired
      AI: why the customer did not buy
    • outcome.reviewstring | nullrequired
      AI: how the business answered
    • outcome.analysisobjectrequired
    • outcome.analysis.statusstringrequired
      One of: none, queued, running, done, failed, off
    • outcome.analysis.errorstring | nullrequired
    • outcome.analysis.atinteger | nullrequired
      Unix time in milliseconds, or null
    • reviewobject | nullrequired
      How the chat was handled over the last 30 days (up to the loss for a lost lead)
    • review.messagesobjectrequired
    • review.messages.from_customerintegerrequired
    • review.messages.aiintegerrequired
    • review.messages.automaticintegerrequired
    • review.messages.teamintegerrequired
    • review.aiobjectrequired
    • review.ai.repliesintegerrequired
    • review.ai.unsureintegerrequired
      Replies where the AI did not know
    • review.ai.handoffsintegerrequired
    • review.ai.unansweredarray of objectrequired
    • review.ai.unanswered[].questionstringrequired
    • review.ai.unanswered[].countintegerrequired
    • review.ai.unanswered[].statusstringrequired
    • review.waitobjectrequired
    • review.wait.median_minnumber | nullrequired
    • review.wait.longest_minnumber | nullrequired
    • review.wait.unansweredintegerrequired
      Customer messages never answered
    • review.lastobject | nullrequired
    • review.last.fromstringrequired
      One of: customer, ai, automatic, team
    • review.last.atintegerrequired
      Unix time in milliseconds
    • review.flagsarray of stringrequired
    • lost_reasonsarray of stringrequired
  • 401Missing, invalid or expired credentials
  • 404Contact not found, or it belongs to another tenant (NOT_FOUND)
Request
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))
}
Response 200
{
  "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

PATCH/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 | null
  • deal_valuenumber | null
  • owner_agent_idstring | null
  • follow_up_atinteger | null
  • follow_up_notestring | null
    Up to 300 characters
  • lost_reasonstring | null
    Why it was lost; used when the lead is (or moves) in a lost stage
    One of: price, not_now, competitor, no_reply, product, shipping, trust, slow_reply, other
  • lost_notestring | null
    Up to 500 characters

Responses

  • 200Saved
    Response fields
    • leadobjectrequired
    • lead.contact_idstringrequired
    • lead.namestring | nullrequired
    • lead.phonestringrequired
    • lead.stagestring | nullrequired
    • lead.labelsarray of objectrequired
    • lead.labels[].namestringrequired
    • lead.labels[].colorstringrequired
    • lead.stage_updated_atinteger | nullrequired
      Unix time in milliseconds, or null
    • lead.deal_valuenumber | nullrequired
      In the lead currency, major units (49.5 = 49.50)
    • lead.owner_agent_idstring | nullrequired
    • lead.owner_namestring | nullrequired
    • lead.follow_up_atinteger | nullrequired
      Unix time in milliseconds, or null
    • lead.follow_up_notestring | nullrequired
    • lead.session_idstring | nullrequired
    • lead.chat_idstring | nullrequired
    • lead.last_messagestring | nullrequired
    • lead.last_message_atinteger | nullrequired
      Unix time in milliseconds, or null
    • lead.unread_countintegerrequired
    • lead.sourceobject | null
      The click-to-WhatsApp link (and campaign tags) the person first came through; null when not through a link
    • lead.source.namestringrequired
    • lead.source.utm_sourcestring | nullrequired
    • lead.source.utm_mediumstring | nullrequired
    • lead.source.utm_campaignstring | nullrequired
    • notesarray of objectrequired
    • notes[].idstringrequired
    • notes[].bodystringrequired
    • notes[].actorstring | nullrequired
    • notes[].created_atintegerrequired
      Unix time in milliseconds
    • historyarray of objectrequired
    • history[].labelstringrequired
      The label, or the new stage / value / owner id / follow-up time
    • history[].actionstringrequired
      One of: add, remove, stage, value, owner, follow_up
    • history[].sourcestringrequired
      link: a click-to-WhatsApp link (rule_id is the link, rule_name its name); payment: a paid QRIS invoice (rule_id is the invoice)
      One of: manual, rule, ai, store, link, payment
    • history[].rule_idstring | nullrequired
    • history[].rule_namestring | nullrequired
    • history[].actorstring | nullrequired
    • history[].atintegerrequired
      Unix time in milliseconds
    • currencystringrequired
    • stagesarray of objectrequired
    • stages[].idstringrequired
    • stages[].namestringrequired
    • stages[].colorstringrequired
    • stages[].kindstringrequired
      won / lost stages close a lead (reports)
      One of: open, won, lost
    • agentsarray of objectrequired
    • agents[].idstringrequired
    • agents[].namestringrequired
    • outcomeobject | nullrequired
      Latest loss of this lead (null: never lost)
    • outcome.activebooleanrequired
      Still lost (false after the lead moved back to an open stage)
    • outcome.lost_atintegerrequired
      Unix time in milliseconds
    • outcome.stagestring | nullrequired
    • outcome.deal_valuenumber | nullrequired
      When it was lost, lead currency
    • outcome.reasonstring | nullrequired
      The reason the team gave
      One of: price, not_now, competitor, no_reply, product, shipping, trust, slow_reply, other
    • outcome.notestring | nullrequired
    • outcome.reason_bystring | nullrequired
    • outcome.reason_atinteger | nullrequired
      Unix time in milliseconds, or null
    • outcome.guessobject | nullrequired
      A suggestion until someone confirms a reason
    • outcome.guess.reasonstringrequired
    • outcome.guess.bystring | nullrequired
      One of: ai, rules
    • outcome.guess.confidencenumber | nullrequired
    • outcome.guess.evidencestring | nullrequired
      What the customer wrote that points to it
    • outcome.summarystring | nullrequired
      AI: why the customer did not buy
    • outcome.reviewstring | nullrequired
      AI: how the business answered
    • outcome.analysisobjectrequired
    • outcome.analysis.statusstringrequired
      One of: none, queued, running, done, failed, off
    • outcome.analysis.errorstring | nullrequired
    • outcome.analysis.atinteger | nullrequired
      Unix time in milliseconds, or null
    • reviewobject | nullrequired
      How the chat was handled over the last 30 days (up to the loss for a lost lead)
    • review.messagesobjectrequired
    • review.messages.from_customerintegerrequired
    • review.messages.aiintegerrequired
    • review.messages.automaticintegerrequired
    • review.messages.teamintegerrequired
    • review.aiobjectrequired
    • review.ai.repliesintegerrequired
    • review.ai.unsureintegerrequired
      Replies where the AI did not know
    • review.ai.handoffsintegerrequired
    • review.ai.unansweredarray of objectrequired
    • review.ai.unanswered[].questionstringrequired
    • review.ai.unanswered[].countintegerrequired
    • review.ai.unanswered[].statusstringrequired
    • review.waitobjectrequired
    • review.wait.median_minnumber | nullrequired
    • review.wait.longest_minnumber | nullrequired
    • review.wait.unansweredintegerrequired
      Customer messages never answered
    • review.lastobject | nullrequired
    • review.last.fromstringrequired
      One of: customer, ai, automatic, team
    • review.last.atintegerrequired
      Unix time in milliseconds
    • review.flagsarray of stringrequired
    • lost_reasonsarray of stringrequired
    • okbooleanrequired
  • 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)
Request
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))
}
Response 200
{
  "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

POST/v1/leads/{contactId}/notes

A note for the team (not sent to the customer).

Path parameters

  • contactIdstringrequired

Request body

  • bodystringrequired
    Up to 2 000 characters

Responses

  • 201Added
    Response fields
    • noteobjectrequired
    • note.idstringrequired
    • note.bodystringrequired
    • note.actorstring | nullrequired
    • note.created_atintegerrequired
      Unix 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)
Request
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))
}
Response 201
{
  "note": {
    "id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
    "body": "Hi Sam, your order has shipped.",
    "actor": "string",
    "created_at": 1767225600000
  }
}

Delete a note

DEL/v1/leads/{contactId}/notes/{noteId}

Agents can delete only their own notes.

Path parameters

  • contactIdstringrequired
  • noteIdstringrequired

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)
Request
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))
}
Response 200
{
  "ok": true
}

Say why a lead was lost

PUT/v1/leads/{contactId}/lost-reason

For 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 | nullrequired
    One of: price, not_now, competitor, no_reply, product, shipping, trust, slow_reply, other
  • notestring | null
    Up to 500 characters

Responses

  • 200Lead
    Response fields
    • leadobjectrequired
    • lead.contact_idstringrequired
    • lead.namestring | nullrequired
    • lead.phonestringrequired
    • lead.stagestring | nullrequired
    • lead.labelsarray of objectrequired
    • lead.labels[].namestringrequired
    • lead.labels[].colorstringrequired
    • lead.stage_updated_atinteger | nullrequired
      Unix time in milliseconds, or null
    • lead.deal_valuenumber | nullrequired
      In the lead currency, major units (49.5 = 49.50)
    • lead.owner_agent_idstring | nullrequired
    • lead.owner_namestring | nullrequired
    • lead.follow_up_atinteger | nullrequired
      Unix time in milliseconds, or null
    • lead.follow_up_notestring | nullrequired
    • lead.session_idstring | nullrequired
    • lead.chat_idstring | nullrequired
    • lead.last_messagestring | nullrequired
    • lead.last_message_atinteger | nullrequired
      Unix time in milliseconds, or null
    • lead.unread_countintegerrequired
    • lead.sourceobject | null
      The click-to-WhatsApp link (and campaign tags) the person first came through; null when not through a link
    • lead.source.namestringrequired
    • lead.source.utm_sourcestring | nullrequired
    • lead.source.utm_mediumstring | nullrequired
    • lead.source.utm_campaignstring | nullrequired
    • notesarray of objectrequired
    • notes[].idstringrequired
    • notes[].bodystringrequired
    • notes[].actorstring | nullrequired
    • notes[].created_atintegerrequired
      Unix time in milliseconds
    • historyarray of objectrequired
    • history[].labelstringrequired
      The label, or the new stage / value / owner id / follow-up time
    • history[].actionstringrequired
      One of: add, remove, stage, value, owner, follow_up
    • history[].sourcestringrequired
      link: a click-to-WhatsApp link (rule_id is the link, rule_name its name); payment: a paid QRIS invoice (rule_id is the invoice)
      One of: manual, rule, ai, store, link, payment
    • history[].rule_idstring | nullrequired
    • history[].rule_namestring | nullrequired
    • history[].actorstring | nullrequired
    • history[].atintegerrequired
      Unix time in milliseconds
    • currencystringrequired
    • stagesarray of objectrequired
    • stages[].idstringrequired
    • stages[].namestringrequired
    • stages[].colorstringrequired
    • stages[].kindstringrequired
      won / lost stages close a lead (reports)
      One of: open, won, lost
    • agentsarray of objectrequired
    • agents[].idstringrequired
    • agents[].namestringrequired
    • outcomeobject | nullrequired
      Latest loss of this lead (null: never lost)
    • outcome.activebooleanrequired
      Still lost (false after the lead moved back to an open stage)
    • outcome.lost_atintegerrequired
      Unix time in milliseconds
    • outcome.stagestring | nullrequired
    • outcome.deal_valuenumber | nullrequired
      When it was lost, lead currency
    • outcome.reasonstring | nullrequired
      The reason the team gave
      One of: price, not_now, competitor, no_reply, product, shipping, trust, slow_reply, other
    • outcome.notestring | nullrequired
    • outcome.reason_bystring | nullrequired
    • outcome.reason_atinteger | nullrequired
      Unix time in milliseconds, or null
    • outcome.guessobject | nullrequired
      A suggestion until someone confirms a reason
    • outcome.guess.reasonstringrequired
    • outcome.guess.bystring | nullrequired
      One of: ai, rules
    • outcome.guess.confidencenumber | nullrequired
    • outcome.guess.evidencestring | nullrequired
      What the customer wrote that points to it
    • outcome.summarystring | nullrequired
      AI: why the customer did not buy
    • outcome.reviewstring | nullrequired
      AI: how the business answered
    • outcome.analysisobjectrequired
    • outcome.analysis.statusstringrequired
      One of: none, queued, running, done, failed, off
    • outcome.analysis.errorstring | nullrequired
    • outcome.analysis.atinteger | nullrequired
      Unix time in milliseconds, or null
    • reviewobject | nullrequired
      How the chat was handled over the last 30 days (up to the loss for a lost lead)
    • review.messagesobjectrequired
    • review.messages.from_customerintegerrequired
    • review.messages.aiintegerrequired
    • review.messages.automaticintegerrequired
    • review.messages.teamintegerrequired
    • review.aiobjectrequired
    • review.ai.repliesintegerrequired
    • review.ai.unsureintegerrequired
      Replies where the AI did not know
    • review.ai.handoffsintegerrequired
    • review.ai.unansweredarray of objectrequired
    • review.ai.unanswered[].questionstringrequired
    • review.ai.unanswered[].countintegerrequired
    • review.ai.unanswered[].statusstringrequired
    • review.waitobjectrequired
    • review.wait.median_minnumber | nullrequired
    • review.wait.longest_minnumber | nullrequired
    • review.wait.unansweredintegerrequired
      Customer messages never answered
    • review.lastobject | nullrequired
    • review.last.fromstringrequired
      One of: customer, ai, automatic, team
    • review.last.atintegerrequired
      Unix time in milliseconds
    • review.flagsarray of stringrequired
    • lost_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)
Request
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))
}
Response 200
{
  "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

POST/v1/leads/{contactId}/lost-reason/analyze

The 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
    • leadobjectrequired
    • lead.contact_idstringrequired
    • lead.namestring | nullrequired
    • lead.phonestringrequired
    • lead.stagestring | nullrequired
    • lead.labelsarray of objectrequired
    • lead.labels[].namestringrequired
    • lead.labels[].colorstringrequired
    • lead.stage_updated_atinteger | nullrequired
      Unix time in milliseconds, or null
    • lead.deal_valuenumber | nullrequired
      In the lead currency, major units (49.5 = 49.50)
    • lead.owner_agent_idstring | nullrequired
    • lead.owner_namestring | nullrequired
    • lead.follow_up_atinteger | nullrequired
      Unix time in milliseconds, or null
    • lead.follow_up_notestring | nullrequired
    • lead.session_idstring | nullrequired
    • lead.chat_idstring | nullrequired
    • lead.last_messagestring | nullrequired
    • lead.last_message_atinteger | nullrequired
      Unix time in milliseconds, or null
    • lead.unread_countintegerrequired
    • lead.sourceobject | null
      The click-to-WhatsApp link (and campaign tags) the person first came through; null when not through a link
    • lead.source.namestringrequired
    • lead.source.utm_sourcestring | nullrequired
    • lead.source.utm_mediumstring | nullrequired
    • lead.source.utm_campaignstring | nullrequired
    • notesarray of objectrequired
    • notes[].idstringrequired
    • notes[].bodystringrequired
    • notes[].actorstring | nullrequired
    • notes[].created_atintegerrequired
      Unix time in milliseconds
    • historyarray of objectrequired
    • history[].labelstringrequired
      The label, or the new stage / value / owner id / follow-up time
    • history[].actionstringrequired
      One of: add, remove, stage, value, owner, follow_up
    • history[].sourcestringrequired
      link: a click-to-WhatsApp link (rule_id is the link, rule_name its name); payment: a paid QRIS invoice (rule_id is the invoice)
      One of: manual, rule, ai, store, link, payment
    • history[].rule_idstring | nullrequired
    • history[].rule_namestring | nullrequired
    • history[].actorstring | nullrequired
    • history[].atintegerrequired
      Unix time in milliseconds
    • currencystringrequired
    • stagesarray of objectrequired
    • stages[].idstringrequired
    • stages[].namestringrequired
    • stages[].colorstringrequired
    • stages[].kindstringrequired
      won / lost stages close a lead (reports)
      One of: open, won, lost
    • agentsarray of objectrequired
    • agents[].idstringrequired
    • agents[].namestringrequired
    • outcomeobject | nullrequired
      Latest loss of this lead (null: never lost)
    • outcome.activebooleanrequired
      Still lost (false after the lead moved back to an open stage)
    • outcome.lost_atintegerrequired
      Unix time in milliseconds
    • outcome.stagestring | nullrequired
    • outcome.deal_valuenumber | nullrequired
      When it was lost, lead currency
    • outcome.reasonstring | nullrequired
      The reason the team gave
      One of: price, not_now, competitor, no_reply, product, shipping, trust, slow_reply, other
    • outcome.notestring | nullrequired
    • outcome.reason_bystring | nullrequired
    • outcome.reason_atinteger | nullrequired
      Unix time in milliseconds, or null
    • outcome.guessobject | nullrequired
      A suggestion until someone confirms a reason
    • outcome.guess.reasonstringrequired
    • outcome.guess.bystring | nullrequired
      One of: ai, rules
    • outcome.guess.confidencenumber | nullrequired
    • outcome.guess.evidencestring | nullrequired
      What the customer wrote that points to it
    • outcome.summarystring | nullrequired
      AI: why the customer did not buy
    • outcome.reviewstring | nullrequired
      AI: how the business answered
    • outcome.analysisobjectrequired
    • outcome.analysis.statusstringrequired
      One of: none, queued, running, done, failed, off
    • outcome.analysis.errorstring | nullrequired
    • outcome.analysis.atinteger | nullrequired
      Unix time in milliseconds, or null
    • reviewobject | nullrequired
      How the chat was handled over the last 30 days (up to the loss for a lost lead)
    • review.messagesobjectrequired
    • review.messages.from_customerintegerrequired
    • review.messages.aiintegerrequired
    • review.messages.automaticintegerrequired
    • review.messages.teamintegerrequired
    • review.aiobjectrequired
    • review.ai.repliesintegerrequired
    • review.ai.unsureintegerrequired
      Replies where the AI did not know
    • review.ai.handoffsintegerrequired
    • review.ai.unansweredarray of objectrequired
    • review.ai.unanswered[].questionstringrequired
    • review.ai.unanswered[].countintegerrequired
    • review.ai.unanswered[].statusstringrequired
    • review.waitobjectrequired
    • review.wait.median_minnumber | nullrequired
    • review.wait.longest_minnumber | nullrequired
    • review.wait.unansweredintegerrequired
      Customer messages never answered
    • review.lastobject | nullrequired
    • review.last.fromstringrequired
      One of: customer, ai, automatic, team
    • review.last.atintegerrequired
      Unix time in milliseconds
    • review.flagsarray of stringrequired
    • lost_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)
Request
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))
}
Response 200
{
  "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

GET/v1/leads/lessons

Leads 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
    One of: 7, 30, 90, 365

Responses

  • 200Lessons
    Response fields
    • daysintegerrequired
    • sinceintegerrequired
      Unix time in milliseconds
    • currencystringrequired
    • totalsobjectrequired
    • totals.lostintegerrequired
    • totals.lost_value_minorintegerrequired
    • totals.lost_valuenumber | nullrequired
    • totals.confirmedintegerrequired
    • totals.guessedintegerrequired
    • totals.unknownintegerrequired
    • totals.reopenedintegerrequired
    • reasonsarray of objectrequired
    • reasons[].idstringrequired
      One of: price, not_now, competitor, no_reply, product, shipping, trust, slow_reply, other
    • reasons[].confirmedintegerrequired
    • reasons[].guessedintegerrequired
    • reasons[].value_minorintegerrequired
    • reasons[].valuenumber | nullrequired
    • agentsarray of objectrequired
    • agents[].idstring | nullrequired
    • agents[].namestring | nullrequired
    • agents[].lostintegerrequired
    • agents[].top_reasonstring | nullrequired
    • sourcesarray of objectrequired
    • sources[].idstringrequired
    • sources[].namestringrequired
    • sources[].lostintegerrequired
    • sources[].top_reasonstring | nullrequired
    • handlingobjectrequired
    • handling.analysedintegerrequired
    • handling.slow_first_replyintegerrequired
    • handling.never_answeredintegerrequired
    • handling.ai_unsureintegerrequired
    • handling.handed_overintegerrequired
    • questionsarray of objectrequired
    • questions[].questionstringrequired
    • questions[].countintegerrequired
    • suggestionsarray of objectrequired
    • suggestions[].idstringrequired
    • suggestions[].kindstringrequired
      One of: faq, guidance
    • suggestions[].questionstring | nullrequired
      faq: the customer question
    • suggestions[].textstring | nullrequired
      faq: the answer (may be empty until written); guidance: the instruction
    • suggestions[].reasonstring | nullrequired
    • suggestions[].countintegerrequired
      Lost leads that suggested it
    • suggestions[].contactsarray of stringrequired
    • suggestions[].statusstringrequired
      One of: proposed, applied, dismissed
    • suggestions[].faq_idstring | nullrequired
    • suggestions[].created_atintegerrequired
      Unix time in milliseconds
    • suggestions[].updated_atintegerrequired
      Unix time in milliseconds
    • suggestions[].applied_atinteger | nullrequired
      Unix time in milliseconds, or null
    • appliedarray of objectrequired
    • applied[].idstringrequired
    • applied[].kindstringrequired
      One of: faq, guidance
    • applied[].questionstring | nullrequired
      faq: the customer question
    • applied[].textstring | nullrequired
      faq: the answer (may be empty until written); guidance: the instruction
    • applied[].reasonstring | nullrequired
    • applied[].countintegerrequired
      Lost leads that suggested it
    • applied[].contactsarray of stringrequired
    • applied[].statusstringrequired
      One of: proposed, applied, dismissed
    • applied[].faq_idstring | nullrequired
    • applied[].created_atintegerrequired
      Unix time in milliseconds
    • applied[].updated_atintegerrequired
      Unix time in milliseconds
    • applied[].applied_atinteger | nullrequired
      Unix time in milliseconds, or null
    • auto_analyzebooleanrequired
    • ai_availablebooleanrequired
  • 401Missing, invalid or expired credentials
Request
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))
}
Response 200
{
  "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

PUT/v1/leads/lessons/settings

On (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)
Request
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))
}
Response 200
{
  "auto_analyze": true
}

Apply a lesson

POST/v1/leads/lessons/{id}/apply

A 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

  • questionstring
    Up to 300 characters
  • textstring
    Up to 2 000 characters

Responses

  • 200Applied
    Response fields
    • lessonobjectrequired
    • lesson.idstringrequired
    • lesson.kindstringrequired
      One of: faq, guidance
    • lesson.questionstring | nullrequired
      faq: the customer question
    • lesson.textstring | nullrequired
      faq: the answer (may be empty until written); guidance: the instruction
    • lesson.reasonstring | nullrequired
    • lesson.countintegerrequired
      Lost leads that suggested it
    • lesson.contactsarray of stringrequired
    • lesson.statusstringrequired
      One of: proposed, applied, dismissed
    • lesson.faq_idstring | nullrequired
    • lesson.created_atintegerrequired
      Unix time in milliseconds
    • lesson.updated_atintegerrequired
      Unix time in milliseconds
    • lesson.applied_atinteger | nullrequired
      Unix 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)
Request
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))
}
Response 200
{
  "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

POST/v1/leads/lessons/{id}/dismiss

It 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)
Request
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))
}
Response 200
{
  "ok": true
}

Stop using an applied lesson

DEL/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)
Request
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))
}
Response 200
{
  "ok": true
}

Labels and stage of a chat

GET/v1/sessions/{sid}/inbox/{chatId}/labels

A 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

  • sidstringrequired
    Session (device) id
  • chatIdstringrequired
    Chat id (JID), URL-encoded

Responses

  • 200Labels
    Response fields
    • labelsarray of objectrequired
    • labels[].namestringrequired
    • labels[].colorstringrequired
    • stagestring | nullrequired
      Lead stage (chats with a person only)
    • stagesarray of objectrequired
    • stages[].idstringrequired
    • stages[].namestringrequired
    • stages[].colorstringrequired
    • stages[].kindstringrequired
      won / lost stages close a lead (reports)
      One of: open, won, lost
    • personbooleanrequired
      The chat is with a person (labels live on their contact)
    • historyarray of objectrequired
      Latest 20 changes
    • history[].labelstringrequired
      The label, or the new stage / value / owner id / follow-up time
    • history[].actionstringrequired
      One of: add, remove, stage, value, owner, follow_up
    • history[].sourcestringrequired
      link: a click-to-WhatsApp link (rule_id is the link, rule_name its name); payment: a paid QRIS invoice (rule_id is the invoice)
      One of: manual, rule, ai, store, link, payment
    • history[].rule_idstring | nullrequired
    • history[].rule_namestring | nullrequired
    • history[].actorstring | nullrequired
    • history[].atintegerrequired
      Unix time in milliseconds
    • leadobject | nullrequired
      The person's lead details (null: not a contact yet)
    • lead.contact_idstringrequired
    • lead.deal_valuenumber | nullrequired
    • lead.currencystringrequired
    • lead.owner_agent_idstring | nullrequired
    • lead.owner_namestring | nullrequired
    • lead.follow_up_atinteger | nullrequired
      Unix time in milliseconds, or null
    • lead.follow_up_notestring | nullrequired
  • 401Missing, invalid or expired credentials
Request
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))
}
Response 200
{
  "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

POST/v1/sessions/{sid}/inbox/{chatId}/labels

Adds 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

  • sidstringrequired
    Session (device) id
  • chatIdstringrequired
    Chat id (JID), URL-encoded

Request body

  • addarray of string
  • removearray of string

Responses

  • 200Saved
    Response fields
    • labelsarray of objectrequired
    • labels[].namestringrequired
    • labels[].colorstringrequired
    • stagestring | nullrequired
      Lead stage (chats with a person only)
    • stagesarray of objectrequired
    • stages[].idstringrequired
    • stages[].namestringrequired
    • stages[].colorstringrequired
    • stages[].kindstringrequired
      won / lost stages close a lead (reports)
      One of: open, won, lost
    • personbooleanrequired
      The chat is with a person (labels live on their contact)
    • historyarray of objectrequired
      Latest 20 changes
    • history[].labelstringrequired
      The label, or the new stage / value / owner id / follow-up time
    • history[].actionstringrequired
      One of: add, remove, stage, value, owner, follow_up
    • history[].sourcestringrequired
      link: a click-to-WhatsApp link (rule_id is the link, rule_name its name); payment: a paid QRIS invoice (rule_id is the invoice)
      One of: manual, rule, ai, store, link, payment
    • history[].rule_idstring | nullrequired
    • history[].rule_namestring | nullrequired
    • history[].actorstring | nullrequired
    • history[].atintegerrequired
      Unix time in milliseconds
    • leadobject | nullrequired
      The person's lead details (null: not a contact yet)
    • lead.contact_idstringrequired
    • lead.deal_valuenumber | nullrequired
    • lead.currencystringrequired
    • lead.owner_agent_idstring | nullrequired
    • lead.owner_namestring | nullrequired
    • lead.follow_up_atinteger | nullrequired
      Unix time in milliseconds, or null
    • lead.follow_up_notestring | nullrequired
  • 400Invalid body or more than 20 labels (LIMIT_REACHED)
  • 401Missing, invalid or expired credentials
Request
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))
}
Response 200
{
  "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

PUT/v1/sessions/{sid}/inbox/{chatId}/labels

Labelling 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

  • sidstringrequired
    Session (device) id
  • chatIdstringrequired
    Chat id (JID), URL-encoded

Request body

  • labelsarray of stringrequired
    Up to 20 items

Responses

  • 200Saved
    Response fields
    • labelsarray of objectrequired
    • labels[].namestringrequired
    • labels[].colorstringrequired
    • stagestring | nullrequired
      Lead stage (chats with a person only)
    • stagesarray of objectrequired
    • stages[].idstringrequired
    • stages[].namestringrequired
    • stages[].colorstringrequired
    • stages[].kindstringrequired
      won / lost stages close a lead (reports)
      One of: open, won, lost
    • personbooleanrequired
      The chat is with a person (labels live on their contact)
    • historyarray of objectrequired
      Latest 20 changes
    • history[].labelstringrequired
      The label, or the new stage / value / owner id / follow-up time
    • history[].actionstringrequired
      One of: add, remove, stage, value, owner, follow_up
    • history[].sourcestringrequired
      link: a click-to-WhatsApp link (rule_id is the link, rule_name its name); payment: a paid QRIS invoice (rule_id is the invoice)
      One of: manual, rule, ai, store, link, payment
    • history[].rule_idstring | nullrequired
    • history[].rule_namestring | nullrequired
    • history[].actorstring | nullrequired
    • history[].atintegerrequired
      Unix time in milliseconds
    • leadobject | nullrequired
      The person's lead details (null: not a contact yet)
    • lead.contact_idstringrequired
    • lead.deal_valuenumber | nullrequired
    • lead.currencystringrequired
    • lead.owner_agent_idstring | nullrequired
    • lead.owner_namestring | nullrequired
    • lead.follow_up_atinteger | nullrequired
      Unix time in milliseconds, or null
    • lead.follow_up_notestring | nullrequired
  • 400Invalid body or more than 20 labels (LIMIT_REACHED)
  • 401Missing, invalid or expired credentials
Request
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))
}
Response 200
{
  "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

PUT/v1/sessions/{sid}/inbox/{chatId}/stage

Puts the person on the leads board in this stage (null takes them off). The person is saved as a contact when needed.

Path parameters

  • sidstringrequired
    Session (device) id
  • chatIdstringrequired
    Chat id (JID), URL-encoded

Request body

  • stagestring | nullrequired

Responses

  • 200Saved
    Response fields
    • labelsarray of objectrequired
    • labels[].namestringrequired
    • labels[].colorstringrequired
    • stagestring | nullrequired
      Lead stage (chats with a person only)
    • stagesarray of objectrequired
    • stages[].idstringrequired
    • stages[].namestringrequired
    • stages[].colorstringrequired
    • stages[].kindstringrequired
      won / lost stages close a lead (reports)
      One of: open, won, lost
    • personbooleanrequired
      The chat is with a person (labels live on their contact)
    • historyarray of objectrequired
      Latest 20 changes
    • history[].labelstringrequired
      The label, or the new stage / value / owner id / follow-up time
    • history[].actionstringrequired
      One of: add, remove, stage, value, owner, follow_up
    • history[].sourcestringrequired
      link: a click-to-WhatsApp link (rule_id is the link, rule_name its name); payment: a paid QRIS invoice (rule_id is the invoice)
      One of: manual, rule, ai, store, link, payment
    • history[].rule_idstring | nullrequired
    • history[].rule_namestring | nullrequired
    • history[].actorstring | nullrequired
    • history[].atintegerrequired
      Unix time in milliseconds
    • leadobject | nullrequired
      The person's lead details (null: not a contact yet)
    • lead.contact_idstringrequired
    • lead.deal_valuenumber | nullrequired
    • lead.currencystringrequired
    • lead.owner_agent_idstring | nullrequired
    • lead.owner_namestring | nullrequired
    • lead.follow_up_atinteger | nullrequired
      Unix time in milliseconds, or null
    • lead.follow_up_notestring | nullrequired
  • 400Not a chat with a person, or an unknown stage (VALIDATION_FAILED)
  • 401Missing, invalid or expired credentials
Request
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))
}
Response 200
{
  "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

POST/v1/sessions/{sid}/inbox/{chatId}/labels/ai

Lets 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

  • sidstringrequired
    Session (device) id
  • chatIdstringrequired
    Chat id (JID), URL-encoded

Responses

  • 200Checked
    Response fields
    • labelsarray of objectrequired
    • labels[].namestringrequired
    • labels[].colorstringrequired
    • stagestring | nullrequired
      Lead stage (chats with a person only)
    • stagesarray of objectrequired
    • stages[].idstringrequired
    • stages[].namestringrequired
    • stages[].colorstringrequired
    • stages[].kindstringrequired
      won / lost stages close a lead (reports)
      One of: open, won, lost
    • personbooleanrequired
      The chat is with a person (labels live on their contact)
    • historyarray of objectrequired
      Latest 20 changes
    • history[].labelstringrequired
      The label, or the new stage / value / owner id / follow-up time
    • history[].actionstringrequired
      One of: add, remove, stage, value, owner, follow_up
    • history[].sourcestringrequired
      link: a click-to-WhatsApp link (rule_id is the link, rule_name its name); payment: a paid QRIS invoice (rule_id is the invoice)
      One of: manual, rule, ai, store, link, payment
    • history[].rule_idstring | nullrequired
    • history[].rule_namestring | nullrequired
    • history[].actorstring | nullrequired
    • history[].atintegerrequired
      Unix time in milliseconds
    • leadobject | nullrequired
      The person's lead details (null: not a contact yet)
    • lead.contact_idstringrequired
    • lead.deal_valuenumber | nullrequired
    • lead.currencystringrequired
    • lead.owner_agent_idstring | nullrequired
    • lead.owner_namestring | nullrequired
    • lead.follow_up_atinteger | nullrequired
      Unix time in milliseconds, or null
    • lead.follow_up_notestring | nullrequired
    • firedarray of stringrequired
      Ids 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)
Request
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))
}
Response 200
{
  "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"
  ]
}