Session verification
A personal agent sends the Poppy-Session header to your APIs, not to LumoAuth. The header is a JWT that the agent signs for that one request. Verifying it takes a metadata fetch, two signature checks and a Session record. LumoAuth does all of it in one call.
This page is part of Personal Agent Protocol. To control an OpenClaw or Hermes agent on your own machine, see Secure OpenClaw and Hermes agents instead.
POST /orgs/{orgId}/api/v1/poppy/sessions/verify
POST /orgs/{orgId}/api/v1/poppy/sessions/status
POST /orgs/{orgId}/api/v1/poppy/sessions/end
On a custom domain the paths are /api/v1/poppy/sessions/verify, /api/v1/poppy/sessions/status and /api/v1/poppy/sessions/end.
Who may call it
Your service authenticates as one of your organization's confidential applications. Use HTTP Basic with the client id and secret, client_id and client_secret in the JSON body, or a private_key_jwt client assertion in the body.
The application's allowed scopes must include poppy:verify. Add the scope under Applications, on the application that your API uses. An administrator gives this permission on purpose: an application without it gets 403 insufficient_scope.
A personal agent can never call these endpoints. A client with a metadata document, or a public client, gets 401 invalid_client.
Verify a request
Forward what you received: the method, the public URL and the protocol's headers.
curl -X POST https://app.lumoauth.dev/orgs/acme-corp/api/v1/poppy/sessions/verify \
-u "$SHOP_API_CLIENT_ID:$SHOP_API_CLIENT_SECRET" \
-H "Content-Type: application/json" \
-d '{
"method": "POST",
"url": "https://shop.example.com/api/orders/ord_1042/return",
"headers": {
"poppy-session": "eyJ0eXAiOiJwb3BweS1zZXNzaW9uK2p3dCIs…",
"poppy-version": "1.0",
"authorization": "Bearer eyJhbGciOi…Qp4w"
},
"required_scope": "orders:write"
}'
| Member | Required | Meaning |
|---|---|---|
method | Yes | The method of the request that you received. |
url | Yes | The address that the personal agent called, without the query. It must be https://. An http:// address is accepted only for localhost, 127.0.0.1 and [::1], so that you can run your API on your own machine. |
headers | Yes | The request's headers by name, in any case. LumoAuth reads poppy-session, poppy-version, poppy-extensions, authorization and dpop. No other header is used. |
required_scope | No | The scopes that the operation needs: a space-separated string or a list. |
resource | No | The resource identifier of your service, when it takes only tokens issued for it. See Tokens for one service. |
allow_replay | No | true accepts a Session JWT that was verified before. See Replays. |
The answer is always 200 when your own call is valid. active says whether the request is verified.
A verified signed-out request
{
"active": true,
"client_id": "https://agent.example/agent.json",
"client_name": "Example Agent",
"user_id": "usr_Q7c1vK",
"agent_id": null,
"session": {
"id": 4821,
"sid": "Yx2b7Qd_Kp8mR3vT1nWc4A",
"new": true,
"started_at": "2026-11-26T10:15:00+00:00"
},
"signed_in": false,
"account": null,
"version": "1.0",
"extensions": {}
}
| Member | Meaning |
|---|---|
client_id, client_name | The personal agent. The name is the agent's own claim. The client_id is what was checked. |
user_id | The agent's stable name for its user at your company. It is not an account. |
agent_id | Set when the personal agent runs several agents for one user and says which one this is. |
session.id | LumoAuth's id of the Session. Store your own Session state under it, such as a cart. |
session.new | true when this request started the Session. |
signed_in, account | Whether the request carried a valid access token, and whose it is. |
version | The Poppy-Version of the request. |
extensions | The extensions that the request declares, as name and version. |
A verified signed-in request
{
"active": true,
"client_id": "https://agent.example/agent.json",
"client_name": "Example Agent",
"user_id": "usr_Q7c1vK",
"agent_id": null,
"session": {
"id": 4821,
"sid": "Yx2b7Qd_Kp8mR3vT1nWc4A",
"new": false,
"started_at": "2026-11-26T10:15:00+00:00"
},
"signed_in": true,
"account": {
"sub": "0193a5c2-7d1e-7c7a-9a52-3f0f2b6c9e11",
"scope": "orders:read orders:write",
"aud": ["https://agent.example/agent.json"],
"exp": 1795000000,
"token_type": "Bearer"
},
"version": "1.0",
"extensions": {}
}
account.sub is the id of the user in your LumoAuth organization. account.scope holds the scopes of the access token. When you pass required_scope, LumoAuth has already checked them.
A rejection
A rejection carries the protocol's error and the exact response for the personal agent:
{
"active": false,
"error": "invalid_session",
"error_description": "The Session JWT was signed for another URL (htu).",
"response": {
"status": 400,
"headers": { "Cache-Control": "no-store" },
"body": {
"error": "invalid_session",
"error_description": "The Session JWT was signed for another URL (htu)."
}
}
}
Return response unchanged: its status, its headers and its body. The protocol puts Session errors in a JSON body with status 400. It puts access token errors in WWW-Authenticate with no body, so body is then null.
error | response.status | response carries | When |
|---|---|---|---|
invalid_session | 400 | JSON body | The header is missing or a check failed. Also when you do not accept the agent, or its token was issued to another client. |
session_ended | 400 | JSON body | The Session was ended, or the request names another account than the Session used. |
version_unsupported | 400 | JSON body | Poppy-Version is missing or not compatible with 1.0. |
account_required | 401 | WWW-Authenticate: Bearer scope="…" | You passed required_scope and the request has no access token. The result also has scope. |
invalid_token | 401 | WWW-Authenticate: Bearer error="invalid_token", … | The access token is expired, revoked, not for your service, or its DPoP proof is missing or wrong. |
insufficient_scope | 403 | WWW-Authenticate: Bearer error="insufficient_scope", scope="…" | The access token lacks a scope of required_scope. The result also has scope. |
too_many_requests | 429 | Retry-After, JSON body | The personal agent started too many Sessions. |
Relay the answer
One function in front of your API does the whole job.
- Node.js
- Python
- PHP
const VERIFY_URL = 'https://app.lumoauth.dev/orgs/acme-corp/api/v1/poppy/sessions/verify';
const PUBLIC_ORIGIN = 'https://shop.example.com';
const BASIC = 'Basic ' + Buffer.from(
`${process.env.SHOP_API_CLIENT_ID}:${process.env.SHOP_API_CLIENT_SECRET}`,
).toString('base64');
const FORWARDED = ['poppy-session', 'poppy-version', 'poppy-extensions', 'authorization', 'dpop'];
// Express middleware. Use it as: app.get('/api/orders', poppy('orders:read'), handler)
function poppy(requiredScope = '') {
return async (req, res, next) => {
const headers = {};
for (const name of FORWARDED) {
if (typeof req.headers[name] === 'string') headers[name] = req.headers[name];
}
const answer = await fetch(VERIFY_URL, {
method: 'POST',
headers: { 'Content-Type': 'application/json', Authorization: BASIC },
body: JSON.stringify({
method: req.method,
// The path as the personal agent sent it: req.path is relative to a router's mount point.
url: PUBLIC_ORIGIN + req.originalUrl.split('?')[0],
headers,
...(requiredScope ? { required_scope: requiredScope } : {}),
}),
});
if (answer.status !== 200) return next(new Error(`Verification failed: ${answer.status}`));
const who = await answer.json();
if (!who.active) {
// The response that the personal agent must get, unchanged.
res.status(who.response.status).set(who.response.headers);
return who.response.body === null ? res.end() : res.json(who.response.body);
}
req.poppy = who; // who.client_id, who.user_id, who.session.id, who.account
next();
};
}
import os
import requests
from flask import Flask, g, jsonify, make_response, request
VERIFY_URL = "https://app.lumoauth.dev/orgs/acme-corp/api/v1/poppy/sessions/verify"
PUBLIC_ORIGIN = "https://shop.example.com"
FORWARDED = ("poppy-session", "poppy-version", "poppy-extensions", "authorization", "dpop")
app = Flask(__name__)
def verify_poppy(required_scope=""):
"""Returns None when the request is verified, or the response to send."""
headers = {name: request.headers[name] for name in FORWARDED if name in request.headers}
# The path as the personal agent sent it. request.path is already decoded.
raw_target = request.environ.get("RAW_URI") or request.environ.get("REQUEST_URI") or request.path
body = {"method": request.method, "url": PUBLIC_ORIGIN + raw_target.split("?", 1)[0], "headers": headers}
if required_scope:
body["required_scope"] = required_scope
answer = requests.post(
VERIFY_URL,
json=body,
auth=(os.environ["SHOP_API_CLIENT_ID"], os.environ["SHOP_API_CLIENT_SECRET"]),
timeout=5,
)
answer.raise_for_status()
who = answer.json()
if not who["active"]:
# The response that the personal agent must get, unchanged.
relayed = who["response"]
response = make_response(jsonify(relayed["body"]) if relayed["body"] is not None else "", relayed["status"])
response.headers.update(relayed["headers"])
return response
g.poppy = who # who["client_id"], who["user_id"], who["session"]["id"], who["account"]
return None
@app.get("/api/orders")
def orders():
rejection = verify_poppy("orders:read")
if rejection is not None:
return rejection
return jsonify(orders=load_orders(g.poppy["account"]["sub"]))
<?php
const VERIFY_URL = 'https://app.lumoauth.dev/orgs/acme-corp/api/v1/poppy/sessions/verify';
const PUBLIC_ORIGIN = 'https://shop.example.com';
const FORWARDED = ['poppy-session', 'poppy-version', 'poppy-extensions', 'authorization', 'dpop'];
/**
* Returns the verification result, or sends the rejection and stops.
*/
function verifyPoppy(string $requiredScope = ''): array
{
$headers = [];
foreach (getallheaders() as $name => $value) {
if (in_array(strtolower($name), FORWARDED, true)) {
$headers[strtolower($name)] = $value;
}
}
$body = [
'method' => $_SERVER['REQUEST_METHOD'],
'url' => PUBLIC_ORIGIN . parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH),
'headers' => (object) $headers,
];
if ($requiredScope !== '') {
$body['required_scope'] = $requiredScope;
}
$request = curl_init(VERIFY_URL);
curl_setopt_array($request, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 5,
CURLOPT_USERPWD => getenv('SHOP_API_CLIENT_ID') . ':' . getenv('SHOP_API_CLIENT_SECRET'),
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode($body),
]);
$answer = curl_exec($request);
if ($answer === false || curl_getinfo($request, CURLINFO_RESPONSE_CODE) !== 200) {
http_response_code(502);
exit;
}
$who = json_decode($answer, true);
if (!$who['active']) {
// The response that the personal agent must get, unchanged.
http_response_code($who['response']['status']);
foreach ($who['response']['headers'] as $name => $value) {
header($name . ': ' . $value);
}
if ($who['response']['body'] !== null) {
header('Content-Type: application/json');
echo json_encode($who['response']['body']);
} else {
// No body: stop PHP from adding its default Content-Type.
ini_set('default_mimetype', '');
}
exit;
}
return $who; // $who['client_id'], $who['user_id'], $who['session']['id'], $who['account']
}
$who = verifyPoppy('orders:read');
A status other than 200 from the verification endpoint is about your call, not about the personal agent. Do not relay it. Answer the personal agent with a 5xx status and fix your configuration.
What LumoAuth checks
The checks run in this order. Each failure is invalid_session unless the list says otherwise.
- Shape. The JWT has
typpoppy-session+jwt,algES256, akidand a delegation inpoppy_dlg. Every required claim is present. - Audience.
audis your Company identifier, character for character, as one string. - The request.
htmis the method andhtuis the URL that you sent.iatis at most 60 seconds old, with 30 seconds of clock skew. - The token binding.
athis the hash of the access token. Without a token,athis absent. - The personal agent. LumoAuth fetches its metadata document and applies your allowed domains and blocks.
- The delegation. A key of the agent's key set signed it, with
ES256orPS384. Itstypispoppy-delegation+jwt, itsissis the JWT'siss, it has not expired, and it lasts at most 24 hours. - The signature. The key in the delegation's
cnf.jwksigned the Session JWT, andkidis that key's thumbprint. A Session JWT that a key of the key set signed directly is rejected. - The version.
Poppy-Versionis compatible with 1.0, or the answer isversion_unsupported. - Replay. The JWT was not verified before.
- The access token. It is active, it was issued to the JWT's
iss, and it may be used at your service. A wrong token isinvalid_token. Then LumoAuth appliesrequired_scope. - The Session. LumoAuth starts it or continues it, or answers
session_ended.
LumoAuth also rejects a delegated key that signed for one User ID and then signs for another.
The public URL
htu is the address that the personal agent used. Behind a proxy or a load balancer, your server sees another host or path. Build url from your configured public origin and the request path. Never build it from the Host header.
Use the path as the personal agent sent it. Many frameworks also offer a path that is already decoded, or a path relative to the place where a router is mounted. Neither one equals htu for every request. In Express, use req.originalUrl without the query, not req.path.
LumoAuth verifies an address of up to 2,048 characters. A longer one is rejected with invalid_session.
Replays
A Session JWT is good for one verification. A second call with the same JWT gets invalid_session. Verify each request once, at your gateway or in one middleware, and pass the result inward.
Some services check one request in several places. For those, send "allow_replay": true. A copied JWT then still works only for the same method, URL and access token, and only for about a minute. Make your writes safe to repeat.
DPoP
When the access token is bound to a DPoP key, include the dpop header. LumoAuth verifies the proof against the method and URL that you sent. A missing or wrong proof is invalid_token, and the response carries a DPoP challenge next to the Bearer one. account.token_type says whether the token is DPoP or Bearer.
Tokens for one service
By default one access token works at all of your services. A service that takes only tokens issued for it publishes its own protected resource metadata. An MCP server does that.
Such a service passes its resource identifier:
{
"method": "POST",
"url": "https://mcp.shop.example.com/mcp",
"headers": { "poppy-session": "…", "poppy-version": "1.0", "authorization": "Bearer …" },
"resource": "https://mcp.shop.example.com/mcp"
}
- With
resource, the token's audience must contain that value. The default token is rejected withinvalid_token. - Without
resource, LumoAuth accepts the default token and a token for one of your Company domains. A token that was issued for another service is rejected.
The personal agent gets a token for your service with resource on its token request. See Tokens for one service.
End a Session
End a Session when your own rules call for it, for example after a fraud signal. Later requests with its sid get session_ended, and the personal agent starts a new Session. The user stays signed in.
curl -X POST https://app.lumoauth.dev/orgs/acme-corp/api/v1/poppy/sessions/end \
-u "$SHOP_API_CLIENT_ID:$SHOP_API_CLIENT_SECRET" \
-H "Content-Type: application/json" \
-d '{
"personal_agent": "https://agent.example/agent.json",
"sid": "Yx2b7Qd_Kp8mR3vT1nWc4A"
}'
{ "ended": true }
ended is false when the Session had ended before. An unknown Session gets 404 not_found. An administrator can also end a Session under AI Agents → Personal agents → Sessions, or through the Admin API.
To end an agent's access to an account, do not end its Sessions. Revoke its tokens or block the agent, as Client ID Metadata Documents describes.
Look up a Session
Sometimes you must know the state of a Session when the personal agent sent no request. The main case is a website that joined a browser to a Session. Its cookie must stop acting for the account when the user signs out or disconnects the personal agent. Ask LumoAuth on each page request.
curl -X POST https://app.lumoauth.dev/orgs/acme-corp/api/v1/poppy/sessions/status \
-u "$SHOP_API_CLIENT_ID:$SHOP_API_CLIENT_SECRET" \
-H "Content-Type: application/json" \
-d '{
"personal_agent": "https://agent.example/agent.json",
"sid": "Yx2b7Qd_Kp8mR3vT1nWc4A"
}'
{
"status": "active",
"user_id": "usr_Q7c1vK",
"agent_id": null,
"account": "0195c7e2-5b1c-7d41-9a3e-0f6c2b7a9d10",
"signed_in": true,
"last_seen_at": "2026-11-26T10:15:00+00:00"
}
| Field | Meaning |
|---|---|
status | active, ended, or unknown when no Session has that sid. A Session that nothing used for the idle period is forgotten, and is unknown after that. |
account | The id of the account that the Session used, or null. |
signed_in | true while the Session is active, it used an account, and the personal agent still holds a valid refresh token for that account. |
signed_in becomes false when the personal agent revokes its refresh tokens, when the user removes the agent under Authorized apps, and when an administrator blocks the agent. The Session itself continues signed out, so status stays active.
For a joined browser, apply these rules:
statusis notactive: drop the cookie. The browser is a visitor again.signed_inisfalse, oraccountis not the account of the join: keep the Session, and treat the browser as signed out.
Errors of your own call
| Status | error | Meaning |
|---|---|---|
| 400 | invalid_request | The body is not a JSON object, or method, url, headers, required_scope or resource is missing or malformed. |
| 401 | invalid_client | Your application did not authenticate, or it is not a confidential application of this organization. |
| 403 | insufficient_scope | Your application lacks the poppy:verify scope. |
| 404 | not_found | Unknown organization, or the protocol is switched off. |
| 429 | too_many_requests | More than 6,000 calls in 60 seconds from one application. The response has Retry-After. |
Using the result
- Signed-out state. Store it under
session.id. To recognize a visitor across Sessions, store it underclient_idanduser_idtogether. - Account data. Use
account.sub. Never useuser_idto find an account: the personal agent chose that value. - Scopes. Pass
required_scopefor each operation. For a finer rule, readaccount.scope. - Rate limits by agent. Count by
client_idonly after a verified answer. - Logs. Log
client_idandsession.id. Never log the headers that you forwarded. - Caching. Do not cache an answer. Each request has its own Session JWT.
Use it for a browser-session endpoint
The second step of the protocol's browser join is a request from the personal agent with a Session header. Verify it like any other request. Pass "required_scope": "poppy:browser-sign-in" only when the request carries an Authorization header. Keep client_id and session.sid of the answer with your cookie, and look up the Session on each page request. The sample Company shows all three steps.
Related
- Personal Agent Protocol: overview, settings and sign-in rules
- Sample Company and test personal agent
- Token introspection, for access tokens outside the protocol
- Specification, section 5.3