> ## Documentation Index
> Fetch the complete documentation index at: https://docs.b3os.org/llms.txt
> Use this file to discover all available pages before exploring further.

# GET /v1/ai/workflow/chat/history

Get chat history for a conversation, workflow, or session

` GET /v1/ai/workflow/chat/history `

Get chat history for a conversation, workflow, or session

## Parameters

### ` conversationId ` (query, optional)

Conversation ID (stable; preferred, used by V3 chat)

- ` value `: type ` string `

### ` workflowId ` (query, optional)

Workflow ID (for edit page)

- ` value `: type ` string `

### ` sessionId ` (query, optional)

Session ID (for create page)

- ` value `: type ` string `

### ` limit ` (query, optional)

Maximum number of messages to return (default: 20, max: 100)

- ` value `: type ` integer `

### ` before ` (query, optional)

RFC3339 keyset cursor; return only messages strictly older than this createdAt (reverse pagination)

- ` value `: type ` string `

### ` beforeId ` (query, optional)

Keyset cursor tiebreak; the oldest loaded row's id, paired with before, so a tied createdAt at a page boundary is not skipped

- ` value `: type ` string `

## Request body (optional)

Content type: ` application/json `

- ` value `: type ` object `

## Responses

### ` 200 ` — OK

Content type: ` application/json `

- ` value `: type ` object `

  - ` code `: type ` integer `

    - example: ` 200 `

  - ` data `: type ` array `

    - ` array item `: type ` object `

      - ` agentVersion `: type ` string `

      - ` content `: type ` string `

      - ` conversationId `: type ` string `

      - ` createdAt `: type ` string `

      - ` id `: type ` string `

      - ` imageUrls `: type ` array `

        - ` array item `: type ` string `

      - ` linkedRunFinishedAt `: type ` string `

      - ` linkedRunId `: type ` string `

      - ` linkedRunStartedAt `: type ` string `

      - ` linkedRunStatus `: type ` string `

        - enum: ` ["running","waiting","success","partial","failure","cancelled"] `

      - ` organizationId `: type ` string `

      - ` role `: type ` string `

      - ` senderUserId `: type ` string `

      - ` sessionId `: type ` string `

      - ` structuredPayload `: type ` array `

        - ` array item `: type ` integer `

      - ` tokensUsed `: type ` integer `

      - ` turnId `: type ` string `

      - ` workflowId `: type ` string `

  - ` message `: type ` string `

    - example: ` "success" `

  - ` requestId `: type ` string `

### ` 400 ` — Bad Request

Content type: ` application/json `

- ` value `: type ` object `

  - ` code `: type ` integer `

  - ` details `: type ` array `

    - ` array item `: type ` unknown `

  - ` message `: type ` string `

  - ` requestId `: type ` string `

## Request examples

### cURL

```curl
curl -X GET 'https://api.example.com/v1/ai/workflow/chat/history' \
  -H 'Authorization: Bearer YOUR_API_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{}'
```

### JavaScript

```javascript
const response = await fetch('https://api.example.com/v1/ai/workflow/chat/history', {
  method: 'GET',
  headers: {
      "Authorization": "Bearer YOUR_API_TOKEN",
      "Content-Type": "application/json"
  },
  body: JSON.stringify({})
});

const data = await response.json();
console.log(data);
```

### Python

```python
import requests

headers = {
    'Authorization': 'Bearer YOUR_API_TOKEN'
}

response = requests.get('https://api.example.com/v1/ai/workflow/chat/history', headers=headers, json={})
print(response.json())
```

### Go

```go
package main

import (
	"fmt"
	"io"
	"net/http"
	"strings"
)

func main() {
	body := strings.NewReader(`{}`)
	req, _ := http.NewRequest("GET", "https://api.example.com/v1/ai/workflow/chat/history", body)
	req.Header.Set("Authorization", "Bearer YOUR_API_TOKEN")
	req.Header.Set("Content-Type", "application/json")

	resp, _ := http.DefaultClient.Do(req)
	defer resp.Body.Close()
	result, _ := io.ReadAll(resp.Body)
	fmt.Println(string(result))
}
```