# List Chat Records by Cursor

> Retrieve chronological conversation messages around a cursor anchor with automatic turn alignment and bidirectional cursors.

Source: https://doc.fastgpt.io/openapi/reference/chat-record/get-records-v2
Last Updated: 2026-11-18

## Endpoint Overview

* **Method** : `POST`
* **Path** : `/api/core/chat/record/getRecords_v2`
* **Module** : Chat / Chat Records
* **Authentication** : `Authorization: Bearer <apiKey>`—Supports **App API Key** ( `appId` optional) and **Personal API Key** ( `appId` required); also supports `authProxy` team member proxy and `outLinkAuthData` share link (see [API Getting Started](https://doc.fastgpt.io/openapi/intro) )
* **Interactive Try-It-Out** : [Open in Scalar API Explorer](https://cloud.fastgpt.io/apidoc/systemopenapi#tag/%E5%AF%B9%E8%AF%9D%E7%AE%A1%E7%90%86/POST/core/chat/record/getRecords_v2) (self-hosted instances: replace the origin with `<instance>/apidoc/systemopenapi#tag/%E5%AF%B9%E8%AF%9D%E7%AE%A1%E7%90%86/POST/core/chat/record/getRecords_v2` )

## Description & Notes

Fetches the latest messages by default in chronological order. Provide at most one of `prevId` (targets Human turn boundary), `nextId` , or `initialId` (targets AI turn boundary). Pass `prevCursor` / `nextCursor` directly to `prevId` / `nextId` ( `null` when no further page exists). Returned count may slightly exceed `pageSize` to complete turn boundaries.

## Request Parameters

### Request Body ( `application/json` )

#### Shared Parameters Across Branches

| Field                 | Type            | Required | Default | Constraints & Description                                                                              |
| --------------------- | --------------- | -------- | ------- | ------------------------------------------------------------------------------------------------------ |
| `chatId`              | `string`        | No       | -       | Chat ID. maxLength: 1024                                                                               |
| `loadCustomFeedbacks` | `boolean`       | No       | -       | Whether to load custom feedback items                                                                  |
| `type`                | `string` (enum) | No       | -       | Fetch mode controlling message visibility and filtering. Allowed values: `normal` , `outLink` , `home` |
| `includeDeleted`      | `boolean`       | No       | -       | Whether to include soft-deleted messages                                                               |

**Mutually Exclusive Branches ( `anyOf` )**

* **App Chat**

Identify the conversation via `appId` . When both API Key and login session are supported, `Authorization` takes precedence over token/Cookie.

| Field        | Type            | Required | Default | Constraints & Description                                                                                                                                                                        |
| ------------ | --------------- | -------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `appId`      | `string`        | Yes      | -       | Application ID authenticated with the request header credentials allowed by this endpoint. pattern: `^[0-9a-fA-F]{24}$`                                                                          |
| `sourceType` | `string` (enum) | No       | -       | Session resource type associated with `appId` . Defaults to `app` ; pass the matching `sourceType` for assistant builder sessions. Allowed values: `app` , `chatAgentHelper` , `workflowBuilder` |

**Default Identity** : Omit `customUid` and `authProxy` to execute using the team member identity associated with the credential.

**Custom end user ( `customUid` )**: Tag end users from your own system via `customUid` without changing the authenticating member or permissions. Passed as workflow `userId` and used to scope chat management.

| Field       | Type     | Required | Default | Constraints & Description                                                                                                                                                                                                                                                                                      |
| ----------- | -------- | -------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `customUid` | `string` | Yes      | -       | Supported only for standard app API Key calls. Exact match against the external user ID ( `outLinkUid` , not `tmbId` ). Omit to keep full scope or pass to restrict reads, updates, and deletions (max 1024 chars, cannot be empty or `null` , does not change member identity). minLength: 1; maxLength: 1024 |

**Proxy Team Member ( `authProxy` )**: Act on behalf of another member in the same team via `authProxy` . Available only on personal API keys with `authProxy` enabled; mutually exclusive with `customUid` .

| Field                | Type     | Required | Default | Constraints & Description                                                                                                                                                                             |
| -------------------- | -------- | -------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `authProxy`          | `object` | Yes      | -       | API Key proxy caller identity. Available only for personal keys with `authProxy` enabled; specify `tmbId` or `username` ( `tmbId` takes precedence without falling back to `username` on invalid ID). |
| `authProxy.tmbId`    | `string` | Yes      | -       | **Branch: By Team Member ID** . Proxied team member ID ( `tmbId` ), takes precedence over `username` . pattern: `^[0-9a-fA-F]{24}$`                                                                   |
| `authProxy.username` | `string` | Yes      | -       | **Branch: By Username** . Proxied team member username. minLength: 1; maxLength: 128                                                                                                                  |

* **Skill Debug Session**

Identify the debug session via `skillId` (takes precedence over `appId` and ignores `sourceType` ), authenticated with allowed request header credentials.

| Field     | Type     | Required | Default | Constraints & Description                                                                               |
| --------- | -------- | -------- | ------- | ------------------------------------------------------------------------------------------------------- |
| `skillId` | `string` | Yes      | -       | Skill Edit debug ID authenticated with allowed request header credentials. pattern: `^[0-9a-fA-F]{24}$` |

* **Share-Link Chat**

Resolves the underlying app via `outLinkAuthData` , taking precedence over `skillId` and `appId` (ignoring `sourceType` ). Protected links still validate login cookies/tokens and never fall back to standard auth on failure.

| Field                        | Type     | Required | Default | Constraints & Description                                                                                                                            |
| ---------------------------- | -------- | -------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| `outLinkAuthData`            | `object` | Yes      | -       | Share-link auth payload ( `shareId` / `outLinkUid` ). Overrides `skillId` and `appId` ; protected links still validate login session cookies/tokens. |
| `outLinkAuthData.shareId`    | `string` | Yes      | -       | Share link ID. minLength: 1                                                                                                                          |
| `outLinkAuthData.outLinkUid` | `string` | Yes      | -       | External share user ID. minLength: 1                                                                                                                 |

* **App API Key (no appId required)**

When authorizing with an app-bound App API Key, omit `appId` and `sourceType` ; the server resolves the bound app with `sourceType` fixed to `app` . Personal keys and login sessions cannot omit `appId` , and an explicit `appId` does not override an App API Key binding.

**Default Identity** : Omit `customUid` and `authProxy` to execute using the team member identity associated with the credential.

**Custom end user ( `customUid` )**: Tag end users from your own system via `customUid` without changing the authenticating member or permissions. Passed as workflow `userId` and used to scope chat management.

| Field       | Type     | Required | Default | Constraints & Description                                                                                                                                                                                                                                                                                      |
| ----------- | -------- | -------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `customUid` | `string` | Yes      | -       | Supported only for standard app API Key calls. Exact match against the external user ID ( `outLinkUid` , not `tmbId` ). Omit to keep full scope or pass to restrict reads, updates, and deletions (max 1024 chars, cannot be empty or `null` , does not change member identity). minLength: 1; maxLength: 1024 |

#### Shared Parameters Across Branches

| Field    | Type                                                     | Required | Default | Constraints & Description                       |
| -------- | -------------------------------------------------------- | -------- | ------- | ----------------------------------------------- |
| `anchor` | `object \| array \| string \| number \| boolean \| null` | No       | -       | Current anchor position (such as `chunkIndex` ) |

**Mutually Exclusive Branches ( `anyOf` )**

* **Page Backward ( `prevId` )**

| Field      | Type      | Required | Default | Constraints & Description                                                                                                                                            |
| ---------- | --------- | -------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `prevId`   | `string`  | Yes      | -       | Cursor data ID for paging backward                                                                                                                                   |
| `pageSize` | `integer` | No       | `20`    | **Mutually Exclusive Group: Pagination Parameters** . Target messages per page (default 20, max 500; may be slightly exceeded to complete turn boundaries). max: 500 |

* **Page Forward ( `nextId` )**

| Field      | Type      | Required | Default | Constraints & Description                                                                                                                                            |
| ---------- | --------- | -------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `nextId`   | `string`  | Yes      | -       | Cursor data ID for paging forward                                                                                                                                    |
| `pageSize` | `integer` | No       | `20`    | **Mutually Exclusive Group: Pagination Parameters** . Target messages per page (default 20, max 500; may be slightly exceeded to complete turn boundaries). max: 500 |

* **Anchor Record ( `initialId` )**

| Field       | Type      | Required | Default | Constraints & Description                                                                                                                                            |
| ----------- | --------- | -------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `initialId` | `string`  | Yes      | -       | Initial anchor message data ID                                                                                                                                       |
| `pageSize`  | `integer` | No       | `20`    | **Mutually Exclusive Group: Pagination Parameters** . Target messages per page (default 20, max 500; may be slightly exceeded to complete turn boundaries). max: 500 |

* **Default Latest Page**

| Field      | Type      | Required | Default | Constraints & Description                                                                                                                                            |
| ---------- | --------- | -------- | ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `pageSize` | `integer` | No       | `20`    | **Mutually Exclusive Group: Pagination Parameters** . Target messages per page (default 20, max 500; may be slightly exceeded to complete turn boundaries). max: 500 |

## Request Examples

Replace `YOUR_API_KEY` and placeholder IDs before running. Self-hosted users should replace the base URL with `<instance>/api` .

### cURL Example

```bash
curl --fail-with-body -X POST "https://cloud.fastgpt.io/api/core/chat/record/getRecords_v2" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  --data-raw '{
  "appId": "68ad85a7463006c963799a05",
  "prevId": "68ad85a7463006c963799a04"
}'
```

### Minimal Valid JSON Body

```json
{
  "appId": "68ad85a7463006c963799a05",
  "prevId": "68ad85a7463006c963799a04"
}
```

## Response Schema & Examples

Successful `/api/*` calls return the standard FastGPT envelope `{ "code": 200, "statusText": "", "message": "", "data": ... }` , where `data` matches the `200` schema below (when a payload schema is declared; otherwise refer to the status description for runtime `data` semantics).

### HTTP 200

Successfully returned chat records

**Content-Type** : `application/json`

| Field         | Type             | Required | Default | Constraints & Description                                                                                      |
| ------------- | ---------------- | -------- | ------- | -------------------------------------------------------------------------------------------------------------- |
| `hasMorePrev` | `boolean`        | Yes      | -       | Whether earlier messages exist before the current slice                                                        |
| `hasMoreNext` | `boolean`        | Yes      | -       | Whether newer messages exist after the current slice                                                           |
| `list`        | `object[]`       | Yes      | -       | Chronological list of chat records (use `dataId` as the canonical identifier)                                  |
| `total`       | `integer`        | Yes      | -       | min: -9007199254740991; max: 9007199254740991                                                                  |
| `prevCursor`  | `string \| null` | Yes      | -       | Cursor `dataId` for paging backward ( `prevId` ; server locates the Human turn start; `null` when unavailable) |
| `nextCursor`  | `string \| null` | Yes      | -       | Cursor `dataId` for paging forward ( `nextId` ; server locates the AI turn end; `null` when unavailable)       |

#### Polymorphic Field: `list`

* **Variant 1** ( `obj="Human"` ): `obj` , `value` , `hideInUI` , `useAgentSandbox` , `totalQuoteList` , `toolCiteLinks` , `errorText` , `llmModuleAccount`
* **Variant 2** ( `obj="System"` ): `obj` , `value` , `useAgentSandbox` , `totalQuoteList` , `toolCiteLinks` , `errorText` , `llmModuleAccount` , `historyPreviewLength`
* **Variant 3** ( `obj="AI"` ): `obj` , `value` , `memories` , `userGoodFeedback` , `userBadFeedback` , `customFeedbacks` , `adminFeedback` , `isFeedbackRead`
