1. Create a signing keypair
Generate an RSA (or EC) keypair. The private key signs tokens and never leaves your servers. The public key is what Patchwork uses to verify — it is not a secret.RS256, RS384, RS512, ES256, ES384, ES512, PS256, PS384, PS512. Symmetric (HS*) is rejected.
2. Publish your public key
Serve the public key as a JWKS document at a stable URL. Patchwork fetches and caches it, matching each token to a key bykid. Rotation is adding a new key alongside the old one.
name + base_url) and set workspace ingress: JWKS URI, allowed origins, request secret, mint URL. Allowed origins are required so the browser can call Patchwork — no wildcards.
3. Mint a session token
Add one endpoint to your backend, authenticated by your existing user session. It returns a short-lived JWT signed with your private key.string
required
Your API key public id (
key_…), not the secret.string[]
required
Must include
patchwork. Include your own API audience as well so the same token can pass your tool middleware.string
required
Your user id. Becomes the thread subject.
uuid
Connection id this token may call. A UUID — not a name, not a URL. Required when the agent has unpinned customer tools.
integer
required
Unix timestamp. Keep it short — about 120 seconds. The browser remints as needed.
string
required
JWT header. Names the signing key so we match it in your JWKS.
4. Call Loom from the browser
202 with a run_id. Poll GET /v1/loom/runs/:id or subscribe to the thread channel — see Realtime.
5. Verify tool calls you host
Every call we make to your backend carries the session token and aPatchwork-Signature over your request secret. A stolen token is useless without the secret.
React
@usepatchwork/react wraps the browser side. You provide url and a mint function that returns the session token. Optional connection pins the host.
useAgent gives you messages, threads, send, openThread, and newChat. See the package readme.