ChatKomodo Docs Home Sign in

API reference · WhatsApp features

Channels

WhatsApp channels (newsletters).

Create a channel

POST/v1/sessions/{sessionId}/newsletter/create

Creates a WhatsApp channel (newsletter).

Path parameters

  • sessionIdstringrequired
    Session (device) id

Request body

  • namestringrequired
    Channel name
  • descriptionstring

Responses

  • 200Channel created
    Response fields
    • idstringrequired
      Channel JID, <id>@newsletter
    • namestringrequired
    • descriptionstring
    • invitestring
    • creation_timeinteger
    • subscribersinteger
  • 400The body is not valid JSON
  • 401Missing or invalid credentials
  • 403The API key is restricted to other sessions, or the operation is not available to CS-agent logins
  • 404Unknown session, or a session of another tenant
  • 409The session is not connected
  • 500WhatsApp operation failed: WhatsApp or the library rejected the call. The gateway does not validate this body, so missing or malformed fields end up here too
Request
curl -X POST "https://api.chatkomodo.com/v1/sessions/YOUR_DEVICE_ID/newsletter/create" \
  -H "Authorization: Bearer $CHATKOMODO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "Acme news",
  "description": "Short description"
}'
const res = await fetch('https://api.chatkomodo.com/v1/sessions/YOUR_DEVICE_ID/newsletter/create', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.CHATKOMODO_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "name": "Acme news",
    "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/sessions/YOUR_DEVICE_ID/newsletter/create",
    headers={
        "Authorization": f"Bearer {os.environ['CHATKOMODO_API_KEY']}",
    },
    json={
        "name": "Acme news",
        "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/sessions/YOUR_DEVICE_ID/newsletter/create', [
    'headers' => [
        'Authorization' => 'Bearer ' . getenv('CHATKOMODO_API_KEY'),
    ],
    'json' => [
        'name' => 'Acme news',
        'description' => 'Short description',
    ],
]);

print_r(json_decode((string) $res->getBody(), true));
Response 200
{
  "id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
  "name": "Acme news",
  "description": "Short description",
  "invite": "string",
  "creation_time": 1767225600000,
  "subscribers": 1
}

Post to a channel

POST/v1/sessions/{sessionId}/newsletter/{nid}/post

Sends a text post to a channel straight through the WhatsApp connection (not queued, not logged in the message history).

Path parameters

  • sessionIdstringrequired
    Session (device) id
  • nidstringrequired
    Channel JID, <id>@newsletter

Request body

  • textstringrequired
    Post text

Responses

  • 200Posted
    Response fields
    • okbooleanrequired
  • 400The body is not valid JSON
  • 401Missing or invalid credentials
  • 403The API key is restricted to other sessions, or the operation is not available to CS-agent logins
  • 404Unknown session, or a session of another tenant
  • 409The session is not connected
  • 500WhatsApp operation failed: WhatsApp or the library rejected the call. The gateway does not validate this body, so missing or malformed fields end up here too
Request
curl -X POST "https://api.chatkomodo.com/v1/sessions/YOUR_DEVICE_ID/newsletter/120363098765432109%40newsletter/post" \
  -H "Authorization: Bearer $CHATKOMODO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "text": "This week only: 20% off all coffee beans."
}'
const res = await fetch('https://api.chatkomodo.com/v1/sessions/YOUR_DEVICE_ID/newsletter/120363098765432109%40newsletter/post', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.CHATKOMODO_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "text": "This week only: 20% off all coffee beans."
  }),
});
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/newsletter/120363098765432109%40newsletter/post",
    headers={
        "Authorization": f"Bearer {os.environ['CHATKOMODO_API_KEY']}",
    },
    json={
        "text": "This week only: 20% off all coffee beans.",
    },
    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/newsletter/120363098765432109%40newsletter/post', [
    'headers' => [
        'Authorization' => 'Bearer ' . getenv('CHATKOMODO_API_KEY'),
    ],
    'json' => [
        'text' => 'This week only: 20% off all coffee beans.',
    ],
]);

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