Skip to main content
verifyAgentToken proves who the User is (email). verifyAgentAccount adds the second step: checking whether that email has an App Account in your database and returning your internal user ID or record.
verifyAgentAccount accepts every verifyAgentToken option plus resolveAccount.
Framework bindings return { ok: true, user } onlyWhile verifyAgentAccount returns { ok: true, email, user }, framework bindings (@agentonboard/sdk/next, /express, /hono) return { ok: true, user } so route handlers scope queries by your internal session.user ID.

The resolveAccount contract

Key rules of resolveAccount:
  1. Receives { email } only: Runs only after cryptographic verification succeeds.
  2. Always use normalizeEmail(email): Pass normalizeEmail(email) (from @agentonboard/sdk) into database queries instead of raw email.toLowerCase() so case and whitespace match consistently.
  3. Return null or undefined when no user exists: Both trigger 403 ACCOUNT_REQUIRED. Numeric 0 and empty string "" count as valid user IDs.
  4. Runs once per request: The SDK never caches resolveAccount results, so suspended or deleted users lose access immediately.
  5. Exceptions become 500 RESOLVER_ERROR: If your query throws, the SDK catches the error and hides the raw exception message so connection strings cannot leak. Log database errors inside resolveAccount before rethrowing.
Return 403 Forbidden for ACCOUNT_REQUIRED, never 401HTTP 401 tells an agent its token is invalid or expired, causing it to mint a new token and retry in a loop. HTTP 403 with ACCOUNT_REQUIRED tells the agent the token is valid, and directs it to follow your auth.md instructions. All framework bindings return 403 for ACCOUNT_REQUIRED automatically.

Handling unknown users: Reject vs. Create

When an email is valid but absent from your database, pick one of two models:

When to Reject (Default)

Keep the default verifyAgentAccount / requireAgentAccount behavior across all routes if:
  • Your API serves existing paying customers, enterprise workspaces, or an invite-only beta.
  • New accounts need billing setup, organization assignment, or manual approval before API access.
  • You want Users to complete web signup before granting agent access.

When to Create (POST /api/signup)

Add a dedicated POST /api/signup handler with createAgentAccount if:
  • Your product is self-serve and you want a User’s agent to register without opening a browser.
  • You apply rate limits and abuse controls to self-serve signups.
  • You document POST /api/signup in your auth.md file.
Agent signup is open self-registrationAnyone with a verified AgentOnboard email can call POST /api/signup, just like submitting a public web signup form. Apply the same rate limits, trial tiers, or email domain allowlists you enforce on web signups.

Setting up explicit agent signup (createAgentAccount)

Follow the two-step signup pattern:
1

Guard regular routes with requireAgentAccount

Keep requireAgentAccount (or verifyAgentAccount) on all regular endpoints so unknown emails receive 403 ACCOUNT_REQUIRED instead of creating accounts as a side effect:
app/api/notes/route.ts
2

Add POST /api/signup using createAgentAccount

createAgentAccount verifies the token first, checks resolveAccount, and runs createAccount only when resolveAccount returns null or undefined:
app/api/signup/route.ts
Operational guarantees of createAgentAccount:
  • Token verified before any database call: Invalid or expired tokens return 401 without running resolveAccount or createAccount.
  • Idempotent on existing users: When resolveAccount finds an existing user, createAccount is skipped and outcome.created is false.
  • Failed inserts return 500 RESOLVER_ERROR: Exceptions inside createAccount return RESOLVER_ERROR with status 500.
  • Your app owns post-signup lifecycle: Welcome emails, rate limits, password setup, and account deletion remain in your application. Revoking an AgentOnboard API Key stops future token minting without deleting App Accounts.
3

Publish POST /api/signup in auth.md

Document POST /api/signup and reference it in the 403 ACCOUNT_REQUIRED row of your auth.md rejection table. See Publishing auth.md for the full template.

Next steps

Publishing auth.md

Testing & Production