Skip to main content
@agentonboard/sdk/next exports requireAgentAccount for Next.js App Router route handlers. It reads the Bearer token, verifies the RS256 signature locally against public JWKS keys, and resolves your App Account by verified email.

Copy-paste agent prompt


1. Install the SDK


2. Guard your route handler

requireAgentAccount(request, options) accepts the standard Web API Request that App Router handlers receive (NextRequest satisfies it unchanged):
app/api/notes/route.ts
Call in route handlers, not in middlewareNext.js middleware cannot pass a resolved user record down to a route handler without writing it into request headers or cookies that a client could spoof. Always execute requireAgentAccount directly inside your route handler where queries are scoped.

3. How errors are handled

When verification fails or resolveAccount returns null, session.ok is false and session.response is a ready-to-return Response (401 for token errors, 403 for ACCOUNT_REQUIRED, 500 for RESOLVER_ERROR or CONFIG_ERROR). See Errors & Status Codes and Framework Overview for onFailure customization.

4. Test with curl

Mint a 5-minute test token using POST /api/v1/token/exchange and call your Next.js route:

Publishing auth.md

Testing & Production