logo

createChat

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.

Inside the 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 createChat only assembles the chat object when type is "Group". Passing any other type through the helper produces an empty chat object, so build the request yourself if you need another chat type.

Preconditions for API Functionality

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.

Response

createChatAck

βœ… On success, createChatAck is returned carrying the created chat.
Field
Type
Returned
Description
method
String
Yes
"createChatAck"
chat
Yes
The newly created chat, including its generated id.
reference
String
Optional
Echoed from the request.

SDK Mapping β€” 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)

Example

Request

json
{ "method": "createChat", "reference": "111111160", "chat": { "type": "Group", "title": "Support Team", "isPublic": 0, "timezone": "Africa/Cairo" } }

Response

json
{ "method": "createChatAck", "reference": "111111160", "chat": { "id": "90090684293000559", "title": "Support Team", "type": "Group" } }

Powered by Notaku