Skip to content

Search the caller's own threads by the words of their titles, descriptions and messages​

POST
/api/search/threads

The caller's own threads, and nobody else's (ADR 0039, ADR 0068): what it finds is always a subset of what listThreads lists for the same archived and branches, for every role (an administrator finds their own too). Another person's thread is never a hit, by its title or by its content. The permission is thread.read. A POST, though it is a safe read that writes nothing: the query is a person's words, and they must not be in a URL, a proxy's access log or a trace. The media type is exactly application/json (a parameter such as charset is allowed; application/problem+json and application/json-seq are not): any other is a 415. The checks run in one order, so two errors never leave a client guessing: 401, 429, 403, 415, then the body's shape (400 bad_request: one JSON object, only the five members, each of its type, none twice, no null), q (400 query_empty, query_too_long), limit's range, archived, branches, the cursor (400 bad_cursor), and last the store (503). The vectors of requests.json hold every case.

Every rule is in thread-search-v1.md, with vectors: what a word is, how it is folded (Café, cafe and CAFÉ are one word; cœur is coeur), how the query is read, when a document matches (every term is the start of one word of one title, one description or one message), what is searched (titles, descriptions, a person's messages and an agent's final answers; not working text, reasoning, steps, tool results or file names), how the snippet is cut and its offsets, and the order. A second client reads that page and gets the same threads, snippets and order as this server.

Order: rank descending (2: the title matches, 1: the description, 0: only messages), then the thread's id descending (the newest created first). A page that is read later differs from an earlier one only when a thread was renamed, deleted or written to in between.

Client recipe (the server enforces every rule above; a client only offers the box):

  1. If getConfig has no search, offer no box.
  2. Debounce about 250 ms, cancel the request in flight when the text changes, and drop an answer that is not for the latest text.
  3. Send {"q": text}; do not trim, fold or bound it yourself. Draw each result with thread.title, and each hit's snippet.text split at matches (UTF-16 code unit offsets) into plain and marked runs, with an ellipsis where cutStart or cutEnd. Never interpret the text as markup. Say messageHits beyond the hits shown. query.terms says what was searched for.
  4. A message hit opens the thread at its seq (getThreadHistory with since=<seq>, as for a #m-<seq> link); a title or description hit opens the thread as usual.
  5. For more, send the same request with cursor set to next, until next is absent.
  6. On 429 wait Retry-After; on 503 say that the search is unavailable and offer to try again.

A query that keeps no term (a, !!) is a 200 with terms: [] and no result.

Authorizations​

bearerToken

A JWT signed by the configured issuer (RS256, RS384, ES256 or EdDSA), with the configured audience. Read when auth.mode is jwt or jwt_or_proxy_header. A missing or refused token gets 401 with WWW-Authenticate: Bearer; an issuer whose keys cannot be fetched gets 503.

Type
HTTP (bearer)
or
dpopToken

A JWT as bearerToken, bound to the key of the client (cnf.jkt, RFC 7638), sent as Authorization: DPoP <token> with one DPoP header holding a proof signed by that key (RFC 9449, ADR 0054). Read only when auth.dpop is configured. A bad proof gets 401 with WWW-Authenticate: DPoP error="invalid_dpop_proof", algs="ES256 EdDSA", a bad or unbound token error="invalid_token".

Type
HTTP (DPoP)
or
proxyIdentity

Set by oauth2-proxy after OIDC login; requests without it get 401. Read when auth.mode is proxy_header (the default) or jwt_or_proxy_header without a bearer token.

Type
API Key (header: X-Auth-Request-Email)

Request Body​

JSON
{
  
"q": "login test",
  
"limit": 20,
  
"archived": "exclude"
}

Responses​

One page of results

JSON
{
  
"query": {
  
  
"terms": [
  
  
  
"login",
  
  
  
"test"
  
  
]
  
},
  
"results": [
  
  
{
  
  
  
"thread": {
  
  
  
  
"id": "00000000-0000-4000-8000-000000000001",
  
  
  
  
"owner": "user@example.com",
  
  
  
  
"title": "Fix the failing login test",
  
  
  
  
"target": {
  
  
  
  
  
"agentId": "coder"
  
  
  
  
},
  
  
  
  
"state": "working",
  
  
  
  
"createdAt": "2026-01-15T09:12:03Z",
  
  
  
  
"updatedAt": "2026-01-15T09:14:41Z",
  
  
  
  
"lastSeq": 7
  
  
  
},
  
  
  
"rank": 1,
  
  
  
"hits": [
  
  
  
  
{
  
  
  
  
  
"field": "title",
  
  
  
  
  
"snippet": {
  
  
  
  
  
  
"text": "Fix the failing login test",
  
  
  
  
  
  
"cutStart": false,
  
  
  
  
  
  
"cutEnd": false,
  
  
  
  
  
  
"matches": [
  
  
  
  
  
  
  
{
  
  
  
  
  
  
  
  
"start": 16,
  
  
  
  
  
  
  
  
"end": 21
  
  
  
  
  
  
  
},
  
  
  
  
  
  
  
{
  
  
  
  
  
  
  
  
"start": 22,
  
  
  
  
  
  
  
  
"end": 26
  
  
  
  
  
  
  
}
  
  
  
  
  
  
]
  
  
  
  
  
}
  
  
  
  
}
  
  
  
],
  
  
  
"messageHits": 0
  
  
}
  
]
}

Samples​

Powered by VitePress OpenAPI