Code samples use your device
. Create an API key under API keys.API reference · WhatsApp features
Communities
Create a community
POST
/v1/sessions/{sessionId}/communities/createCreates a WhatsApp community. WhatsApp may answer with no group data, in which case the response body is null.
Path parameters
sessionIdstringrequiredSession (device) id
Request body
subjectstringrequiredCommunity namebodystringrequiredCommunity description
Responses
- 200Community created
Response fields
idstringrequiredGroup JIDsubjectstringrequiredGroup nameownerstringcreationintegerCreation time as reported by WhatsApp (Unix epoch)descstringGroup descriptionsizeintegerrestrictbooleanOnly admins can change group settingsannouncebooleanOnly admins can writeephemeralDurationintegerDisappearing-messages timer in secondsparticipantsarray of objectrequiredparticipants[].idstringrequiredparticipants[].adminstring | nulladmin,superadminor null
- 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
- 500
WhatsApp 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/communities/create" \
-H "Authorization: Bearer $CHATKOMODO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"subject": "Support team",
"body": "Hi Sam, your order has shipped."
}'const res = await fetch('https://api.chatkomodo.com/v1/sessions/YOUR_DEVICE_ID/communities/create', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.CHATKOMODO_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"subject": "Support team",
"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/sessions/YOUR_DEVICE_ID/communities/create",
headers={
"Authorization": f"Bearer {os.environ['CHATKOMODO_API_KEY']}",
},
json={
"subject": "Support team",
"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/sessions/YOUR_DEVICE_ID/communities/create', [
'headers' => [
'Authorization' => 'Bearer ' . getenv('CHATKOMODO_API_KEY'),
],
'json' => [
'subject' => 'Support team',
'body' => 'Hi Sam, your order has shipped.',
],
]);
print_r(json_decode((string) $res->getBody(), true));Response 200
{
"id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"subject": "Support team",
"owner": "string",
"creation": 1,
"desc": "string",
"size": 12,
"restrict": true,
"announce": true,
"ephemeralDuration": 604800,
"participants": [
{
"id": "01JA5V6Q8M2H7G4K9P3T0R1S2X",
"admin": "string"
}
]
}Link a group to a community
POST
/v1/sessions/{sessionId}/communities/{cid}/link-groupNot available yet: the WhatsApp library version in use (Baileys 6.7.23) has no communityLinkGroup method, so this answers 501 NOT_SUPPORTED. The request shape is the one the handler reads.
Path parameters
sessionIdstringrequiredSession (device) idcidstringrequiredCommunity JID
Request body
group_jidstringrequiredJID of the group to link
Responses
- 200Linked
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
- 500
WhatsApp 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 - 501
NOT_SUPPORTED: the WhatsApp library version in use (Baileys 6.7.x) has no such operation, so the call is not available yet
Request
curl -X POST "https://api.chatkomodo.com/v1/sessions/YOUR_DEVICE_ID/communities/120363012345678901%40g.us/link-group" \
-H "Authorization: Bearer $CHATKOMODO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"group_jid": "[email protected]"
}'const res = await fetch('https://api.chatkomodo.com/v1/sessions/YOUR_DEVICE_ID/communities/120363012345678901%40g.us/link-group', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.CHATKOMODO_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"group_jid": "[email protected]"
}),
});
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/communities/120363012345678901%40g.us/link-group",
headers={
"Authorization": f"Bearer {os.environ['CHATKOMODO_API_KEY']}",
},
json={
"group_jid": "[email protected]",
},
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/communities/120363012345678901%40g.us/link-group', [
'headers' => [
'Authorization' => 'Bearer ' . getenv('CHATKOMODO_API_KEY'),
],
'json' => [
'group_jid' => '[email protected]',
],
]);
print_r(json_decode((string) $res->getBody(), true));Response 200
{
"ok": true
}