---
agent:
  instructions: "Use this search API to find relevant content across this site with keywords or natural-language queries, instead of crawling individual pages. Results are returned in Markdown."
  endpoint: "https://segmentstream.com/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# Search chat history

POST /api/workspaces/{workspaceId}/agent/conversations/search

## Endpoint

**POST**`/api/workspaces/{workspaceId}/agent/conversations/search`

Locate messages by text, sender, chat or time range before reading a transcript. This is a repeatable read. See chats_readChat. Required personal key scopes: workspace:view, conversations:read.

## Authorization

Bearer token · workspace:view · conversations:read

## Parameters

- `workspaceId` *path · uuid · required*

  Workspace UUID returned by list workspaces.

- `API-Version` *header · string · optional*

  Optional platform API major version. Omit to use the current default.

  Allowed values: 1

## Request body

### application/json schema

```
{
  "type": "object",
  "properties": {
    "q": {
      "type": "string",
      "maxLength": 1000,
      "description": "Text to search for in the chat archive."
    },
    "provider": {
      "type": "string",
      "minLength": 1,
      "maxLength": 512,
      "description": "Provider associated with the connection, event or channel."
    },
    "chatId": {
      "type": "string",
      "minLength": 1,
      "maxLength": 512,
      "description": "Chat identifier assigned by the channel provider."
    },
    "threadId": {
      "type": "string",
      "minLength": 1,
      "maxLength": 512,
      "description": "Thread identifier within the chat."
    },
    "senderId": {
      "type": "string",
      "minLength": 1,
      "maxLength": 512,
      "description": "Identifier of the sender at the channel provider."
    },
    "messageId": {
      "type": "string",
      "minLength": 1,
      "maxLength": 512,
      "description": "Identifier of the message."
    },
    "from": {
      "type": "string",
      "minLength": 1,
      "maxLength": 512,
      "description": "Start of the requested reporting interval."
    },
    "to": {
      "type": "string",
      "minLength": 1,
      "maxLength": 512,
      "description": "End of the requested reporting interval."
    },
    "before": {
      "type": "string",
      "minLength": 1,
      "maxLength": 512,
      "description": "Cursor or upper bound used to fetch earlier events."
    },
    "limit": {
      "type": "integer",
      "description": "Maximum number of entries to return."
    },
    "pending": {
      "type": "boolean",
      "description": "Only channel replies still to deliver: reply operations (`operationId` `reply:<key>`) whose newest state is `requested`. A workspace runtime reads its own across chats."
    }
  },
  "additionalProperties": false
}
```

[Full schema and referenced types ↗](https://segmentstream.com/openapi.json)

### Example

```
{
  "q": "daily orders",
  "limit": 10
}
```

## Responses

### `200` Success

### application/json schema

```
{
  "type": "object",
  "properties": {
    "events": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "eventId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 512,
            "description": "Identifier of the event."
          },
          "provider": {
            "type": "string",
            "minLength": 1,
            "maxLength": 512,
            "description": "Provider associated with the connection, event or channel."
          },
          "chatId": {
            "type": "string",
            "minLength": 1,
            "maxLength": 512,
            "description": "Chat identifier assigned by the channel provider."
          },
          "chatType": {
            "type": "string",
            "enum": [
              "group",
              "private",
              "channel"
            ],
            "description": "Provider classification of the conversation."
          },
          "threadId": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 1,
                "maxLength": 512
              },
              {
                "type": "null"
              }
            ],
            "description": "Thread identifier within the chat."
          },
          "participantIds": {
            "type": "array",
            "items": {
              "type": "string",
              "minLength": 1,
              "maxLength": 512
            },
            "maxItems": 100,
            "description": "Provider identifiers of participants in the conversation."
          },
          "senderId": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 1,
                "maxLength": 512
              },
              {
                "type": "null"
              }
            ],
            "description": "Identifier of the sender at the channel provider."
          },
          "senderName": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 100000
              },
              {
                "type": "null"
              }
            ],
            "description": "Sender display name supplied by the channel."
          },
          "senderIsBot": {
            "type": "boolean",
            "description": "Whether the channel identifies the sender as a bot."
          },
          "kind": {
            "type": "string",
            "enum": [
              "inbound",
              "outbound",
              "decision",
              "tool_call",
              "tool_result"
            ],
            "description": "Discriminator identifying the kind of entry."
          },
          "messageId": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 1,
                "maxLength": 512
              },
              {
                "type": "null"
              }
            ],
            "description": "Identifier of the message."
          },
          "replyToMessageId": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 1,
                "maxLength": 512
              },
              {
                "type": "null"
              }
            ],
            "description": "Identifier of the reply to message."
          },
          "sessionId": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 1,
                "maxLength": 512
              },
              {
                "type": "null"
              }
            ],
            "description": "Identifier of the agent session."
          },
          "turnId": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 1,
                "maxLength": 512
              },
              {
                "type": "null"
              }
            ],
            "description": "Agent turn ID associated with the log event."
          },
          "text": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 100000
              },
              {
                "type": "null"
              }
            ],
            "description": "Human-readable content of the message or log entry."
          },
          "decision": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "reply",
                  "silent"
                ]
              },
              {
                "type": "null"
              }
            ],
            "description": "Whether the agent chose to reply or stay silent."
          },
          "reason": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 100000
              },
              {
                "type": "null"
              }
            ],
            "description": "Explanation of the reported status or decision."
          },
          "toolCallId": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 1,
                "maxLength": 512
              },
              {
                "type": "null"
              }
            ],
            "description": "ID of a particular invocation of an agent tool."
          },
          "toolName": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 1,
                "maxLength": 512
              },
              {
                "type": "null"
              }
            ],
            "description": "Name of the invoked agent tool."
          },
          "argsSummary": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 100000
              },
              {
                "type": "null"
              }
            ],
            "description": "Short rendering of the arguments passed to the tool."
          },
          "status": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "requested",
                  "completed",
                  "failed",
                  "rejected",
                  "cancelled",
                  "unknown",
                  "sent",
                  "uncertain"
                ]
              },
              {
                "type": "null"
              }
            ],
            "description": "Current lifecycle or execution status."
          },
          "operationId": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 1,
                "maxLength": 512
              },
              {
                "type": "null"
              }
            ],
            "description": "Identifier of the operation."
          },
          "requestedBy": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "id": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 512,
                    "description": "Identifier of this resource."
                  },
                  "kind": {
                    "type": "string",
                    "enum": [
                      "member",
                      "service"
                    ],
                    "description": "Discriminator identifying the kind of entry."
                  },
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 512,
                    "allOf": [
                      {
                        "description": "Name identifying this item within its parent resource."
                      }
                    ]
                  },
                  "via": {
                    "type": "string",
                    "enum": [
                      "oauth",
                      "hq",
                      "service"
                    ],
                    "description": "Mechanism through which the operation or event occurred."
                  },
                  "clientId": {
                    "anyOf": [
                      {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 512
                      },
                      {
                        "type": "null"
                      }
                    ],
                    "description": "Identifier of the client."
                  },
                  "clientName": {
                    "anyOf": [
                      {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 512
                      },
                      {
                        "type": "null"
                      }
                    ],
                    "description": "Display name of the client application."
                  },
                  "attribution": {
                    "type": "string",
                    "maxLength": 2000,
                    "description": "Empty only for a member's own reply, sent unsigned; the archive refuses it on any other."
                  }
                },
                "required": [
                  "id",
                  "kind",
                  "name",
                  "via",
                  "clientId",
                  "clientName",
                  "attribution"
                ],
                "additionalProperties": false
              },
              {
                "type": "null"
              }
            ],
            "description": "Identity or component that requested the operation."
          },
          "url": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 1,
                "maxLength": 2000
              },
              {
                "type": "null"
              }
            ],
            "description": "Address at which the resource can be accessed."
          },
          "attachments": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 512,
                  "description": "Identifier of this resource."
                },
                "kind": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 512,
                  "description": "Discriminator identifying the kind of entry."
                },
                "filename": {
                  "type": "string",
                  "maxLength": 100000,
                  "description": "File name supplied for this attachment."
                },
                "contentType": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 512,
                  "description": "Media type describing the content."
                },
                "size": {
                  "anyOf": [
                    {
                      "type": "number"
                    },
                    {
                      "type": "string",
                      "enum": [
                        "Infinity",
                        "-Infinity",
                        "NaN"
                      ]
                    }
                  ],
                  "allOf": [
                    {
                      "description": "Size of the resource in the units used by its enclosing object."
                    }
                  ]
                },
                "uniqueId": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 512,
                  "description": "Unique identifier assigned to the attachment."
                }
              },
              "required": [
                "id",
                "kind"
              ],
              "additionalProperties": false
            },
            "maxItems": 100,
            "description": "Files associated with the message."
          },
          "at": {
            "type": "string",
            "minLength": 1,
            "maxLength": 512,
            "allOf": [
              {
                "description": "Time of the recorded event."
              }
            ]
          },
          "sequence": {
            "type": "string",
            "description": "Sequence number used to order entries."
          },
          "storedAt": {
            "type": "string",
            "description": "Time when the item was stored."
          }
        },
        "required": [
          "eventId",
          "provider",
          "chatId",
          "chatType",
          "threadId",
          "participantIds",
          "senderId",
          "senderName",
          "senderIsBot",
          "kind",
          "messageId",
          "replyToMessageId",
          "sessionId",
          "turnId",
          "text",
          "decision",
          "reason",
          "toolCallId",
          "toolName",
          "argsSummary",
          "status",
          "attachments",
          "at",
          "sequence",
          "storedAt"
        ],
        "additionalProperties": false
      },
      "allOf": [
        {
          "description": "Events recorded for the requested resource and interval."
        }
      ]
    },
    "nextCursor": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "description": "Opaque continuation cursor for the next page."
    }
  },
  "required": [
    "events",
    "nextCursor"
  ],
  "additionalProperties": false
}
```

[Full schema and referenced types ↗](https://segmentstream.com/openapi.json)

### Example

```
{
  "events": [],
  "nextCursor": null
}
```

### Response headers

- API-Version

  Supported platform API major version.

- RateLimit

  Remaining quota (r) and seconds until reset (t), when admission is available.

- RateLimit-Policy

  Request quota (q) and window in seconds (w).

- Deprecation

  Present when the operation is deprecated. RFC 9745 date in seconds since the Unix epoch.

- Sunset

  Present when retirement is scheduled. HTTP date of planned removal, per RFC 8594.

### `400` Error

### application/json schema

```
{
  "type": "object",
  "properties": {
    "error": {
      "type": "string",
      "description": "Machine-readable error code or diagnostic reported by the operation."
    },
    "detail": {
      "type": "string",
      "description": "Human-readable explanation of the failure."
    },
    "requestId": {
      "type": "string",
      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|[fF]{8}-[fF]{4}-[fF]{4}-[fF]{4}-[fF]{12})$",
      "format": "uuid",
      "description": "Correlation ID for tracing the request with support."
    },
    "retryable": {
      "type": "boolean",
      "description": "Whether retrying the same failed request may succeed."
    }
  },
  "required": [
    "error",
    "detail",
    "requestId",
    "retryable"
  ],
  "additionalProperties": true
}
```

[Full schema and referenced types ↗](https://segmentstream.com/openapi.json)

### Response headers

- API-Version

  Supported platform API major version.

- RateLimit

  Remaining quota (r) and seconds until reset (t), when admission is available.

- RateLimit-Policy

  Request quota (q) and window in seconds (w).

### `401` Error

### application/json schema

```
{
  "type": "object",
  "properties": {
    "error": {
      "type": "string",
      "description": "Machine-readable error code or diagnostic reported by the operation."
    },
    "detail": {
      "type": "string",
      "description": "Human-readable explanation of the failure."
    },
    "requestId": {
      "type": "string",
      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|[fF]{8}-[fF]{4}-[fF]{4}-[fF]{4}-[fF]{12})$",
      "format": "uuid",
      "description": "Correlation ID for tracing the request with support."
    },
    "retryable": {
      "type": "boolean",
      "description": "Whether retrying the same failed request may succeed."
    }
  },
  "required": [
    "error",
    "detail",
    "requestId",
    "retryable"
  ],
  "additionalProperties": true
}
```

[Full schema and referenced types ↗](https://segmentstream.com/openapi.json)

### Response headers

- API-Version

  Supported platform API major version.

- RateLimit

  Remaining quota (r) and seconds until reset (t), when admission is available.

- RateLimit-Policy

  Request quota (q) and window in seconds (w).

### `403` Error

### application/json schema

```
{
  "type": "object",
  "properties": {
    "error": {
      "type": "string",
      "description": "Machine-readable error code or diagnostic reported by the operation."
    },
    "detail": {
      "type": "string",
      "description": "Human-readable explanation of the failure."
    },
    "requestId": {
      "type": "string",
      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|[fF]{8}-[fF]{4}-[fF]{4}-[fF]{4}-[fF]{12})$",
      "format": "uuid",
      "description": "Correlation ID for tracing the request with support."
    },
    "retryable": {
      "type": "boolean",
      "description": "Whether retrying the same failed request may succeed."
    }
  },
  "required": [
    "error",
    "detail",
    "requestId",
    "retryable"
  ],
  "additionalProperties": true
}
```

[Full schema and referenced types ↗](https://segmentstream.com/openapi.json)

### Response headers

- API-Version

  Supported platform API major version.

- RateLimit

  Remaining quota (r) and seconds until reset (t), when admission is available.

- RateLimit-Policy

  Request quota (q) and window in seconds (w).

### `404` Error

### application/json schema

```
{
  "type": "object",
  "properties": {
    "error": {
      "type": "string",
      "description": "Machine-readable error code or diagnostic reported by the operation."
    },
    "detail": {
      "type": "string",
      "description": "Human-readable explanation of the failure."
    },
    "requestId": {
      "type": "string",
      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|[fF]{8}-[fF]{4}-[fF]{4}-[fF]{4}-[fF]{12})$",
      "format": "uuid",
      "description": "Correlation ID for tracing the request with support."
    },
    "retryable": {
      "type": "boolean",
      "description": "Whether retrying the same failed request may succeed."
    }
  },
  "required": [
    "error",
    "detail",
    "requestId",
    "retryable"
  ],
  "additionalProperties": true
}
```

[Full schema and referenced types ↗](https://segmentstream.com/openapi.json)

### Response headers

- API-Version

  Supported platform API major version.

- RateLimit

  Remaining quota (r) and seconds until reset (t), when admission is available.

- RateLimit-Policy

  Request quota (q) and window in seconds (w).

### `406` Unsupported platform API version

### application/json schema

```
{
  "type": "object",
  "properties": {
    "error": {
      "type": "string",
      "description": "Machine-readable error code or diagnostic reported by the operation."
    },
    "detail": {
      "type": "string",
      "description": "Human-readable explanation of the failure."
    },
    "requestId": {
      "type": "string",
      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|[fF]{8}-[fF]{4}-[fF]{4}-[fF]{4}-[fF]{12})$",
      "format": "uuid",
      "description": "Correlation ID for tracing the request with support."
    },
    "retryable": {
      "type": "boolean",
      "description": "Whether retrying the same failed request may succeed."
    }
  },
  "required": [
    "error",
    "detail",
    "requestId",
    "retryable"
  ],
  "additionalProperties": true
}
```

[Full schema and referenced types ↗](https://segmentstream.com/openapi.json)

### Response headers

- API-Version

  Supported platform API major version.

- RateLimit

  Remaining quota (r) and seconds until reset (t), when admission is available.

- RateLimit-Policy

  Request quota (q) and window in seconds (w).

### `409` Error

### application/json schema

```
{
  "type": "object",
  "properties": {
    "error": {
      "type": "string",
      "description": "Machine-readable error code or diagnostic reported by the operation."
    },
    "detail": {
      "type": "string",
      "description": "Human-readable explanation of the failure."
    },
    "requestId": {
      "type": "string",
      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|[fF]{8}-[fF]{4}-[fF]{4}-[fF]{4}-[fF]{12})$",
      "format": "uuid",
      "description": "Correlation ID for tracing the request with support."
    },
    "retryable": {
      "type": "boolean",
      "description": "Whether retrying the same failed request may succeed."
    }
  },
  "required": [
    "error",
    "detail",
    "requestId",
    "retryable"
  ],
  "additionalProperties": true
}
```

[Full schema and referenced types ↗](https://segmentstream.com/openapi.json)

### Response headers

- API-Version

  Supported platform API major version.

- RateLimit

  Remaining quota (r) and seconds until reset (t), when admission is available.

- RateLimit-Policy

  Request quota (q) and window in seconds (w).

### `429` Request limit reached

### application/json schema

```
{
  "type": "object",
  "properties": {
    "error": {
      "type": "string",
      "description": "Machine-readable error code or diagnostic reported by the operation."
    },
    "detail": {
      "type": "string",
      "description": "Human-readable explanation of the failure."
    },
    "requestId": {
      "type": "string",
      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|[fF]{8}-[fF]{4}-[fF]{4}-[fF]{4}-[fF]{12})$",
      "format": "uuid",
      "description": "Correlation ID for tracing the request with support."
    },
    "retryable": {
      "type": "boolean",
      "description": "Whether retrying the same failed request may succeed."
    }
  },
  "required": [
    "error",
    "detail",
    "requestId",
    "retryable"
  ],
  "additionalProperties": true
}
```

[Full schema and referenced types ↗](https://segmentstream.com/openapi.json)

### Response headers

- Retry-After

  Seconds to wait before retrying the request.

- API-Version

  Supported platform API major version.

- RateLimit

  Remaining quota (r) and seconds until reset (t), when admission is available.

- RateLimit-Policy

  Request quota (q) and window in seconds (w).

### `500` Error

### application/json schema

```
{
  "type": "object",
  "properties": {
    "error": {
      "type": "string",
      "description": "Machine-readable error code or diagnostic reported by the operation."
    },
    "detail": {
      "type": "string",
      "description": "Human-readable explanation of the failure."
    },
    "requestId": {
      "type": "string",
      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|[fF]{8}-[fF]{4}-[fF]{4}-[fF]{4}-[fF]{12})$",
      "format": "uuid",
      "description": "Correlation ID for tracing the request with support."
    },
    "retryable": {
      "type": "boolean",
      "description": "Whether retrying the same failed request may succeed."
    }
  },
  "required": [
    "error",
    "detail",
    "requestId",
    "retryable"
  ],
  "additionalProperties": true
}
```

[Full schema and referenced types ↗](https://segmentstream.com/openapi.json)

### Response headers

- API-Version

  Supported platform API major version.

- RateLimit

  Remaining quota (r) and seconds until reset (t), when admission is available.

- RateLimit-Policy

  Request quota (q) and window in seconds (w).

### `503` Error

### application/json schema

```
{
  "type": "object",
  "properties": {
    "error": {
      "type": "string",
      "description": "Machine-readable error code or diagnostic reported by the operation."
    },
    "detail": {
      "type": "string",
      "description": "Human-readable explanation of the failure."
    },
    "requestId": {
      "type": "string",
      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|[fF]{8}-[fF]{4}-[fF]{4}-[fF]{4}-[fF]{12})$",
      "format": "uuid",
      "description": "Correlation ID for tracing the request with support."
    },
    "retryable": {
      "type": "boolean",
      "description": "Whether retrying the same failed request may succeed."
    }
  },
  "required": [
    "error",
    "detail",
    "requestId",
    "retryable"
  ],
  "additionalProperties": true
}
```

[Full schema and referenced types ↗](https://segmentstream.com/openapi.json)

### Response headers

- API-Version

  Supported platform API major version.

- RateLimit

  Remaining quota (r) and seconds until reset (t), when admission is available.

- RateLimit-Policy

  Request quota (q) and window in seconds (w).

[Read as Markdown ↗](https://segmentstream.com/docs/api/chats/chats_searchChats.md)
