Introduction
What a stitch is, the integration pain it removes, and how this documentation is organized.
A stitch is a typed, declarative, composable unit that turns one endpoint into a resilient, validated, observable function. You declare it once; your code calls it, the CLI runs it, and an agent invokes it — without any of them ever touching a credential.
That is the whole idea, and the rest of these docs are an expansion of it. A
stitch is atomic (one endpoint at a time, no spec required) and it hands the
caller a capability, not a secret. Everything that normally rots in a src/api/
folder — auth lifecycle, retries, validation, drift detection, tracing — folds
into the call itself.
The pain it removes
Most integrations start as a thin wrapper over fetch that returns opaque
bytes, and then every reliability concern gets re-implemented by hand at each
call site, separately, where it quietly drifts out of date. A stitch replaces
that wrapper with a declaration:
- No spec, no codegen, no server. A stitch needs a URL and an example response — so it works on the long tail of internal and undocumented APIs that never get a complete OpenAPI document.
- Auth is a boundary. Bearer, API key, cookie sessions, OAuth2 client credentials — the stitch owns the secret and its lifecycle, and the caller receives data, never the credential.
- Resilience is declared. Retry with backoff, proactive throttling, and real timeouts are configuration, uniform across every stitch.
- Validation and drift are live. Responses are validated on every call, and
a silently renamed field surfaces as a loud, leveled drift signal instead of
an
undefinedthree layers downstream. - Observability ships with it. Every call emits a typed event stream, traced to a local JSONL log by default — no collector, nothing to deploy.
The smallest stitch
The smallest stitch is a URL. Declare it once, call it as a typed function:
import { } from 'stitchapi';
const = ('https://api.example.com/users');
const = await (); // GET, parsed JSONThat is the entire surface for a basic call. Adding path params, an output schema, auth, and resilience is the job of the Quickstart, which walks the full first run end to end.
Awaiting a stitch gives you just the final validated value. The same call is also an event stream you can iterate — that is how progress, retries, and drift become observable for free.
How this documentation is organized
The docs are seven top-level sections, ordered for a first read. Start at the top and move down, or jump straight to the section that matches what you need.
Getting started
Install the runtime and declare your first stitch in five minutes.
Concepts
The mental model — the stitch primitive, the event stream, capability over credential.
Guides
One focused page per feature: authoring, auth, resilience, data, validation, observability, state.
Surfaces
The front doors to one definition — in-process function, CLI, HTTP, and MCP.
For agents
How an agent invokes, authors, and reasons over stitches without seeing a secret.
Reference
Signatures and option shapes, generated from the real types.
Errors & pitfalls
One catalog page per coded failure, keyed to the URL the runtime points you at.