List chat sessions

List every conversation the caller can open in the organization, most recent activity (updatedAt) first: their own whose touched spaces they all reach with chat:read; with ?spaceId=, those whose touched spaces include that space, or that touched none yet (a conversation that has acted nowhere holds no space data). Ignores X-Space-Id (like every /api/orgs/{orgId} route); admitted when some reachable space grants chat:read. A credential confined to spaces (pinned to one, or carrying a space allowlist, such as the bearer of a chat turn) is refused (403). Keyset-paginated: when hasMore is true, pass the last session's id as ?startingAfter=, or follow the RFC 5988 Link: <…>; rel="next" response header. A session whose activity moves it to the head while you page is not repeated later in that walk; re-read the first page to see it.

GET/api/orgs/{orgId}/chat/sessions

Authorization

better-auth.session_token<token>

Cookie session from Better Auth. Requires X-Org-Id header for org-scoped routes.

In: cookie

Path Parameters

orgId*string

Organization ID.

Query Parameters

limit?integer

Page size. Out-of-range or non-numeric values fall back to 100.

Default100
Range1 <= value <= 100
spaceId?string

Keep the conversations that touched this space or no space yet; the space is one the caller must read with chat:read (else a 400 naming spaceId). The cursor and the page size apply within the filtered list.

q?string

Case-insensitive substring search on the session title (%, _ and \ match literally). Surrounding whitespace is ignored; blank means no filter. Untitled sessions never match. Combines with startingAfter and limit. Longer than 200 characters is a 400.

Lengthlength <= 200
startingAfter?string

Keyset cursor — the id of the last session of the previous page. An id that is not one of the caller's sessions in this (filtered) list is a 400.

curl -X GET "https://your-instance/api/orgs/string/chat/sessions"
{
  "object": "list",
  "data": [
    {
      "object": "chat_session",
      "id": "string",
      "title": "string",
      "generating": true,
      "unread": true,
      "skill_discovery": true,
      "pins": [
        {
          "id": "string",
          "status": "injected",
          "chars": 0
        }
      ],
      "spaceId": "string",
      "restricted": true,
      "space_ids": [
        "string"
      ],
      "createdAt": "2019-08-24T14:15:22Z",
      "updatedAt": "2019-08-24T14:15:22Z"
    }
  ],
  "hasMore": true
}

{
  "type": "https://docs.appstrate.dev/errors/validation-failed",
  "title": "Validation Failed",
  "status": 400,
  "detail": "name: Invalid input: expected string, received undefined (+2 more)",
  "code": "validation_failed",
  "request_id": "req_abc123",
  "errors": [
    {
      "field": "name",
      "code": "required",
      "message": "Invalid input: expected string, received undefined"
    },
    {
      "field": "email",
      "code": "invalid_format",
      "message": "Invalid email address"
    },
    {
      "field": "age",
      "code": "invalid_type",
      "message": "Invalid input: expected number, received string"
    }
  ]
}

{
  "type": "https://docs.appstrate.dev/errors/forbidden",
  "title": "Forbidden",
  "status": 403,
  "detail": "Insufficient permissions",
  "code": "forbidden",
  "request_id": "req_abc123"
}