ChatKomodo Docs Home Sign in

API reference · Conversations

Push notifications

Web Push for the dashboard: a browser subscribes and gets a notification when a customer writes. For dashboard logins (owner and agents).

Get the push public key

GET/v1/push/key

The platform's VAPID public key, to pass as applicationServerKey to PushManager.subscribe().

Responses

  • 200Key
    Response fields
    • public_keystringrequired
      base64url, uncompressed P-256 point
Request
curl "https://api.chatkomodo.com/v1/push/key" \
  -H "Authorization: Bearer $CHATKOMODO_API_KEY"
const res = await fetch('https://api.chatkomodo.com/v1/push/key', {
  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/push/key",
    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/push/key', [
    'headers' => [
        'Authorization' => 'Bearer ' . getenv('CHATKOMODO_API_KEY'),
    ],
]);

print_r(json_decode((string) $res->getBody(), true));
Response 200
{
  "public_key": "uploads/abc123.jpg"
}

Turn on notifications for a browser

POST/v1/push/subscribe

Notify this browser when a customer writes in a 1:1 chat: the owner for every chat, an agent for chats assigned to them or unassigned. At most one notification per chat and device every 30 s; the preview is encrypted for the device. Dashboard logins only.

Request body

  • endpointstring (uri)required
    From PushManager.subscribe(); only the browsers' push services are accepted
  • keysobjectrequired
  • keys.p256dhstringrequired
  • keys.authstringrequired

Responses

  • 201Subscribed
    Response fields
    • okbooleanrequired
  • 400VALIDATION_FAILED
  • 403Not a dashboard login
Request
curl -X POST "https://api.chatkomodo.com/v1/push/subscribe" \
  -H "Authorization: Bearer $CHATKOMODO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "endpoint": "https://example.com/file.jpg",
  "keys": {
    "p256dh": "BP4z9KsN6nGRTbVYI_c7VJSPQTBtkgcy27mlmlMoZIIgDll6e3vCYLocInmYWAmS6TlzAC8wEqKK6PBru3jl7A8",
    "auth": "BTBZMqHH6r4Tts7J_aSIgg"
  }
}'
const res = await fetch('https://api.chatkomodo.com/v1/push/subscribe', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.CHATKOMODO_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "endpoint": "https://example.com/file.jpg",
    "keys": {
      "p256dh": "BP4z9KsN6nGRTbVYI_c7VJSPQTBtkgcy27mlmlMoZIIgDll6e3vCYLocInmYWAmS6TlzAC8wEqKK6PBru3jl7A8",
      "auth": "BTBZMqHH6r4Tts7J_aSIgg"
    }
  }),
});
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/push/subscribe",
    headers={
        "Authorization": f"Bearer {os.environ['CHATKOMODO_API_KEY']}",
    },
    json={
        "endpoint": "https://example.com/file.jpg",
        "keys": {
            "p256dh": "BP4z9KsN6nGRTbVYI_c7VJSPQTBtkgcy27mlmlMoZIIgDll6e3vCYLocInmYWAmS6TlzAC8wEqKK6PBru3jl7A8",
            "auth": "BTBZMqHH6r4Tts7J_aSIgg",
        },
    },
    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/push/subscribe', [
    'headers' => [
        'Authorization' => 'Bearer ' . getenv('CHATKOMODO_API_KEY'),
    ],
    'json' => [
        'endpoint' => 'https://example.com/file.jpg',
        'keys' => [
            'p256dh' => 'BP4z9KsN6nGRTbVYI_c7VJSPQTBtkgcy27mlmlMoZIIgDll6e3vCYLocInmYWAmS6TlzAC8wEqKK6PBru3jl7A8',
            'auth' => 'BTBZMqHH6r4Tts7J_aSIgg',
        ],
    ],
]);

print_r(json_decode((string) $res->getBody(), true));
Response 201
{
  "ok": true
}

Turn off notifications for a browser

DEL/v1/push/subscribe

Stop notifications on this browser.

Request body

  • endpointstringrequired

Responses

  • 200Stopped
    Response fields
    • okbooleanrequired
  • 403Not a dashboard login
Request
curl -X DELETE "https://api.chatkomodo.com/v1/push/subscribe" \
  -H "Authorization: Bearer $CHATKOMODO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "endpoint": "https://example.com/file.jpg"
}'
const res = await fetch('https://api.chatkomodo.com/v1/push/subscribe', {
  method: 'DELETE',
  headers: {
    Authorization: `Bearer ${process.env.CHATKOMODO_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "endpoint": "https://example.com/file.jpg"
  }),
});
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/push/subscribe",
    headers={
        "Authorization": f"Bearer {os.environ['CHATKOMODO_API_KEY']}",
    },
    json={
        "endpoint": "https://example.com/file.jpg",
    },
    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/push/subscribe', [
    'headers' => [
        'Authorization' => 'Bearer ' . getenv('CHATKOMODO_API_KEY'),
    ],
    'json' => [
        'endpoint' => 'https://example.com/file.jpg',
    ],
]);

print_r(json_decode((string) $res->getBody(), true));
Response 200
{
  "ok": true
}

Send a test notification

POST/v1/push/test

Send a test notification to this browser (header X-Lang: id for Indonesian).

Request body

  • endpointstringrequired

Responses

  • 200Sent
    Response fields
    • okbooleanrequired
  • 403Not a dashboard login
  • 404This browser is not subscribed
  • 502PUSH_FAILED
Request
curl -X POST "https://api.chatkomodo.com/v1/push/test" \
  -H "Authorization: Bearer $CHATKOMODO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "endpoint": "https://example.com/file.jpg"
}'
const res = await fetch('https://api.chatkomodo.com/v1/push/test', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.CHATKOMODO_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "endpoint": "https://example.com/file.jpg"
  }),
});
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/push/test",
    headers={
        "Authorization": f"Bearer {os.environ['CHATKOMODO_API_KEY']}",
    },
    json={
        "endpoint": "https://example.com/file.jpg",
    },
    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/push/test', [
    'headers' => [
        'Authorization' => 'Bearer ' . getenv('CHATKOMODO_API_KEY'),
    ],
    'json' => [
        'endpoint' => 'https://example.com/file.jpg',
    ],
]);

print_r(json_decode((string) $res->getBody(), true));
Response 200
{
  "ok": true
}