---
title: "Read message history for a chat (any type) from the MAM archive"
method: GET
path: "/v2/apps/{appId}/chats/{chatId}/messages"
tags: ["Chats"]
---

# Read message history for a chat (any type) from the MAM archive

`GET /v2/apps/{appId}/chats/{chatId}/messages`

## Request

- Base URL: `https://api.chat.ethora.com`
- URL: `https://api.chat.ethora.com/v2/apps/{appId}/chats/{chatId}/messages`
- Auth: one of:
  - HTTP bearer
  - HTTP bearer

**Auth**: Tenant Actor

Returns the message history for a single chat room, fetched directly from
ejabberd's `mod_mam` archive table. Generic — works for any chat type
(`widget`, `group`, `private`); this is the same endpoint the admin
AI Widget Conversations modal calls for inline transcripts and which can
be reused for any other chat-inspection surface.

The chat must exist AND belong to the requested app — even if the caller
knows the chatId, archives for chats in other apps are not exposed.

Pagination uses a `before` cursor in milliseconds-since-epoch on the
message timestamp. Pass `nextBefore` from a prior response back as
`before` to fetch the next older page. Results are returned in
chronological order (oldest first) so the UI can render top-to-bottom
without re-sorting.

Installs that haven't wired the `MAM_MYSQL_*` env vars get
`mamUnavailable: true` and an empty `results` array — the UI should
render a "history viewer not configured" hint rather than a broken state.

## Path parameters

- `appId` string, required
- `chatId` string, required

## Query parameters

- `limit` integer
- `before` integer

## Response `200`

```
{
  results: [
    {
      id: string,             // ejabberd archive row id (stable, sortable)
      originId: string|null,  // client-side message id when available
      ts: number,             // ms-since-epoch
      from: string,           // sender bare JID
      nick: string,           // sender's MUC nickname
      body: string            // plain-text message body
    }
  ],
  total: number,
  nextBefore: number|null,
  chat: { _id: string, name: string, type: string },
  mamUnavailable: boolean    // true when MAM_MYSQL_* env not configured
}
```

## Other responses

- `400`: Bad Request
- `401`: Unauthorized
- `403`: Forbidden
- `404`: Chat not found, or not in the requested app. ``` { error: string, code: 'CHAT_NOT_FOUND' } ```
- `422`: Validation error (missing chatId, etc.). ``` { error: string, code: 'VALIDATION_ERROR' } ```
- `500`: Internal Server Error
- `502`: MySQL read failed (network / auth / etc.). ``` { error: string, code: 'MAM_READ_FAILED' } ```

---

[API](https://skmtc.dev/ethora/apis/platform-api.md) · [All operations](https://skmtc.dev/ethora/apis/platform-api/llms.txt) · [OpenAPI document](https://skmtc.dev/ethora/apis/platform-api/revisions/01b6e64378ee?raw)
