Use this method to create a new chat owned by your app.
The request wraps the chat's properties in a nested chat object.
| Field | Type | Required | Description |
|---|---|---|---|
method |
String | Yes | "createChat" |
chat |
Object | Yes | The chat to create — see the table below. |
reference |
String | Optional | Unique identifier for the request, echoed in the response. |
chat object| Field | Type | Required | Description |
|---|---|---|---|
type |
String | Yes | The chat type. The SDK helpers build the payload for "Group". |
title |
String | Yes | Display title of the new chat. |
isPublic |
Number | Yes | 1 for a public chat, 0 for private. |
timezone |
String | Yes | Timezone of the chat, e.g. "Africa/Cairo". |
💡 The SDK helper
createChatonly assembles thechatobject whentypeis"Group". Passing any other type through the helper produces an emptychatobject, so build the request yourself if you need another chat type.
The following tables outline the preconditions that must be met for the API to function correctly. Failure to meet these conditions may result in errors or unexpected behavior.
| Action | Requirement | Description |
|---|---|---|
| Create a chat | App ownership | The API must belong to the app the chat is being created under. |
✅ On success, createChatAck is returned carrying the created chat.
| Field | Type | Returned | Description |
|---|---|---|---|
method |
String | Yes | "createChatAck" |
chat |
Chat | Yes | The newly created chat, including its generated id. |
reference |
String | Optional | Echoed from the request. |
createChat| SDK | Request Method | Response Callback |
|---|---|---|
| Java | api.createChat(type, title, isPublic, reference, appId); |
onCreateChat(Chat chat) |
| JavaScript | api.createChat(type, title, isPublic, reference, appId); |
onCreateChat(chat) |
| Python | napi.create_chat(type=type, title=title, is_public=is_public, reference=reference, app_id=app_id) |
on_create_chat(self, chat) |
{
"method": "createChat",
"reference": "111111160",
"chat": {
"type": "Group",
"title": "Support Team",
"isPublic": 0,
"timezone": "Africa/Cairo"
}
}