Browse Platform API
Platform API

Create group

Copy

Use Create group to create an OpenIM group with an owner, initial members and administrators, and group profile data.

HTTP request

POST {API_ADDRESS}/group/create_group

Request example

curl --request POST "${API_ADDRESS}/group/create_group" \
  --header "Content-Type: application/json; charset=utf-8" \
  --header "operationID: ${OPERATION_ID}" \
  --header "token: ${ADMIN_TOKEN}" \
  --data-raw '{
  "memberUserIDs": [
    "user_001",
    "user_002"
  ],
  "adminUserIDs": [
    "user_admin"
  ],
  "ownerUserID": "user_owner",
  "groupInfo": {
    "groupID": "group_001",
    "groupName": "Product Discussion",
    "notification": "Welcome to OpenIM",
    "introduction": "Group for product discussions",
    "faceURL": "https://example.com/group.png",
    "ex": "",
    "groupType": 2,
    "needVerification": 0,
    "lookMemberInfo": 0,
    "applyMemberFriend": 0
  },
  "sendMessage": true
}'
Keep administrator tokens on trusted backend services only. Client applications should use user tokens issued by your backend.

Request body

{
  "memberUserIDs": [
    "user_001",
    "user_002"
  ],
  "adminUserIDs": [
    "user_admin"
  ],
  "ownerUserID": "user_owner",
  "groupInfo": {
    "groupID": "group_001",
    "groupName": "Product Discussion",
    "notification": "Welcome to OpenIM",
    "introduction": "Group for product discussions",
    "faceURL": "https://example.com/group.png",
    "ex": "",
    "groupType": 2,
    "needVerification": 0,
    "lookMemberInfo": 0,
    "applyMemberFriend": 0
  },
  "sendMessage": true
}
ParameterRequiredTypeDescription
memberUserIDsNoarrayInitial regular member user IDs, up to 1,000.
adminUserIDsNoarrayList of group administrator user IDs.
ownerUserIDYesstringGroup owner user ID.
groupInfoYesobjectGroup profile following GroupInfo.
groupInfo.groupIDNostringGroup ID. OpenIM generates one when this field is omitted.
groupInfo.groupNameYesstringGroup name.
groupInfo.notificationNostringGroup announcement or notification text.
groupInfo.introductionNostringGroup introduction.
groupInfo.faceURLNostringAvatar or icon URL.
groupInfo.exNostringBusiness extension field.
groupInfo.groupTypeYesintGroup type. This endpoint requires the value 2; see GroupType.
groupInfo.needVerificationNointJoin verification policy. See GroupVerification.
groupInfo.lookMemberInfoNointWhether members can view group member information.
groupInfo.applyMemberFriendNointWhether members can add each other as friends from the group.
sendMessageNobooleanWhether OpenIM should send a notification message for this operation.
displayIsRead EnterpriseNobooleanWhether group-message read status is displayed. The server may disable it automatically for large groups.

Response

OpenIM usually returns 200 OK when the request reaches the service. Use errCode in the JSON response to determine business success; errCode === 0 means the operation succeeded.

{
  "errCode": 0,
  "errMsg": "",
  "errDlt": "",
  "data": {
    "groupInfo": {
      "groupID": "group_001",
      "groupName": "Product Discussion",
      "notification": "Welcome to OpenIM",
      "introduction": "Group for product discussions",
      "faceURL": "https://example.com/group.png",
      "ownerUserID": "user_owner",
      "createTime": 1719800000000,
      "memberCount": 3,
      "ex": "",
      "status": 0,
      "creatorUserID": "user_owner",
      "groupType": 2,
      "needVerification": 0,
      "lookMemberInfo": 0,
      "applyMemberFriend": 0,
      "notificationUpdateTime": 0,
      "notificationUserID": ""
    }
  }
}

Response fields

FieldTypeDescription
errCodeintBusiness error code. 0 means success.
errMsgstringShort error message.
errDltstringDetailed error information for troubleshooting.
dataobjectEndpoint-specific response data.
data.groupInfoobjectCreated group profile following GroupInfo.

Error response

When a request fails, OpenIM returns the same error envelope. See Error codes for the full handling model.

{
  "errCode": 1004,
  "errMsg": "RecordNotFoundError",
  "errDlt": ": [1004]RecordNotFoundError"
}
ScenarioPossible causeRecommended action
Authentication failedtoken is missing, expired, or not an administrator token.Issue a new administrator token and keep it on the backend.
Traceability is weakoperationID is missing or reused across many requests.Generate a unique operationID for every request and log it with the response.
Validation failedThe request body has an invalid type, missing field, or unsupported enum value.Compare the payload with the request table and retry after correcting the fields.

Permissions and limits

  • groupInfo and ownerUserID are required.
  • groupInfo.groupType must be 2, and memberUserIDs accepts at most 1,000 users.
  • displayIsRead is available in OpenIM Enterprise.