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

# Hono

> Verify AI agent tokens and authenticate requests in Hono across Edge runtimes using @agentonboard/sdk/hono.

`@agentonboard/sdk/hono` provides `requireAgentAccount(c, options)` for [Hono](https://hono.dev/) apps on Cloudflare Workers, Bun, Deno, Node.js, and Fastly Compute without `nodejs_compat` flags.

## Copy-paste agent prompt

```text 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`.
```

***

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

***

## 2. Guard your Hono route

```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();

// Simulated user database
const accounts = new Map([["ada@example.com", "user_123"]]);

app.post("/api/notes", async (c) => {
  const session = await requireAgentAccount(c, {
    audience: "notes.com",
    resolveAccount: async ({ email }) => {
      return accounts.get(normalizeEmail(email)) ?? null;
    },
  });

  // session.response is a standard Response (401, 403, or 500)
  if (!session.ok) return session.response;

  return c.json({ success: true, user: session.user });
});

export default app;
```

> [!WARNING]
>
> **Use `session.user` directly**
>
> The binding does not mutate Hono's `c.set()` context map. Read `session.user` directly from the returned object so TypeScript types stay exact.

***

## 3. Test with curl

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

```bash theme={null}
# Mint a 5-minute test token
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')

# Call your Hono service
curl -i -X POST http://localhost:8787/api/notes \
  -H "Authorization: Bearer $TOKEN"
```

***

> [card] [Testing & Production](https://docs.agentonboard.xyz/testing-and-production.md)
>
> Key caching, 1-hour refresh, and last-known-good fallbacks.

> [card] [Accounts & Agent Signup](https://docs.agentonboard.xyz/accounts.md)
>
> Allow agents to create App Accounts at POST /api/signup.


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