Threads

REST endpoints for threads. Bearer-auth required.

GET /api/threads

List threads.

Query parameters

  • limit (optional): Page size (1–100, default 100).
  • after (optional): Keyset cursor — return the page after this row (next page).
  • before (optional): Keyset cursor — return the page before this row (prev page).
  • ids (optional): Comma-separated list of IDs. Narrows results to these IDs within the caller's accessible scope (does not bypass access checks).
  • filter (optional): Nested filter expression (<Entity>Filter): AND/OR/NOT + per-field comparison operators + relation traversal. JSON-encoded on the query string.
  • orderBy (optional): Multi-key sort (<Entity>OrderBy[]): array of { field: direction } applied in order. Directions: asc/desc plus the four explicit nulls variants. JSON-encoded on the query string.
  • workspace_id (optional): Filter to threads in this workspace. When omitted, returns threads across every workspace the caller is a member of (admins see all).
  • user_id (optional): Filter to threads where this user is a participant.
  • agent_id (optional): Filter to threads where this agent is a participant.
  • swarm_id (optional): Filter to threads where this swarm is a participant.
  • parent_message_id (optional): Filter to sub-threads rooted at this message. Pass the literal string null to list only top-level threads.
  • include_deleted (optional): Soft-deleted thread visibility. false (default) — active rows only. true — active plus soft-deleted. only — soft-deleted only (trash view).
  • created_by_user_id (optional): Shorthand: filter where createdByUserId equals this value.

Response

JSON
{
  "data": [
    {
      "id": "<...>",
      "workspaceId": "<...>",
      "title": "<...>",
      "createdByUserId": "<...>",
      "parentMessageId": "<...>",
      "lastMessageAt": "<...>",
      "createdAt": "<...>",
      "updatedAt": "<...>",
      "unreadCount": "<...>"
    }
  ],
  "pageInfo": {
    "total": "number",
    "hasNextPage": "boolean",
    "hasPreviousPage": "boolean",
    "startCursor": "string",
    "endCursor": "string"
  }
}

POST /api/threads

Create a thread

Request body

JSON
{
  "workspaceId": "string",
  "title?": "string",
  "parentMessageId?": "string"
}

Response

JSON
{
  "id": "string",
  "workspaceId": "string",
  "title": "string",
  "createdByUserId": "string",
  "parentMessageId": "string",
  "lastMessageAt": "string",
  "createdAt": "string",
  "updatedAt": "string",
  "unreadCount": "integer"
}

GET /api/threads/{id}

Get a thread by ID.

Path parameters

  • id (required): Thread to retrieve.

Response

JSON
{
  "id": "string",
  "workspaceId": "string",
  "title": "string",
  "createdByUserId": "string",
  "parentMessageId": "string",
  "lastMessageAt": "string",
  "createdAt": "string",
  "updatedAt": "string",
  "unreadCount": "integer"
}

PATCH /api/threads/{id}

Update a thread

Path parameters

  • id (required):

Request body

JSON
{
  "title?": "string"
}

Response

JSON
{
  "id": "string",
  "workspaceId": "string",
  "title": "string",
  "createdByUserId": "string",
  "parentMessageId": "string",
  "lastMessageAt": "string",
  "createdAt": "string",
  "updatedAt": "string",
  "unreadCount": "integer"
}

DELETE /api/threads/{id}

Delete a thread.

Path parameters

  • id (required): Thread to soft-delete.

Response

JSON
{
  "success": "boolean"
}

DELETE /api/threads/{id}/purge

Permanently delete a soft-deleted thread.

Path parameters

  • id (required): Soft-deleted thread to permanently delete.

Response

JSON
{
  "success": "boolean"
}

PUT /api/threads/{id}/read

Mark a thread as read

Advance the caller's read pointer in this thread to the given message (or the latest message if omitted). Idempotent — pointer only moves forward.

Path parameters

  • id (required):

Request body

JSON
{
  "messageId?": "string"
}

Response

JSON
{
  "id": "string",
  "workspaceId": "string",
  "title": "string",
  "createdByUserId": "string",
  "parentMessageId": "string",
  "lastMessageAt": "string",
  "createdAt": "string",
  "updatedAt": "string",
  "unreadCount": "integer"
}

POST /api/threads/{id}/restore

Restore a thread.

Path parameters

  • id (required): Soft-deleted thread to restore.

Response

JSON
{
  "id": "string",
  "workspaceId": "string",
  "title": "string",
  "createdByUserId": "string",
  "parentMessageId": "string",
  "lastMessageAt": "string",
  "createdAt": "string",
  "updatedAt": "string",
  "unreadCount": "integer"
}