SDK & verify
The complete POST /api/verify contract — request shape, every HTTP status and error message, response shapes, and the @agentonboard/sdk client
SDK & verify
Verification is the heart of the partner integration: your API sends the agent's session token to AgentOnboard's POST /api/verify, and AgentOnboard answers with the user's email — or a structured error. This page documents the exact contract and the official @agentonboard/sdk client that wraps it.
The one-line version
import { verify } from "@agentonboard/sdk";
const result = await verify(partnerKey, sessionToken);
if (result.ok) {
const email = result.email; // the AgentOnboard login email
} else {
const error = result.error; // a human-readable failure reason
}Install
npm install @agentonboard/sdkverify(partnerKey, sessionToken, apiUrl?)
The SDK exposes a single function:
verify(
partnerKey: string, // your partner key (Authorization: Bearer)
sessionToken: string, // the agent's session token
apiUrl?: string, // defaults to "https://api.ao.aawej.in"
): Promise<VerifyResult>apiUrl is optional and rarely needed — it exists for local development and self-hosting. The default points at the hosted AgentOnboard API.
verify() never throws
The SDK catches network failures and returns them as an error result, so you can handle every failure with one if (!result.ok) check.
VerifyResult
Prop
Type
What the SDK sends
Under the hood, verify() makes exactly this request:
POST https://api.ao.aawej.in/api/verify
Authorization: Bearer <partnerKey>
Content-Type: application/json
{ "sessionToken": "<sessionToken>" }The same call in plain fetch, if you prefer not to use the SDK:
const res = await fetch("https://api.ao.aawej.in/api/verify", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${partnerKey}`,
},
body: JSON.stringify({ sessionToken }),
});
const body = await res.json();The POST /api/verify contract
Request
| Part | Value |
|---|---|
| Method | POST |
| Path | {apiUrl}/api/verify — default https://api.ao.aawej.in/api/verify |
| Header | Authorization: Bearer <partnerKey> |
| Body | { "sessionToken": "<sessionToken>" } (JSON) |
Response
Prop
Type
HTTP statuses
| Status | When | Response body |
|---|---|---|
200 | Valid partner key and a valid, unexpired session token | { "email": "<email>" } |
400 | Body is not valid JSON | { "error": "Invalid JSON body" } |
400 | sessionToken is missing or not a string | { "error": "Missing or invalid sessionToken" } |
401 | No Authorization header, or it does not start with Bearer | { "error": "Missing or invalid partner key" } |
401 | Bearer with an empty key | { "error": "Missing partner key" } |
401 | The partner key is not recognised | { "error": "Invalid partner key" } |
401 | The session token is invalid or expired | { "error": "Invalid or expired session token" } |
403 | The partner key has been revoked | { "error": "Partner key has been revoked" } |
500 | Any unexpected server error | { "error": "<message>" } |
Reading the statuses
- 200 — success. The
emailin the response is the AgentOnboard login email of the user who minted the session token. This is the value you use to look up the account in your own system. - 400 — the request itself was malformed: bad JSON, or a missing/non-string
sessionToken. This is a client bug on the agent's side; your API should pass the token through untouched. - 401 — authentication failed: the partner key or the session token is missing, invalid, or expired. Treat these as "unauthenticated" and return a 401 to the agent.
- 403 — the partner key is revoked. AgentOnboard maps its internal
partner_key_revokederror to 403 so you can distinguish "this key is no longer valid" from "this token is no longer valid". Rotate the key in the partner dashboard and redeploy. - 500 — an AgentOnboard server error. Retry with backoff; if it persists, contact support.
Email is the join key
/api/verify returns the email the user used to sign up with AgentOnboard. The agent's request only ever reaches your API if that user is a real AgentOnboard account — the token is cryptographically bound to it. Match the returned email against your own user records (see Email & identity in the User Guide for the policy and the mismatch case).
Error handling in practice
A robust handler distinguishes the failure classes so the agent gets a sensible response:
const result = await verify(partnerKey, sessionToken);
if (!result.ok) {
// 400-class failures are the agent's fault — surface the message.
if (result.error === "Invalid or expired session token") {
return res.status(401).json({ error: "Session token invalid or expired" });
}
// The partner key itself is bad or revoked — this is on you, not the agent.
if (result.error === "Partner key has been revoked") {
console.error("Partner key revoked — rotate it in the dashboard");
return res.status(500).json({ error: "Service misconfigured" });
}
return res.status(401).json({ error: "Authentication failed" });
}Remember the SDK returns { ok: false, error: "Network error: cannot reach API" } when the API is unreachable — that is a server-side problem in your API, not an authentication failure.
Related
- Getting Started — wire this into your API in ten minutes
- Example app: REST API integration — how the notes app uses
verify()with aTokenVerifyResultunion - Example app: create & read notes — the endpoints an agent actually calls