Skip to main content
POST

Authorizations

Authorization
string
header
required

Every request authenticates with an API key: Authorization: Bearer {API_KEY}. App endpoints take an app API key; knowledge endpoints take a knowledge base API key (Get Started).

Keep keys server-side; never embed them in client code. Requests with a missing or invalid key fail with HTTP 401 (unauthorized).

Path Parameters

knowledge_base_id
string<uuid>
required

Knowledge base ID: the last segment of the Service API endpoint shown in the knowledge base's API Access dialog (…/knowledge-fs/spaces/<knowledge base ID>), and the segment after /datasets/new/ in the address bar.

Body

application/json

Unknown fields answer 400.

Optional fields marked nullable treat null as omitted.

Provide a nonblank query.

query
string
required

The question. Use a nonblank query. Also limited to 16,384 UTF-8 bytes.

Maximum string length: 16000
Pattern: \S
activeDocumentIds
string[]

These IDs do not filter or rank retrieved content. Leave empty.

Maximum array length: 100
activeEntityIds
string[]

These IDs do not filter or rank retrieved content. Leave empty.

Maximum array length: 100
mode
enum<string> | null

Retrieval depth: fast, deep, or research (see Retrieval Depth). Omit it (or send null) to use the knowledge base's default depth, retrieval.default_mode in Get Knowledge Base Settings.

Available options:
fast,
deep,
research,
null
sessionId
string | null

ID of a query session, as a UUID. Omit it to start a new session. Run Query returns the session ID in its x-session-id response header.

A session stores the last 20 queries but doesn't carry them into later answers. It expires after 30 minutes without a query.

An expired or unknown ID starts a fresh session under that ID, so a UUID you generate yourself stays valid as that session's ID.

Response

Query token issued.

expires_at
string

When the token expires, as an ISO 8601 timestamp in UTC. At most 60 seconds after issue. The deployment can shorten the lifetime.

operation_id
string

Always createQuery, the operation the token is valid for. Callers can ignore it.

request
object

Request body for Run Query. Send it unchanged.

token
string

Query token for Run Query on this knowledge base, good until expires_at. Send it as Authorization: Bearer <token>.

Create a new token for each call, including a retry.

It is a signed JWT. Read trace_id from this response for the X-Trace-ID header; you do not need to decode the token.

trace_id
string

Value to send as the X-Trace-ID header of Run Query. It equals the token's trace_id claim. It is not the query record ID.

url
string

Where to send Run Query. An absolute URL when the deployment sets SERVICE_API_URL. Otherwise the path /v1/knowledge-fs/query-stream, which already carries the /v1 prefix. Resolve that form against the scheme and host of your endpoint, not against the endpoint's path.