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

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

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

Write a single fact. Dispatches on `infer` mode: full (LLM-extracted), triples (caller-supplied), preview (dry run), none (literal).

## Path parameters

- `context_id` string, required

## Request body

- FactsRequest — Request body for `POST /api/v1/{ctx}/facts`.
  - `infer` 'full' | 'triples' | 'preview' | 'none' — Inference mode for the `/facts` write API. Decides which extraction path runs and which provenance kind the reconciler tags the writes with (see the per-variant docs below).
  - `labels` Label[] — Descriptive labels for the persisted rows (scope-model §5). Accepted and recorded on the wire now; row-level application lands in a follow-up (cf. `ScopeView` — accepted but behaves as `Strict`).
  - `memory_category` 'identity' | 'knowledge' | 'context' — Memory category classification applied during extraction.
  - `observed_at` string, nullable — Optional RFC3339 known/observed time for the written facts (backfill). When set, the facts are stamped with this `created_at` (known time), so `as_of` queries see them dated to when they were observed rather than to wall-clock ingest. `None` keeps the default (facts dated to ingest time).
  - `role` 'user' | 'assistant' | 'system' | 'tool' — Role of a conversation turn participant.
  - `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[]
  - `session_id` string, nullable — Existing session id to attach the turn to. When absent, the handler auto-creates a session before the write.
  - `text` string, nullable — Free-form text (used by `full`, `preview`, `none`). Optional only when `infer = triples` is supplied.
  - `triples` Triple[] — Caller-supplied triples (only consumed when `infer = triples`).
    - `entity` TripleEntity, required — Entity descriptor on a [`Triple`].
      - `name` string, required
      - `type` string, required
    - `key` string, required
    - `memory_category` 'identity' | 'knowledge' | 'context' — Memory category classification applied during extraction.
    - `target` TripleEntity — Entity descriptor on a [`Triple`].
      - `name` string, required
      - `type` string, required
    - `value` string, nullable

## Response `200`

- FactsResponseJson
  - `chunkId` string
  - `extraction` ExtractionResultJson
    - `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
  - `mode` 'full' | 'triples' | 'preview' | 'none', required — Inference mode for the `/facts` write API. Decides which extraction path runs and which provenance kind the reconciler tags the writes with (see the per-variant docs below).
  - `preview` boolean
  - `sessionId` string, required
  - `turnId` string

## Other responses

- `400` — Invalid request
- `401` — Unauthorized
- `409` — Idempotency-Key reused with a different body
- `422` — Invalid context id

---

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