Skip to content
syntaqx

Requests & Responses, chapter 06 of 11

HTTP QUERY

Supporting RFC 10008's QUERY method today: one query model behind GET, QUERY and a POST fallback, plus caching, CORS, and where the ecosystem still falls short.

5 min readUpdated

RFC 10008, published June 2026, adds the QUERY method: a request that carries its query in the body like POST, but is safe and idempotent like GET. It closes the gap Filtering & Sorting runs into: either a complex search goes in the URL and fights length limits, encoding and logged filters, or it goes in POST /search and loses caching, automatic retries, and the meaning of "this is a read". The ecosystem is still catching up, so this is how I support QUERY now without leaving clients behind.

What QUERY Is#

QUERY /payments
Content-Type: application/json
Accept: application/json

{
  "status": ["captured", "settled"],
  "amount_gte": 10000,
  "created_after": "2026-10-01T00:00:00Z",
  "sort": "-created_at"
}

Field names, operator suffixes and sort are exactly the filtering parameters, and a comma list in the query string is an array in the body. The body can also express what a query string can't, such as nested any and all groups for (a AND b) OR c.

HTTP/1.1 200 OK
Content-Type: application/json
Link: <https://api.syntaqx.com/payments/queries/0194a7f3-2b11-7e80-9c3d-4e8f1a2b5c70?cursor=eyJpZCI6IjEyMyJ9>; rel="next"

[
  { "id": "01932c6c-7616-7590-a8db-cb4b0e4d1c8a", "status": "captured", "amount": 25000, "currency": "USD" }
]
Property GET QUERY POST
Safe (no side effects) Yes Yes No
Idempotent (safe to retry) Yes Yes No
Request body has meaning No Yes Yes
Cacheable Yes Yes, keyed on the body Rarely

One Query Model, Three Doors#

Every searchable collection has one query model, and three ways to send it that all reach the same handler:

Door When Example
GET with a query string Simple filters that fit in a URL and aren't sensitive GET /payments?status=captured&sort=-created_at
QUERY with a body The preferred form for anything structured, long, or sensitive QUERY /payments
POST with a method override Clients or infrastructure that can't send QUERY yet POST /payments + X-HTTP-Method-Override: QUERY

GET /payments?status=captured and QUERY /payments with {"status": "captured"} return the same thing.

The POST Fallback

The polyfill: a POST to the collection with X-HTTP-Method-Override: QUERY is handled exactly as a QUERY:

POST /payments
X-HTTP-Method-Override: QUERY
Content-Type: application/json

{ "status": ["captured"] }
  • The only allowed override is POST to QUERY. Any other is rejected with 400, because an override that can turn a request into DELETE is a security hole.
  • No side effects, ever. The handler is the read-only QUERY handler. An Idempotency-Key isn't needed and is ignored.
  • The header keeps its X- prefix. Everywhere else these docs drop X- (RFC 6648), but X-HTTP-Method-Override is what gateways, SDKs and Google's APIs already send, and renaming it would break the clients it exists for.
  • Responses tell caches the truth. Intermediaries see a POST, so they won't cache it, and the response says Cache-Control: private, no-store. Clients that want caching use the stored query (below).

A separate POST /payments/search would be a second URL for the same read, with its own docs and its own drift.

Discovery#

A client shouldn't have to try QUERY and see what breaks. Resources that support it say so, with the headers RFC 10008 defines:

HTTP/1.1 200 OK
Allow: GET, HEAD, OPTIONS, QUERY
Accept-Query: application/json
  • Allow on OPTIONS responses, and on any 405 Method Not Allowed.
  • Accept-Query lists the query formats the resource understands. It's a Structured Field list, and it applies to every URL with the same path.
  • Clients can also just send QUERY and fall back to the override on 405 or 501.

Status Codes#

Situation Status
Missing Content-Type, or it doesn't match the body 400
Body is larger than the limit (64 KB) 413
Unsupported query format 415, with Accept-Query listing what is
Valid JSON, but the query can't run (unknown field, bad operator) 422, with field-level errors
Accept asks for a format the resource can't produce 406

The server never sniffs the body to guess its type. The RFC forbids it, and it's how parsers get confused into doing the wrong thing.

Stored Queries#

A QUERY body can't be bookmarked, linked to, or cached by most of today's infrastructure. RFC 10008's answer is the equivalent resource: a URL that stands for "this query, against this collection", which anyone can GET.

HTTP/1.1 200 OK
Location: /payments/queries/0194a7f3-2b11-7e80-9c3d-4e8f1a2b5c70
ETag: "a3f9c1"
  • Location points to the stored query. A GET to it runs the query again, with current results, without resending the body.
  • That GET works with everything GET already works with: conditional requests (If-None-Match and 304), CDNs, browser caches, pagination links.
  • The stored query ID is derived from a hash of the normalized query, so the same query always gets the same URL (UUID v5 is a natural fit).
  • Stored queries expire after 24 hours without use. A GET after that returns 404, and the client re-sends the original QUERY.
  • The URL never contains the query's contents, so nothing sensitive ends up in logs, as the RFC requires.

Pagination links on QUERY responses point at the stored query, so following rel="next" is a plain GET.

Caching#

QUERY responses are cacheable, and the cache key includes the body. Caches may normalize it (key order, whitespace, content encoding) for the key only.

In practice: assume no shared cache understands QUERY yet. Send Cache-Control on QUERY responses as you would for the equivalent GET, and rely on the stored-query GET URL for CDN caching.

Limitations#

The method is standardized. Support isn't. Each of these has a workaround, and that's why the fallback exists.

Layer Limitation What we do
Browsers fetch() can send QUERY, but it isn't CORS-safelisted, so every cross-origin call needs a preflight. HTML forms can't send it at all. List QUERY in Access-Control-Allow-Methods and cache preflights with Access-Control-Max-Age
Frameworks Many routers only dispatch the classic methods. Next.js route handlers, for example, only export GET, HEAD, OPTIONS, POST, PUT, DELETE and PATCH, and a native QUERY to a route handler is rejected (Next.js 16 answers with an empty 400). Route QUERY at the server or proxy layer where possible, and the POST override always works
CDNs, WAFs, load balancers Some reject unknown methods outright, and most don't cache QUERY with a body-aware key yet Allow QUERY explicitly in edge rules, and cache through stored-query GET URLs
Runtimes Older HTTP parsers reject the method. Node.js parses it in current releases (http.METHODS includes QUERY in Node 24). Check the runtime before relying on native support
API descriptions OpenAPI 3.2 has a query operation. 3.1 and older tooling doesn't. Describe QUERY in 3.2 where tooling supports it, and document the POST override alongside it
Logging and observability Tools that log method + URL see the same URL for every query Log a hash of the normalized body with the request ID, never the body itself

Live Example#

The syntaqx API's /hash endpoint supports all of this. Hashing has no side effects and always gives the same answer, and its input is exactly the kind of data that shouldn't end up in a URL.

# Native QUERY
curl -X QUERY https://api.syntaqx.com/hash \
  -H "Content-Type: application/json" \
  -d '{"input": "hello world"}'

# The POST fallback
curl -X POST https://api.syntaqx.com/hash \
  -H "Content-Type: application/json" \
  -H "X-HTTP-Method-Override: QUERY" \
  -d '{"input": "hello world"}'

How it's built:

  • QUERY is served in the proxy layer, because Next.js route handlers answer a native QUERY with an empty 400. The proxy recognizes both doors, applies the checks above (Content-Type, the 64 KB limit, override rules), and calls the read-only handler directly.
  • Native responses are cacheable for a year (public, max-age=31536000, immutable), since a digest never changes for the same input. Overridden requests return private, no-store.
  • No stored query, because a digest is already the complete, permanent answer.
  • The OpenAPI document describes it natively, as a query operation in OpenAPI 3.2, next to the POST with its override header. Plain POST /hash still works for existing clients.

QUERY /docs takes the playbook list's filters as a JSON body ({"section": ["payments"], "sort": "title"}) and returns the same results as the equivalent GET. Its Link header points the next page at that GET URL, so paging past the first response is a plain request every cache understands.

References#

Specifications

Reference

In practice