Documentation IndexFetch the complete documentation index at: /llms.txtUse this file to discover all available pages before exploring further.
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Protect Express routes with ImaRobot token verification.
npm install imarobot-verify
import express from 'express'; import { createVerifier } from 'imarobot-verify'; const app = express(); const verifier = createVerifier({ publishableKey: process.env.IMAROBOT_PUBLISHABLE_KEY, }); // Protect all routes under /api app.use('/api', verifier.middleware()); app.get('/api/accounts', (req, res) => { const { agentId, scopes } = req.agent; res.json({ agentId, scopes }); });
app.get('/api/accounts', verifier.middleware(), (req, res) => { if (!req.agent.scopes.includes('read:accounts')) { return res.status(403).json({ error: 'FORBIDDEN' }); } // ... });
401
{ "error": { "code": "UNAUTHORIZED", "message": "Missing Authorization header.", "request_id": "req_abc123" } }
req.agent
req.agent = { agentId: string, name: string, issuer: string, scopes: string[], expiresAt: string, }
// Public route — no auth app.get('/health', (req, res) => res.json({ ok: true })); // Protected route — requires valid ImaRobot token app.get('/api/data', verifier.middleware(), handler);