# Get message history (/en/api-reference/api-ref/signaling/message-history)

> For AI agents: see the complete documentation index at [llms.txt](/llms.txt).

Retrieves historical messages from a specified channel.

- OpenAPI: /openapi/rtm/signaling-rest.en.yaml
- Operation ID: get-message-history
- Method: GET
- Path: /rtm/v2/history/{appId}/userId/{userId}/channelType/{channelType}/channel/{channelName}

## Servers

- https://api.sd-rtn.com

## Parameters

- `appId` (path, required) - The App ID of your Agora project.
- `userId` (path, required) - The user ID for the operation.

 - 26 lowercase English letters: a-z
 - 26 uppercase English letters: A-Z
 - 10 numbers: 0-9
 - Space
 - Special characters: !, #, $, %, &, (, ), +, -, :, ;, <, =, ., >, ?, @, [, ], ^, _, {, }, |, ~
- `channelType` (path, required) - The type of channel to retrieve messages from. `message` for a message channel, `user` for a user channel.
- `channelName` (path, required) - The name of the channel.

 - 26 lowercase English letters: a-z
 - 26 uppercase English letters: A-Z
 - 10 numbers: 0-9
 - Space
 - Special characters: !, #, $, %, &, (, ), +, -, :, ;, <, =, ., >, ?, @, [, ], ^, _, {, }, |, ~
- `start` (query, optional) - The start timestamp of the historical message query. Defaults to `0` if not specified.
- `end` (query, optional) - The end timestamp of the historical message query. Defaults to `0` if not specified.
- `messageCount` (query, optional) - The maximum number of messages to return in a single query. The value must be in the range `(0, 100]`. Defaults to `100`.

## Request body

No request body.

## Responses

### 200

The request was successful. The response body contains the result of the request.

- `errorCode` (integer) - The status code of the request. `200` indicates success.
No schema.
- `error` (boolean) - Indicates whether the request failed. `false` if it succeeded, `true` if it failed.
No schema.
- `requestId` (string) - The unique ID associated with the request.
No schema.
- `operation` (string) - The specific operation performed by the request.
No schema.
- `reason` (string) - A short explanation of the reason for the error.
No schema.
- `timestamp` (integer) - The time the request was sent, as a Unix timestamp in milliseconds.

The time the request was sent, represented as a Unix timestamp in milliseconds.
No schema.
- `data` (object) - The response payload.

The response payload. Contains the following fields:
  - `data.messageList` (array) - An array of message objects.
    - `data.messageList.items` (object)
      - `data.messageList.items.messageType` (string) - The type of message content. `STRING` uses the `message` field directly; `BINARY` is base64-encoded in the `message` field.
No schema.
      - `data.messageList.items.message` (string) - The content of the message.
No schema.
      - `data.messageList.items.customType` (string) - The custom message type.
No schema.
      - `data.messageList.items.publisher` (string) - The user ID of the message sender.
No schema.
      - `data.messageList.items.timestamp` (integer) - The time the message was sent, as a Unix timestamp.
No schema.
  - `data.count` (integer) - The total number of messages retrieved.
No schema.
  - `data.newStart` (integer) - The start timestamp for the next batch of messages.
No schema.
### default

The request failed. The response body includes the error code and description.

No schema.
