그룹 생성
Feature Overview
This API is used by the app admin to create groups.
API Calling Description
Applicable group types
Group Type ID | RESTful API Support |
Private | Yes. Same as work groups (Work) in the new version. |
Public | Yes |
ChatRoom | Yes. Same as meeting groups (Meeting) in the new version. |
AVChatRoom | Yes. To use an audio-video group (AVChatroom), users (including the group owner) must use the SDK to request to join the group. |
Community | Yes |
Note
If the group type is specified as audio-video group (AVChatRoom):
When creating a group of this type, the group creator cannot add users to the group. If a group member is specified during the group creation, error 10007 will be returned. Users can only request to join this type of group. If a group owner is specified, the group owner must use the SDK API to join the group every time he or she uses the group.
If the group type is specified as a type other than an audio-video group (AVChatRoom):
If neither a group owner nor a group member list is specified when the request is sent, the number of groups that can be created is unrestricted.
If a group owner or group member list is specified when the request is sent, the specified group owner or group members are automatically added to the group.
If the total number of groups in the app exceeds 100,000, certain fees will be charged. For more information, see Pricing.
The number of groups that a user can join at the same time is limited. If the number is reached, joining or creating a group will fail. For more information, see Pricing.
Sample request URL
https://xxxxxx/v4/group_open_http_svc/create_group?sdkappid=88888888&identifier=admin&usersig=xxx&random=99999999&contenttype=json
Request parameters
The following table describes the modified parameters when this API is called. For other parameters, see RESTful API Overview.
Parameter | Description |
xxxxxx | Domain name corresponding to the country/region where your SDKAppID is located. China: console.tim.qq.com Singapore: adminapisgp.im.qcloud.com Seoul: adminapikr.im.qcloud.com Frankfurt: adminapiger.im.qcloud.com Silicon Valley: adminapiusa.im.qcloud.com Jakarta: adminapiidn.im.qcloud.com |
v4/group_open_http_svc/create_group | Request API |
sdkappid | SDKAppID assigned by the Chat console when an app is created |
identifier | |
usersig | |
random | A random 32-bit unsigned integer ranging from 0 to 4294967295. |
contenttype | Request format, which should always be json . |
Maximum call frequency
200 calls per second
Sample request
Basic format
Create a group. The
Owner_Account
field is optional. If it is not specified, the group will have no group owner. If you want to specify a group owner, ensure that the UserId of the group owner has been imported.{"Owner_Account": "leckie", // UserId of the group owner (optional)"Type": "Public", // Group type: Private, Public, ChatRoom, AVChatRoom, or Community"Name": "TestGroup" // Group name (required)}
Containing only basic group information
Create a group and specify basic group information, such as the group introduction and group notice.
{"Owner_Account": "leckie", // UserId of the group owner (optional)"Type": "Public", // Group type: Private, Public, ChatRoom, AVChatRoom, or Community"Name": "TestGroup", // Group name (required)"Introduction": "This is group Introduction", // Group introduction (optional)"Notification": "This is group Notification", // Group notice (optional)"FaceUrl": "http://this.is.face.url", // Group profile photo URL (optional)"MaxMemberCount": 500, // Maximum number of group members (optional)"ApplyJoinOption": "FreeAccess" // Method for handling requests to join the group (optional)}
Containing only group member information
Create a group and specify to initialize the group member list, which is described in the request packet description table. When group members are initialized, only the
Member_Account
and Role
fields can be set.{"Name": "TestGroup", // Group name (required)"Type": "Public", // Group type: Private, Public, ChatRoom, or Community (AVChatRoom is not supported) (required)"MemberList": [ // Initial group member list, which contains a maximum of 100 members (optional){"Member_Account": "bob", // Member (required)"Role": "Admin" // Role assigned to the member (optional). Currently, only the Admin option is available.},{"Member_Account": "peter"}]}
Custom group ID
To simplify group IDs, Tencent Cloud allows apps to customize group IDs when creating groups through the RESTful API.
{"Owner_Account": "leckie", // UserId of the group owner (optional)"Type": "Public", // Group type: Private, Public, ChatRoom, AVChatRoom, or Community (required)"GroupId": "MyFirstGroup", // User-defined group ID (optional)"Name": "TestGroup" // Group name (required)}
Containing only custom group information
Create a group and specify group custom fields. The
AppDefineData
field is unavailable by default and needs to be enabled in the Chat console before use. For details, see the request packet field description table.{"Name": "TestGroup", // Group name (required)"Type": "Public", // Group type: Private, Public, ChatRoom, AVChatRoom, or Community (required)"AppDefinedData": [ // Group custom field (optional){"Key": "GroupTestData1", // Key of the app custom field"Value": "xxxxx" // Value of the custom field},{"Key": " GroupTestData2","Value": "abc\u0000\u0001" // The custom field supports binary data.}]}
Containing only custom group member information
Create a group and specify group member custom fields. By default, AppMemberDefinedData is not available and needs to be enabled in the Chat console before use. For details, see the table for request packet fields.
{"Owner_Account": "leckie", // UserId of the group owner (optional)"Type": "Public", // Group type: Private, Public, ChatRoom, or Community (AVChatRoom is not supported) (required)"Name": "TestGroup", // Group name (required)"MemberList": [{"Member_Account":"bob","AppMemberDefinedData":[ // Group member custom field (optional){"Key": "MemberDefined1", // Group member custom key"Value": "MemberData1" // Value of the group member custom field},{"Key": "MemberDefined2","Value": "MemberData2"}]},{"Member_Account":"peter","AppMemberDefinedData":[{"Key": "MemberDefined1","Value": "MemberData1"},{"Key": "MemberDefined2","Value": "MemberData2"}]}]}
Containing only the topic-enabled parameter format
Create a group and specify the type as a topic-enabled community.
{"Type": "Community", // Group type (required)"Name": "TestCommunityGroup", // Group name (required)"SupportTopic": 1 // Whether the topic option is supported. Valid values: `1`: yes; `0`: no.}
ALL IN ONE
{"Owner_Account": "leckie", // UserId of the group owner (optional)"Type": "Public", // Group type: Private, Public, ChatRoom, or Community (AVChatRoom is not supported) (required)"GroupId":"MyFirstGroup", // User-defined group ID (optional)"Name": "TestGroup", // Group name (required)"Introduction": "This is group Introduction", // Group introduction (optional)"Notification": "This is group Notification", // Group notice (optional)"FaceUrl": "http://this.is.face.url", // Group profile photo URL (optional)"MaxMemberCount": 500, // Maximum number of group members (optional)"ApplyJoinOption": "FreeAccess", // Method for handling requests to join the group (optional)"AppDefinedData": [ // Group custom field (optional){"Key": "GroupTestData1", // Key of the app custom field"Value": "xxxxx" // Value of the custom field},{"Key": "GroupTestData2","Value": "abc\u0000\u0001" // The custom field supports binary data.}],"MemberList": [ // Initial group member list, which contains a maximum of 100 members (optional){"Member_Account": "bob", // Member (required)"Role": "Admin", // Role assigned to the member. Currently, only the Admin option is available. (optional)"AppMemberDefinedData":[ // Group member custom field (optional){"Key":"MemberDefined1", // Group member custom key"Value":"MemberData1" // Value of the group member custom field},{"Key":"MemberDefined2","Value":"MemberData2"}]},{"Member_Account": "peter","AppMemberDefinedData":[{"Key":"MemberDefined1","Value":"MemberData1"},{"Key":"MemberDefined2","Value":"MemberData2"}]}]}
Request fields
Field | Type | Required | Description |
Owner_Account | String | Optional | Group owner ID, which must be an imported account. The value will be automatically added to group members. If this field is not specified, the group will have no group owner, and group members need to call the group joining API when using an audio-video group (AVChatroom) group. |
Type | String | Required | Group type, including Public, Work (Private), Meeting, AVChatRoom, and Community. |
GroupId | String | Optional | To simplify group IDs and make them easier to remember and share, we allow apps to customize group IDs when creating groups through the RESTful API. |
Name | String | Required | Group name, whose maximum length is 30 bytes. This field is UTF-8-encoded, and one Chinese character occupies 3 bytes. |
Introduction | String | Optional | Group introduction, whose maximum length is 240 bytes. This field is UTF-8-encoded, and one Chinese character occupies 3 bytes. |
Notification | String | Optional | Group notice, whose maximum length is 300 bytes. This field is UTF-8-encoded, and one Chinese character occupies 3 bytes. |
FaceUrl | String | Optional | URL of the group profile photo, whose maximum length is 100 bytes. |
MaxMemberCount | Integer | Optional | Maximum number of group members. The default value is the upper limit of the paid package. For example, it is 20 for a Developer edition. If you upgrade your package, you need to modify this field according to the basic information of the modified group. |
ApplyJoinOption | String | Optional | Method for handling requests to join the group, which can be FreeAccess , NeedPermission , or DisableApply . The default method is NeedPermission .This field is valid only for groups that can be joined by users. Community groups currently do not support this field. |
AppDefinedData | Array | Optional | Group-level custom field. This field is unavailable by default and needs to be enabled in the Chat console. For details, see Custom Fields. |
MemberList | Array | Optional | Initial group member list, which contains a maximum of 100 members. For details on group member information fields, see Group member profile. |
AppMemberDefinedData | Array | Optional | Group member custom fields. This field is unavailable by default and needs to be enabled in the Chat console. For details, see Custom Fields. |
SupportTopic | Integer | No | Whether the topic option is supported. This field is valid only for communities. |
Sample response
Basic form, containing only basic group information, containing only group member information, or containing only custom information
{"ActionStatus": "OK","ErrorInfo": "","ErrorCode": 0,"GroupId": "@TGS#2J4SZEAEL"}
Containing only the topic-enabled parameter format
{"ActionStatus": "OK","ErrorInfo": "","ErrorCode": 0,"GroupId": "@TGS#_@TGS#cRDH3HIM62CP","HugeGroupFlag": 0,"Type": "Community"}
Custom group ID and ALL IN ONE
{"ActionStatus": "OK","ErrorInfo": "","ErrorCode": 0,"GroupId": "MyFirstGroup"}
Response fields
Field | Type | Description |
ActionStatus | String | Request result. OK : Successful; FAIL : Failed |
ErrorCode | Integer | Error code. 0 : Successful; other values: Failed |
ErrorInfo | String | Error information |
GroupId | String | Group ID after successful creation, which is assigned by the Chat backend. |
Error Codes
The returned HTTP status code for this API is always 200 unless a network error (such as error 502) occurs. The specific error code and details can be found in the response fields
ErrorCode
and ErrorInfo
respectively.
For public error codes (60000 to 79999), see Error Codes.
The following table describes the error codes specific to this API:Error Code | Description |
10002 | Internal server error. Try again. |
10003 | Invalid request command word. |
10004 | Invalid parameter. Check the error description and fix the issue. |
10005 | The number of members imported in the request packet exceeds 100. Reduce the number of members imported in the MemberList parameter. |
10006 | The operation exceeds the frequency limit. Please reduce the call frequency. This error is usually caused by too much net group increase in a single day or too frequent calls to obtain all groups in the app. |
10007 | Insufficient operation permission. Check the request parameters based on the error information. For example, the specified group type does not allow adding members but MemberList was specified in the request. |
10008 | The request is invalid, probably because verification of the signing information in the request failed. Please try again or submit a ticket. |
10016 | The app backend rejected this operation through a webhook. Check the returned value of your wehook "Before a group is created". |
10021 | The group ID has already been used by another user. Select another group ID. |
10025 | You have already used this group ID. Disband the existing group first or select another group ID. |
10036 | The number of audio-video groups (AVChatRoom) created exceeds the limit. Delete some of the groups or purchase an upgrade by referring to Pricing. |
10037 | The request specifies Owner_Account, but the number of groups that the group owner has created or joined exceeds the limit. The group owner needs to leave some groups first or refer to Pricing to purchase an upgrade. |
10038 | The number of members imported in the request packet exceeds the limit. Reduce the number of members imported in the MemberList parameter or purchase an upgrade by referring to Pricing. |
10058 | You are now using the Developer edition, and the free quota of 100 groups is exceeded. To create more groups, you need to purchase a package. |