> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agentonboard.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Overview

> Drop-in route guards for Next.js, Express, Hono, FastAPI, Django, and Flask.

Each framework binding reads the `Authorization` header, verifies the `RS256` token against AgentOnboard's public JWKS, calls your account resolver, and maps failures to HTTP `401`, `403`, or `500` responses.

***

## Choose your framework

> [card] [Next.js](https://docs.agentonboard.xyz/nextjs.md)
>
> requireAgentAccount(request, options) for App Router route handlers. Returns a standard Web Response.

> [card] [Express](https://docs.agentonboard.xyz/express.md)
>
> requireAgentAccount(req, res, options) for Express APIs. Writes rejection status and JSON body directly.

> [card] [Hono](https://docs.agentonboard.xyz/hono.md)
>
> requireAgentAccount(c, options) for Cloudflare Workers, Bun, Deno, and Node.js.

> [card] [FastAPI](https://docs.agentonboard.xyz/fastapi.md)
>
> AgentBearerAuth security dependency via agentonboard-sdk\[fastapi].

> [card] [Django](https://docs.agentonboard.xyz/django.md)
>
> @require\_agent\_token view decorator for sync and async Django views via agentonboard-sdk\[django].

> [card] [Flask](https://docs.agentonboard.xyz/flask.md)
>
> @require\_agent\_token route decorator via agentonboard-sdk\[flask].

***

## Shared adapter guarantees

All `@agentonboard/sdk` framework bindings enforce the same rules:

| Option omitted on bindings | Why |
| - | - |
| `token` | Always read from the request's `Authorization` header so a token cannot arrive via query string or cookie. |
| `jwks`, `jwksUrl`, `fetchJwks` | Bindings verify against the configured `issuer` JWKS. Call [`verifyAgentAccount`](https://docs.agentonboard.xyz/accounts) directly when passing offline keys in tests. |

Key properties across all bindings:

* **Header-only extraction:** A `Bearer ` prefix is stripped case-insensitively.
* **Hardcoded Domain:** `audience` and `issuer` come from your server code, never from the incoming request.
* **Minimal resolver input:** `resolveAccount` receives `{ email }` alone.
* **No account caching:** `resolveAccount` runs once per request so deleted or suspended users are blocked immediately.
* **Consistent HTTP statuses:** Token verification failures return `401`. `ACCOUNT_REQUIRED` returns `403`. Unhandled resolver errors return `500`.

***

## Custom failure responses (`onFailure`)

In TypeScript bindings (`next`, `express`, `hono`), pass `onFailure` to customize the error response body or headers. It receives `{ code, error }` and must return a standard Web `Response`:

> [!WARNING]
>
> **Return a Web `Response` from `onFailure`**
>
> `onFailure` takes one argument `({ code, error })` and must return a Web `Response` object, including in the Express adapter which copies the status, headers, and body onto `res`.

```ts theme={null}
import { requireAgentAccount } from "@agentonboard/sdk/next";

const session = await requireAgentAccount(request, {
  audience: "notes.com",
  resolveAccount,
  onFailure: ({ code, error }) =>
    code === "ACCOUNT_REQUIRED"
      ? Response.json(
          { problem: "connect_account", error },
          { status: 403, headers: { location: "https://notes.com/connect" } },
        )
      : Response.json({ code, error }, { status: 401 }),
});
```

***

## Supplying custom or offline JWKS keys

For unit tests, air-gapped environments, or custom `fetchJwks` proxies, call `verifyAgentAccount` from `@agentonboard/sdk` directly:

```ts theme={null}
import { normalizeEmail, verifyAgentAccount } from "@agentonboard/sdk";

const token = request.headers.get("Authorization") ?? "";
const outcome = await verifyAgentAccount({
  token,
  audience: "notes.com",
  jwks: pinnedKeys,
  resolveAccount: async ({ email }) => accounts.get(normalizeEmail(email)) ?? null,
});

if (!outcome.ok) {
  const status =
    outcome.code === "ACCOUNT_REQUIRED"
      ? 403
      : outcome.code === "RESOLVER_ERROR" || outcome.code === "CONFIG_ERROR"
        ? 500
        : 401;
  return Response.json({ code: outcome.code, error: outcome.error }, { status });
}
return Response.json({ created_by: outcome.user });
```

***

> [card] [Errors & Status Codes](https://docs.agentonboard.xyz/errors.md)
>
> Every error code, its cause, and the HTTP status to return.

> [card] [Testing & Production](https://docs.agentonboard.xyz/testing-and-production.md)
>
> Six curl checks, JWKS caching, 1-hour refresh, and key rotation.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.