1. Install the SDK
- npm
- pnpm
- yarn
- bun
- Python (pip)
- Python (uv)
@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
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 callsget_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
Raw JWT string. A leading
Bearer prefix is stripped case-insensitively. Empty strings return MALFORMED_TOKEN.Your Domain hostname (for example
"notes.com"). Normalized before comparison against the token’s aud claim.Expected
iss claim and base URL for the default JWKS endpoint (${issuer}/.well-known/jwks.json).Custom URL to fetch the JSON Web Key Set from. Ignored when
jwks is provided.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.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.Seconds of clock skew tolerated when checking
exp. Must be non-negative; negative or NaN values return CONFIG_ERROR.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 youraudience 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: