Browse Platform API
Platform API

Get sorted conversation list

Copy

Use Get sorted conversation list to retrieve a user's ordered conversation summaries together with total unread state. Supply conversationIDs to restrict the result, or omit it to page through the user's conversations.

HTTP request

POST {API_ADDRESS}/conversation/get_sorted_conversation_list

Request example

curl --request POST "${API_ADDRESS}/conversation/get_sorted_conversation_list" \
  --header "Content-Type: application/json; charset=utf-8" \
  --header "operationID: ${OPERATION_ID}" \
  --header "token: ${ADMIN_TOKEN}" \
  --data-raw '{
  "userID": "user_001",
  "conversationIDs": [
    "si_user_001_user_002"
  ],
  "pagination": {
    "pageNumber": 1,
    "showNumber": 20
  }
}'
Keep administrator tokens on trusted backend services only. Client applications should use user tokens issued by your backend.

Request body

{
  "userID": "user_001",
  "conversationIDs": [
    "si_user_001_user_002"
  ],
  "pagination": {
    "pageNumber": 1,
    "showNumber": 20
  }
}
ParameterRequiredTypeDescription
userIDYesstringOpenIM user ID.
conversationIDsNoarrayConversation IDs to include. Omit this field to read the user's conversations by page.
paginationYesobjectPagination settings.
pagination.pageNumberYesintPage number, starting from 1.
pagination.showNumberYesintNumber of records to return per page.

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": {
    "conversationTotal": 2,
    "unreadTotal": 3,
    "conversationElems": [
      {
        "conversationID": "si_user_001_user_002",
        "recvMsgOpt": 0,
        "unreadCount": 2,
        "IsPinned": false,
        "msgInfo": {
          "serverMsgID": "server_msg_001",
          "clientMsgID": "client_msg_001",
          "sessionType": 1,
          "sendID": "user_002",
          "recvID": "user_001",
          "senderName": "Jane",
          "faceURL": "https://example.com/avatar-jane.png",
          "groupID": "",
          "groupName": "",
          "groupFaceURL": "",
          "groupType": 0,
          "groupMemberCount": 0,
          "LatestMsgRecvTime": 1719800000000,
          "msgFrom": 100,
          "contentType": 101,
          "content": "{\"content\":\"hello\"}",
          "ex": ""
        }
      }
    ]
  }
}

Response fields

FieldTypeDescription
errCodeintBusiness error code. 0 means success.
errMsgstringShort error message.
errDltstringDetailed error information for troubleshooting.
dataobjectEndpoint-specific response data.
data.conversationTotalintTotal number of matching conversations.
data.unreadTotalintTotal unread message count across the matching conversations.
data.conversationElemsarrayOrdered summaries containing conversation ID, receive option, unread count, pinned state, and latest-message summary.

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

  • Call this endpoint from a trusted backend service.
  • Log operationID, the endpoint path, and the response error fields for troubleshooting.
  • Treat write operations as state-changing. If a retry follows an uncertain failure, check the resource state first.