Skip to main content
Last updated on
Advanced — 0.0.x primitives

You don't need this page for a normal integration. Use the quickstarts and createMythos() instead. These low-level functions remain exported for custom setups.

Required routes

Every Producer app must expose these routes on every server entry point that serves production traffic.

info

Just getting started? Quickstart: Next.js · Quickstart: FastAPI

Route overview​

RouteSDK primitiveRequired
GET /.well-known/mythos-handshake?lt=handshakeRoute() / handshake_routerYes
GET /api/mythos/session?lt=requireLaunchToken() / require_launch_token()Yes
POST /api/mythos/report-usagereportUsage() / report_usage()Yes
GET|POST /.well-known/mythos-listing-registered?lt=listingCallbackRoute() / create_listing_callback_handlerOptional
warning

If your app has multiple entry points (e.g. backend/main.py for local dev and api/index.py on Vercel), Mythos routes must exist on every entry point that serves production traffic.

1. Handshake​

text
GET /.well-known/mythos-handshake?lt=<handshake-jwt>
StatusBodyMeaning
200{"ok":true,"sdk_version":"0.1.0"}SDK installed and reachable
401{"error":"Missing launch token"}No lt param
401{"error":"Invalid launch token"}Bad, expired, or wrong-purpose token
503{"error":"Service unavailable"}Unexpected server error

Node mount: app.use(handshakeRoute())

Python mount: app.include_router(handshake_router)

2. Session exchange​

text
GET /api/mythos/session?lt=<launch-jwt>

Verifies signature, validates audience, calls Mythos /consume.

StatusMeaning
200Token valid and consumed; return session
401Missing, invalid, or already-consumed token
503Mythos /consume unreachable — fail closed

Session response shape​

Node (wrapped — recommended):

json
{
"ok": true,
"session": {
"userId": "...",
"email": "...",
"displayName": "...",
"listingId": "...",
"sessionJti": "..."
}
}

Python (flat — also valid):

json
{
"userId": "...",
"email": "...",
"displayName": "...",
"listingId": "...",
"sessionJti": "..."
}

Pick one shape and use it consistently in frontend code. The current browser client manages this automatically.

3. Report usage​

text
POST /api/mythos/report-usage

Node request body:

json
{ "sessionJti": "...", "credits": 1, "reason": "page-view" }

Python request body:

json
{ "session_jti": "...", "credits": 1, "reason": "page-view" }
StatusMeaning
200Billed successfully
402Insufficient funds
404Session not found
503Mythos API error

4. Listing callback (optional)​

text
GET|POST /.well-known/mythos-listing-registered?lt=<listing-registered-jwt>
StatusBodyMeaning
200{"ok":true}Listing ID persisted
401{"error":"Missing listing callback token"}No lt param
401{"error":"Invalid listing callback token"}Bad or wrong-purpose token
503{"error":"Service unavailable"}Callback handler failed

See Dynamic listing IDs.

Route naming​

Use /api/mythos/report-usage consistently. Avoid drift (/api/mythos/usage, /api/mythos-usage) — pick one path and match your frontend.

Next steps​