Skip to main content

1. Install the SDK

@agentonboard/sdk has one runtime dependency (jose) and uses no Node.js builtins, so it runs on Node.js, Bun, Deno, and Cloudflare Workers. Source lives at github.com/agentonboard/js-sdk. TypeScript entry points:

2. Verify a token directly

verifyAgentToken (and verify_agent_token in Python) checks the RS256 signature against public JWKS keys, validates required claims, and returns either the verified email or an error code:
src/auth/agent.ts
For production routes, use requireAgentAccount or verifyAgentAccount so the verified email maps to your internal user ID and unknown users receive 403 ACCOUNT_REQUIRED. See Accounts & Agent Signup.

Token anatomy

When an agent calls get_token(domain: "notes.com") or POST /api/v1/token/exchange, AgentOnboard signs a 5-minute RS256 JWT:

What verifyAgentToken checks

The SDK does not store seen jti values, so a valid token presented twice within its 5-minute window verifies both times. Serve endpoints over HTTPS and never log raw tokens.

Options

string
required
Raw JWT string. A leading Bearer prefix is stripped case-insensitively. Empty strings return MALFORMED_TOKEN.
string
required
Your Domain hostname (for example "notes.com"). Normalized before comparison against the token’s aud claim.
string
default:"AON_ISSUER, else \"https://agentonboard.xyz\""
Expected iss claim and base URL for the default JWKS endpoint (${issuer}/.well-known/jwks.json).
string
default:"`${issuer}/.well-known/jwks.json`"
Custom URL to fetch the JSON Web Key Set from. Ignored when jwks is provided.
JSONWebKeySet
Pre-parsed JSON Web Key Set object for offline verification, air-gapped environments, or unit tests. Shape-checked before use; invalid key sets return KEY_SOURCE_UNAVAILABLE.
(url: string) => Promise<unknown>
Custom function to fetch the JWKS instead of global fetch. Must resolve to a parsed JSON object (not a Response). Ignored if jwks is set.
number
default:"5"
Seconds of clock skew tolerated when checking exp. Must be non-negative; negative or NaN values return CONFIG_ERROR.
Option name is clockToleranceSecondsIn plain JavaScript without TypeScript checking, misspelled options such as clockSkewSeconds are ignored and default to 5 seconds.

AON_ISSUER environment variable

AON_ISSUER is the only environment variable the SDK reads. Set AON_ISSUER or pass issuer explicitly when verifying tokens from a staging or self-hosted issuer; otherwise tokens fail with ISSUER_MISMATCH.

Custom fetchJwks logging

If your custom fetchJwks callback throws, the SDK returns { ok: false, code: "KEY_SOURCE_UNAVAILABLE", error: "..." } with a generic message so internal URLs or proxy credentials never leak into HTTP responses. Log errors inside fetchJwks before rethrowing:

Domain normalization

The SDK normalizes your audience option to a bare lowercase hostname by stripping any scheme, path, userinfo, and port (except localhost and 127.0.0.1, which keep their port): After normalization, the SDK compares the token’s aud claim by exact string equality. Suffix spoofing (notes.com.evil.com vs notes.com) fails with AUDIENCE_MISMATCH. The same normalization runs when an agent mints a token via get_token or POST /api/v1/token/exchange. Write the bare hostname your API serves on. If your API runs on api.notes.com, use api.notes.com in both your backend code and your auth.md. Passing an audience that cannot normalize to a hostname (such as "" or "/") returns CONFIG_ERROR.

Return value and non-throwing contract

verifyAgentToken returns a discriminated union on ok and never throws for verification failures:

Next steps

Accounts & Agent Signup

Errors & Status Codes