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

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

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

Query memory and return formatted context for LLM prompt injection

## Path parameters

- `context_id` string, required

## Request body

- ContextQueryRequestJson
  - `k` integer — Max hits to return (default 10, max 50).
  - `labels` string[] — Label filter (design §4): `key=value` strings the result rows must all carry; applied after the scope predicate (never widening).
  - `lens` 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[]
  - `query` string, required
  - `scopeView` string, nullable — Scope read breadth: `strict` (default) | `merged` | `crossTeam` (§7.1).

## Response `200`

- ContextQueryResponseJson
  - `context` string, required
  - `queryMs` integer, required
  - `tier` 'direct' | 'cache' | 'hybrid' | 'escalated', required — Which tier resolved the query. Exposed on the response for the CLI's `--tier` flag (Phase 8) and so callers can tell when their query went all the way to tier 4.

## 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` — 1 warning, 2 info
  - added the new `escalated` enum value to the `tier` response property for the response status `200`
  - added the non-success response with the status `503`
  - removed the `full_context` enum value from the `tier` response property for the response status `200`
- **2026-06-16** `52b41ab517b6` — 4 warning
  - added the new `cache` enum value to the `tier` response property for the response status `200`
  - added the new `direct` enum value to the `tier` response property for the response status `200`
  - added the new `full_context` enum value to the `tier` response property for the response status `200`
  - added the new `hybrid` enum value to the `tier` response property for the response status `200`
- **2026-06-16** `6ad06b1fefc4` — 1 breaking
  - the `lens/items/` request property type/format changed from `string`/`` to `array`/``
- **2026-06-08** `741d58b9ef89` — 1 breaking, 4 info
  - the `lens/items/` request property type/format changed from `array`/`` to `string`/``
  - removed the `cache` enum value from the `tier` response property for the response status `200`
  - removed the `direct` enum value from the `tier` response property for the response status `200`
  - removed the `full_context` enum value from the `tier` response property for the response status `200`
  - …1 more

[Change history](https://skmtc.dev/surrealdb/apis/spectron/changes/api/v1/:context_id/context/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)
