Skip to main content

Callback Before Group Creation

Description

The App’s business server can use this callback to review requests from users to create groups. The server can either allow the request, reject it, or modify it as needed.

Important Notes

  • To enable this callback, configure the callback URL and activate the corresponding protocol switch. For configuration details, refer to the Callback Introduction document.
  • The callback is initiated from the OpenIM Server to the App backend as an HTTP/HTTPS POST request.
  • The App business server must respond within the timeout period.

Scenarios that Trigger This Callback

  • Group creation requests from an App user through the client.
  • Group creation requests from an App admin via REST API.

Timing of Callback

  • Triggered before the OpenIM Server prepares to create the group.

Interface Description

Example Request URL

The CallbackCommand here is: callbackBeforeCreateGroupCommand

{WEBHOOK_ADDRESS}/callbackBeforeCreateGroupCommand?contenttype=json

Example Request Package

{
"callbackCommand": "callbackBeforeCreateGroupCommand",
"groupID": "12345",
"groupName": "MyGroup",
"notification": "Welcome to MyGroup!",
"introduction": "This is a group for discussing example topics.",
"faceURL": "http://example.com/path/to/face/image.png",
"ownerUserID": "user123",
"createTime": 1673048592000,
"memberCount": 10,
"ex": "Extra data",
"status": 1,
"creatorUserID": "user123",
"groupType": 1,
"needVerification": 1,
"lookMemberInfo": 1,
"applyMemberFriend": 0,
"notificationUpdateTime": 1673048592000,
"notificationUserID": "user456",
"initMemberList": [
{
"userID": "user789",
"roleLevel": 60
},
{
"userID": "user101112",
"roleLevel": 20
}
]
}

Request Package Field Descriptions

FieldTypeDescription
callbackCommandstringCallback command for pre-group creation.
groupIDstringUnique identifier for the group.
groupNamestringName of the group.
notificationstringGroup notification message.
introductionstringGroup introduction.
faceURLstringURL for the group’s icon.
ownerUserIDstringUser ID of the group owner.
createTimeint64Timestamp for when the group was created (in ms).
memberCountuint32Number of members in the group.
exstringAdditional data field.
statusint32Group status.
creatorUserIDstringUser ID of the group creator.
groupTypeint32Group type, fixed at 2.
needVerificationint32Whether verification is needed to join the group.
lookMemberInfoint32Whether group members’ information is visible.
applyMemberFriendint32Whether members can add each other as friends.
notificationUpdateTimeint64Timestamp for when the notification was last updated (in ms).
notificationUserIDstringUser ID of the person who updated the notification.
initMemberListarrayList of initial group members, each with userID and roleLevel fields.
initMemberList.userIDstringUser ID of the initial group member.
initMemberList.roleLevelint32Role level of the initial group member.

Example Response Package

Allow Creation

{
"actionCode": 0,
"errCode": 0,
"errMsg": "",
"errDlt": "",
"nextCode": 0,
"groupID": "G001",
"groupName": "MyGroup",
"notification": "Welcome to MyGroup!",
"introduction": "A group for discussions",
"faceURL": "http://example.com/groupface.png",
"ownerUserID": "user01",
"ex": "Some extra data",
"status": 1,
"creatorUserID": "user02",
"groupType": 1,
"needVerification": 0,
"lookMemberInfo": 1,
"applyMemberFriend": 1
}

Response Package Field Descriptions

FieldValueDescription
actionCode0Indicates if the callback was executed correctly. 0 means success.
errCode5001Custom error code, ranging between 5000-9999. Set if actionCode is not 0 or nextCode is 1.
errMsg"An error message"Simple error message for the custom error code.
errDlt"Detailed error information"Detailed error information for the custom error code.
nextCode1Next action code, set to 1 to halt further action if actionCode is 0.
groupIDstringUnique identifier for the group.
groupNamestringGroup name.
notificationstringNotification or announcement for the group.
introductionstringGroup introduction.
faceURLstringURL for the group’s icon or image.
ownerUserIDstringUser ID of the group owner.
exstringAdditional data or information.
statusint32Group status.
creatorUserIDstringUser ID of the person creating the group.
groupTypeint32Group type, fixed at 2.
needVerificationint32Whether verification is needed to join the group.
lookMemberInfoint32Whether group members’ information is visible.
applyMemberFriendint32Whether members can add each other as friends.