---
title: "POST /api/v1/{context_id}/chat"
method: POST
path: "/api/v1/{context_id}/chat"
---

# POST /api/v1/{context_id}/chat

`POST /api/v1/{context_id}/chat`

Phase 7.5 — Spectron-as-agent chat endpoint. Resolves the session, retrieves context via the unified /query router, and calls the configured LLM provider; then, only after a successful synthesis (or a tier-2 cache hit), stores the user message and the assistant response via /facts and emits a response_trace. A failed synthesis writes no turn, fact, or response_trace (a retrieval_trace recording the query may still be written). Set `stream=true` for SSE.

## Path parameters

- `context_id` string, required

## Request body

- ChatRequestJson
  - `bypassCache` boolean — Phase 7.6 — when `true` skips the tier-2 response cache and forces a fresh tier-3 call. Defaults to `false`.
  - `labels` string[] — Descriptive labels for rows the chat persists.
  - `message` string, required
  - `model` string, nullable
  - `scopes` array[] — A DNF scope selector: an OR of conjunctive clauses. Each clause is an array of scope paths, ALL of which a reader must cover (AND); the outer array is the OR. E.g. [["team/a"],["team/b","clearance/secret"]] means team/a OR (team/b AND clearance/secret). Empty means unscoped (the caller's default region). A bare string is also accepted as a singleton clause.
    - string[]
  - `sessionId` string, nullable
  - `stream` boolean
  - `suppressMarkers` boolean — When `true`, the reply text carries no inline citation marker in either form (`[S1]` or bare `S1`); `citations` still names every source the reply cited before the markers were removed. Defaults to `false`.

## Response `200`

- ChatResponseJson
  - `citations` CitationJson[], required — Sources the reply cited, one per `[S1]`-style marker.
    - `documentTitle` string, nullable
    - `id` string, required
    - `kind` string, required
    - `marker` string, required
    - `occurredAt` string, nullable
    - `positionPercent` integer, nullable
    - `role` string, nullable — Conversational role of a cited conversational row (`user` / `assistant` / `system` / `tool`), so callers can tell a cited assistant reply (derived text) from a user-asserted turn. Carried by `memory_chunk` and `turn` citations; absent for non-conversational rows and legacy rows with no recorded role.
    - `score` number, float, required
    - `snippet` string, required
  - `memoryUpdates` ExtractionResultJson, required
    - `actions` ActionSummaryJson[], required
      - `actor` string, required
      - `memoryCategory` 'identity' | 'knowledge' | 'context', required — Memory category classification applied during extraction.
      - `object` string, nullable — The acted-on thing as the extraction named it, whether or not it resolved to a graph entity.
      - `occurredAt` string, nullable
      - `summary` string, required
      - `verb` string, required
    - `attributes` AttributeSummaryJson[], required
      - `entityId` string, required
      - `id` string, required
      - `key` string, required
      - `memoryCategory` 'identity' | 'knowledge' | 'context', required — Memory category classification applied during extraction.
      - `value` string, required
    - `corrections` CorrectionSummaryJson[], required
      - `entityId` string, required
      - `key` string, required
      - `newValue` string, required
      - `oldValue` string, required
    - `entities` EntitySummaryJson[], required
      - `entityType` string, required
      - `id` string, required
      - `isNew` boolean, required
      - `memoryCategory` 'identity' | 'knowledge' | 'context', required — Memory category classification applied during extraction.
      - `name` string, required
    - `instructions` InstructionSummaryJson[], required
      - `description` string, required
      - `id` string, required
      - `label` string, required
    - `relations` RelationSummaryJson[], required
      - `label` string, required
      - `memoryCategory` 'identity' | 'knowledge' | 'context', required — Memory category classification applied during extraction.
      - `object` string, required
      - `subject` string, required
    - `turnId` string, required
    - `uncertainties` UncertaintySummaryJson[], required
      - `about` string, required
      - `reason` string, required
  - `reply` string, required
  - `sessionId` string, required
  - `traceId` string, required

## Other responses

- `400` — Invalid request
- `401` — Unauthorized
- `422` — Invalid context id
- `503` — Server too busy: the per-pod in-flight request cap was exceeded. Retry per the `Retry-After` header.

## Changes

- **2026-08-24** `9f1598713067` — 4 info
  - added the new optional request property `suppressMarkers`
  - added the non-success response with the status `503`
  - added the required property `citations` to the response with the `200` status
  - added the required property `memoryUpdates/actions` to the response with the `200` status
- **2026-06-16** `6ad06b1fefc4` — 1 warning, 1 info
  - removed the request property `scope`
  - added the new optional request property `scopes`
- **2026-06-08** `741d58b9ef89` — 1 warning, 1 info
  - removed the request property `scopes`
  - added the new optional request property `scope`

[Change history](https://skmtc.dev/surrealdb/apis/spectron/changes/api/v1/:context_id/chat/post.md)

---

[API](https://skmtc.dev/surrealdb/apis/spectron.md) · [All operations](https://skmtc.dev/surrealdb/apis/spectron/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/surrealdb/spectron/revisions/9f1598713067/schema)
