CortexDB Docs
API Reference

POST /v1/compose

Compose a structured markdown document from a scope's memory, with inline citations.

POST
/v1/compose
AuthorizationBearer <token>

PASETO v4 public token (or deployment gate key). Auth-disabled dev instances accept any caller.

In: header

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

curl -X POST "https://example.com/v1/compose" \  -H "Content-Type: application/json" \  -d '{    "scope": "string",    "brief": "string"  }'
Empty

What it does

/v1/compose is recall composed with an LLM writing pass: it retrieves a pack for the scope, then asks the answer model to write a structured markdown document that fulfils your brief, with inline citation markers back to the evidence. Think of it as /v1/answer for long-form output — a briefing, dossier, or summary rather than a single answer.

The response is { pack_id, document, citations, provenance, diagnostics }:

  • document — the composed markdown, with inline markers like [S1], [S2].
  • citations[{ marker, layer, id, support_strength }] mapping each marker in document to the memory it came from (verified live: markers resolve to layer: "event" ids with a support_strength).
  • provenance / diagnostics — the same recall provenance contract as recall and answer.

Shaping the document

FieldEffect
brief (required)The instruction — what the document should cover.
lengthbrief · standard · deep — overall length target.
depthstandard · exhaustive — how hard recall works to gather evidence.
structureAn array of section headings to force a specific outline.
citationsToggle inline citation markers on/off.
filtersSame recall filters.metadata shape as recall.
max_tokensOutput ceiling for the composed document.
include_contextReturn the recalled context block alongside the document.

Needs the answer lane — same as /v1/answer

Composition runs the LLM, so self-hosted it requires the answer lane (CORTEX_ANSWER_*) to be configured and is disabled until it's set — the claude-* default is a managed-cloud value. On a content-only instance with no answer lane, use recall for retrieval without generation. See Self-hosting defaults.

Composition is not instant

Like /v1/answer, a compose call blocks on the LLM — a multi-paragraph document can take tens of seconds depending on length/depth and your answer model. Budget your client timeout accordingly.

On this page