> ## 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.

# Quickstart

> Add AI agent authentication to your API in four steps across Next.js, Express, Hono, FastAPI, Django, and Flask.

Give AI agents verified access to your API in four steps.

## Copy-paste agent prompt

Paste the prompt for your stack into Claude Code, Cursor, or Codex to wire AgentOnboard into your repository:

```text Next.js theme={null}
Integrate AgentOnboard into this Next.js App Router repository.

1. Inspect the codebase and install `@agentonboard/sdk`.
2. Read these docs before editing:
   - https://docs.agentonboard.xyz/nextjs.md
   - https://docs.agentonboard.xyz/verify.md
   - https://docs.agentonboard.xyz/accounts.md
   - https://docs.agentonboard.xyz/auth-md.md
3. Ask me three questions before writing code:
   - Which auth provider or users table should `resolveAccount` query?
   - Should unknown emails return `403 ACCOUNT_REQUIRED` (reject) or create an account on `POST /api/signup`?
   - What is the production Domain hostname (e.g. `notes.com` or `api.notes.com`)?
4. Implement the integration following these invariants:
   - Call `requireAgentAccount` from `@agentonboard/sdk/next` inside route handlers (never in middleware).
   - Hardcode `audience` to the normalized production Domain.
   - Normalize emails with `normalizeEmail(email)` from `@agentonboard/sdk` (never raw `email.toLowerCase()`).
   - Publish the discovery file at both `/auth.md` and `/.well-known/auth.md` with matching `## Audience` and `403` instructions.
5. Verify against localhost by minting a test token with `POST https://agentonboard.xyz/api/v1/token/exchange` and testing `403 ACCOUNT_REQUIRED`, `200 OK`, and `401 INVALID_SIGNATURE`.
```

```text Express theme={null}
Integrate AgentOnboard into this Express repository.

1. Inspect the codebase and install `@agentonboard/sdk`.
2. Read these docs before editing:
   - https://docs.agentonboard.xyz/express.md
   - https://docs.agentonboard.xyz/verify.md
   - https://docs.agentonboard.xyz/accounts.md
   - https://docs.agentonboard.xyz/auth-md.md
3. Ask me three questions before writing code:
   - Which auth provider or users table should `resolveAccount` query?
   - Should unknown emails return `403 ACCOUNT_REQUIRED` (reject) or create an account on `POST /api/signup`?
   - What is the production Domain hostname (e.g. `notes.com` or `api.notes.com`)?
4. Implement the integration following these invariants:
   - Call `requireAgentAccount(req, res, options)` from `@agentonboard/sdk/express`.
   - Hardcode `audience` to the normalized production Domain.
   - Normalize emails with `normalizeEmail(email)` from `@agentonboard/sdk` (never raw `email.toLowerCase()`).
   - Serve the discovery file at both `/auth.md` and `/.well-known/auth.md` with matching `## Audience` and `403` instructions.
5. Verify against localhost by minting a test token with `POST https://agentonboard.xyz/api/v1/token/exchange` and testing `403 ACCOUNT_REQUIRED`, `200 OK`, and `401 INVALID_SIGNATURE`.
```

```text Hono theme={null}
Integrate AgentOnboard into this Hono repository.

1. Inspect the codebase and install `@agentonboard/sdk`.
2. Read these docs before editing:
   - https://docs.agentonboard.xyz/hono.md
   - https://docs.agentonboard.xyz/verify.md
   - https://docs.agentonboard.xyz/accounts.md
   - https://docs.agentonboard.xyz/auth-md.md
3. Ask me three questions before writing code:
   - Which auth provider or users table should `resolveAccount` query?
   - Should unknown emails return `403 ACCOUNT_REQUIRED` (reject) or create an account on `POST /api/signup`?
   - What is the production Domain hostname (e.g. `notes.com` or `api.notes.com`)?
4. Implement the integration following these invariants:
   - Call `requireAgentAccount(c, options)` from `@agentonboard/sdk/hono`.
   - Hardcode `audience` to the normalized production Domain.
   - Normalize emails with `normalizeEmail(email)` from `@agentonboard/sdk` (never raw `email.toLowerCase()`).
   - Serve the discovery file at both `/auth.md` and `/.well-known/auth.md` with matching `## Audience` and `403` instructions.
5. Verify against localhost by minting a test token with `POST https://agentonboard.xyz/api/v1/token/exchange` and testing `403 ACCOUNT_REQUIRED`, `200 OK`, and `401 INVALID_SIGNATURE`.
```

```text FastAPI theme={null}
Integrate AgentOnboard into this FastAPI repository.

1. Inspect the codebase and install `agentonboard-sdk[fastapi]`.
2. Read these docs before editing:
   - https://docs.agentonboard.xyz/fastapi.md
   - https://docs.agentonboard.xyz/verify.md
   - https://docs.agentonboard.xyz/accounts.md
   - https://docs.agentonboard.xyz/auth-md.md
3. Ask me three questions before writing code:
   - Which database or user model should the `resolver` query?
   - Should unknown emails return `403 ACCOUNT_REQUIRED` (reject) or create an account on `POST /api/signup`?
   - What is the production Domain hostname (e.g. `notes.com` or `api.notes.com`)?
4. Implement the integration following these invariants:
   - Use `AgentBearerAuth` from `agentonboard.frameworks.fastapi`.
   - Hardcode `audience` to the normalized production Domain.
   - Normalize emails consistently in lowercase before querying your database.
   - Serve the discovery file at both `/auth.md` and `/.well-known/auth.md` with matching `## Audience` and `403` instructions.
5. Verify against localhost by minting a test token with `POST https://agentonboard.xyz/api/v1/token/exchange` and testing `403 ACCOUNT_REQUIRED`, `200 OK`, and `401 INVALID_SIGNATURE`.
```

```text Django theme={null}
Integrate AgentOnboard into this Django repository.

1. Inspect the codebase and install `agentonboard-sdk[django]`.
2. Read these docs before editing:
   - https://docs.agentonboard.xyz/django.md
   - https://docs.agentonboard.xyz/verify.md
   - https://docs.agentonboard.xyz/accounts.md
   - https://docs.agentonboard.xyz/auth-md.md
3. Ask me three questions before writing code:
   - Which user model should the `resolver` query?
   - Should unknown emails return `403 ACCOUNT_REQUIRED` (reject) or create an account on `POST /api/signup`?
   - What is the production Domain hostname (e.g. `notes.com` or `api.notes.com`)?
4. Implement the integration following these invariants:
   - Use `@require_agent_token` from `agentonboard.frameworks.django`.
   - Hardcode `audience` to the normalized production Domain.
   - Query emails case-insensitively (`email__iexact` or normalized lowercase).
   - Serve the discovery file at both `/auth.md` and `/.well-known/auth.md` with matching `## Audience` and `403` instructions.
5. Verify against localhost by minting a test token with `POST https://agentonboard.xyz/api/v1/token/exchange` and testing `403 ACCOUNT_REQUIRED`, `200 OK`, and `401 INVALID_SIGNATURE`.
```

```text Flask theme={null}
Integrate AgentOnboard into this Flask repository.

1. Inspect the codebase and install `agentonboard-sdk[flask]`.
2. Read these docs before editing:
   - https://docs.agentonboard.xyz/flask.md
   - https://docs.agentonboard.xyz/verify.md
   - https://docs.agentonboard.xyz/accounts.md
   - https://docs.agentonboard.xyz/auth-md.md
3. Ask me three questions before writing code:
   - Which database or user model should the `resolver` query?
   - Should unknown emails return `403 ACCOUNT_REQUIRED` (reject) or create an account on `POST /api/signup`?
   - What is the production Domain hostname (e.g. `notes.com` or `api.notes.com`)?
4. Implement the integration following these invariants:
   - Use `@require_agent_token` from `agentonboard.frameworks.flask`.
   - Hardcode `audience` to the normalized production Domain.
   - Normalize emails consistently in lowercase before querying your database.
   - Serve the discovery file at both `/auth.md` and `/.well-known/auth.md` with matching `## Audience` and `403` instructions.
5. Verify against localhost by minting a test token with `POST https://agentonboard.xyz/api/v1/token/exchange` and testing `403 ACCOUNT_REQUIRED`, `200 OK`, and `401 INVALID_SIGNATURE`.
```

***

## Manual setup

**1. Install the SDK**

> [tab] npm
>
> ```bash theme={null}
> npm install @agentonboard/sdk
> ```

> [tab] pnpm
>
> ```bash theme={null}
> pnpm add @agentonboard/sdk
> ```

> [tab] yarn
>
> ```bash theme={null}
> yarn add @agentonboard/sdk
> ```

> [tab] bun
>
> ```bash theme={null}
> bun add @agentonboard/sdk
> ```

> [tab] Python (pip)
>
> ```bash theme={null}
> # Choose your framework extra: fastapi, django, or flask
> pip install "agentonboard-sdk[fastapi]"
> ```

> [tab] Python (uv)
>
> ```bash theme={null}
> # Choose your framework extra: fastapi, django, or flask
> uv add "agentonboard-sdk[fastapi]"
> ```

**2. Guard your route handler**

Verify the incoming Bearer token against AgentOnboard's public JWKS and look up the user by normalized email:

> [tab] Next.js
>
> ```ts title="app/api/notes/route.ts" theme={null}
> import { normalizeEmail } from "@agentonboard/sdk";
> import { requireAgentAccount } from "@agentonboard/sdk/next";
>
> export async function POST(request: Request) {
>   const session = await requireAgentAccount(request, {
>     audience: "notes.com",
>     resolveAccount: async ({ email }) => {
>       const user = await db.user.findUnique({
>         where: { email: normalizeEmail(email) },
>       });
>       return user?.id ?? null;
>     },
>   });
>
>   // Returns 401 (invalid/expired token) or 403 (ACCOUNT_REQUIRED)
>   if (!session.ok) return session.response;
>
>   return Response.json({ success: true, created_by: session.user });
> }
> ```

> [tab] Express
>
> ```ts title="api/notes.ts" theme={null}
> import express from "express";
> import { normalizeEmail } from "@agentonboard/sdk";
> import { requireAgentAccount } from "@agentonboard/sdk/express";
>
> const app = express();
> app.use(express.json());
>
> app.post("/api/notes", async (req, res) => {
>   const session = await requireAgentAccount(req, res, {
>     audience: "notes.com",
>     resolveAccount: async ({ email }) => {
>       const user = await db.user.findUnique({
>         where: { email: normalizeEmail(email) },
>       });
>       return user?.id ?? null;
>     },
>   });
>
>   // If verification failed, status and JSON body were already sent on `res`
>   if (!session.ok) return;
>
>   res.json({ success: true, created_by: session.user });
> });
> ```

> [tab] Hono
>
> ```ts title="src/index.ts" theme={null}
> import { Hono } from "hono";
> import { normalizeEmail } from "@agentonboard/sdk";
> import { requireAgentAccount } from "@agentonboard/sdk/hono";
>
> const app = new Hono();
>
> app.post("/api/notes", async (c) => {
>   const session = await requireAgentAccount(c, {
>     audience: "notes.com",
>     resolveAccount: async ({ email }) => {
>       const user = await db.user.findUnique({
>         where: { email: normalizeEmail(email) },
>       });
>       return user?.id ?? null;
>     },
>   });
>
>   if (!session.ok) return session.response;
>
>   return c.json({ success: true, created_by: session.user });
> });
> ```

> [tab] FastAPI
>
> ```python title="main.py" theme={null}
> from fastapi import Depends, FastAPI
> from agentonboard import AgentIdentity
> from agentonboard.frameworks.fastapi import AgentBearerAuth
>
> app = FastAPI()
>
> async def get_user_by_email(identity: AgentIdentity):
>     user = await db.users.find_one({"email": identity.email.strip().lower()})
>     return str(user["_id"]) if user else None
>
> agent_auth = AgentBearerAuth(
>     audience="notes.com",
>     resolver=get_user_by_email,
> )
>
> @app.post("/api/notes")
> async def create_note(user_id: str = Depends(agent_auth)):
>     return {"success": True, "created_by": user_id}
> ```

> [tab] Django
>
> ```python title="views.py" theme={null}
> from django.contrib.auth import get_user_model
> from django.http import HttpRequest, JsonResponse
> from django.views.decorators.csrf import csrf_exempt
> from agentonboard import AgentIdentity
> from agentonboard.frameworks.django import require_agent_token
>
> User = get_user_model()
>
> def get_user_by_email(identity: AgentIdentity):
>     user = User.objects.filter(email__iexact=identity.email.strip()).first()
>     return user.id if user else None
>
> @csrf_exempt
> @require_agent_token(audience="notes.com", resolver=get_user_by_email)
> def create_note(request: HttpRequest, agent_user: int):
>     return JsonResponse({"success": True, "created_by": agent_user})
> ```

> [tab] Flask
>
> ```python title="app.py" theme={null}
> from flask import Flask, jsonify
> from agentonboard import AgentIdentity
> from agentonboard.frameworks.flask import require_agent_token
>
> app = Flask(__name__)
>
> def get_user_by_email(identity: AgentIdentity):
>     user = db.users.find_one({"email": identity.email.strip().lower()})
>     return str(user["_id"]) if user else None
>
> @app.post("/api/notes")
> @require_agent_token(audience="notes.com", resolver=get_user_by_email)
> def create_note(agent_user: str):
>     return jsonify({"success": True, "created_by": agent_user})
> ```

**3. Publish auth.md**

Serve a static `auth.md` file at `https://<your-domain>/auth.md` and `https://<your-domain>/.well-known/auth.md` (for example `public/auth.md` and `public/.well-known/auth.md`) so agents learn your Domain, endpoints, and `401` / `403` handling:

```markdown title="public/auth.md" theme={null}
# Notes API

This service accepts AgentOnboard tokens.

## Audience

`notes.com`

    get_token(domain: "notes.com")

Send the token on every request as `Authorization: Bearer <token>`.

## Endpoints

### `POST /api/notes`

- Request: `{ "title": string, "body": string }`
- Success: `201` with `{ "id": string, "title": string, "body": string }`
- Required header: `Authorization: Bearer <token>`

## When a request is rejected

| Status | `code` | What to do |
|---|---|---|
| 401 | any | The token was rejected. Call `get_token` for `notes.com` again and retry **once**. |
| 403 | `ACCOUNT_REQUIRED` | The identity is valid but has no Notes account. Ask the human to connect their account at https://notes.com/connect, then retry. |
| 500 | `RESOLVER_ERROR` or `CONFIG_ERROR` | Server error. Retry after a short delay with the same token. |
```

**4. Test with curl**

Mint a 5-minute test token using [`POST /api/v1/token/exchange`](https://docs.agentonboard.xyz/api/token-exchange), then call your endpoint:

```bash theme={null}
# 1. Mint a 5-minute test token for your domain
TOKEN=$(curl -s -X POST https://agentonboard.xyz/api/v1/token/exchange \
  -H "Authorization: Bearer aon_live_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{"audience":"notes.com"}' \
  | jq -r '.token')

# 2. Call your protected endpoint
curl -i -X POST https://notes.com/api/notes \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"title": "First note", "body": "Created by an agent"}'
```

***

## Next steps

> [card] [Accounts & Agent Signup](https://docs.agentonboard.xyz/accounts.md)
>
> Decide between rejecting unknown emails with 403 or adding POST /api/signup.

> [card] [Testing & Production](https://docs.agentonboard.xyz/testing-and-production.md)
>
> Run all six curl checks and review JWKS caching and key rotation.


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