---
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' | 'full_context', 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

---

[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/versions/52b41ab517b6/schema)
