Query Chat History

Last Updated on : 2026-02-26 09:16:49download

Based on the device ID, query the chat history for the specified AI agent.

API address

GET: /v1.0/cloud/agent/ai/chat/b/devices/{device_id}/history

Request parameter

Parameter nameTypeINRequiredDescription
device_idStringpathtrueThe ID of the specified device.
bind_role_typeIntegerquerytrueThe type of role to bind. Valid values:
  • 0: Custom role
  • 1: Template-based role
  • 2: Single role (There is no role, and data is at the agent level)
When role_id has a value, this parameter value must be passed.
role_idStringquerytrueThe ID of the specified role.
gmt_endLongquerytrueThe end timestamp of the chat message. Chat messages sent before this time will be returned.
page_sizeIntegerquerytrueThe number of items returned per page. Maximum value: 20.

Return parameter

Parameter nameTypeDescription
resultListThe list of session records.

Description of result

Parameter nameTypeDescription
gmt_createLongThe timestamp when the chat is created.
answerListThe list of answers.
questionListThe list of questions.
request_idStringThe ID of the session record.

Description of question

Parameter nameTypeDescription
contextStringThe message content.
typeStringThe message type.

Description of answer

Parameter nameTypeDescription
contextStringThe message content.
typeStringThe message type.

Request example

GET: /v1.0/cloud/agent/ai/chat/b/devices/{device_id}/history
{
  "device_id": "6c50600a0e15d1fb78h***",
  "bind_role_type": 1,
  "role_id": "94300***",
  "gmt_end": 1753079987512,
  "page_size": 20
}

Return example

{
    "result": [
        {
            "gmt_create": 1753344939913,
            "question": [
                {
                    "type": "text",
                    "context": "My ***"
                }
            ],
            "answer": [
                {
                    "type": "text",
                    "context": "You told me *** before"
                }
            ],
            "request_id": "ccbda733-e3d2-4ee3-bb19-d201-***"
        }
    ],
    "t": 1753707608368,
    "success": true
}

Error code

For more information, see error code.