defineEndpoint is for teams without an OpenAPI spec. If you have one, run kweri-gen instead — it generates all endpoint definitions automatically and you can skip this page entirely.What is an endpoint?
An endpoint is a plain object that describes an API route — its HTTP method, path, parameter schema, and response schema:params and response.
defineEndpoint
defineEndpoint is an identity function that provides type inference:
defineEndpoint is entirely optional. It only exists to surface TypeScript errors closer to the definition site.
Path parameters
Use{name} placeholders in the path. The matching path object in params provides the values:
Query parameters
Keys in aquery object are appended as query string parameters:
Request body
Use abody key for POST/PUT/PATCH payloads:
Combined path, query, and body
Type inference
UseInferParams and InferResponse to extract the TypeScript types from an endpoint:
TypeBox schema reference
Kweri re-exportsType and Static from @sinclair/typebox:
Runtime validation
Params are not validated at runtime. Whenkweri.query() and kweri.mutate() call the API client internally, they replace the endpoint’s params schema with Type.Any() before executing the request. This means the TypeBox params schema is purely a TypeScript-level construct — it drives type inference for InferParams<E> but is never evaluated against your actual values at runtime.
Responses are validated at runtime. After a successful fetch, kweri checks the server’s response against the endpoint’s response schema. If the shape doesn’t match, a ValidationError is thrown: