Streaming chat with the FOIA Expert Agent (SSE)
Authentication
Request
Session ID for conversation continuity. Auto-generated if omitted.
Previous conversation history for multi-turn sessions
Streaming chat with the FOIA Expert Agent (SSE)
Session ID for conversation continuity. Auto-generated if omitted.
Previous conversation history for multi-turn sessions
Send a message and receive Server-Sent Events as the agent processes.
Identical functionality to /api/agent/chat but streams text incrementally
for real-time UI rendering.
SSE Event Types:
text_delta — Streaming text chunk: {"type":"text_delta","text":"..."}tool_call — Tool invocation: {"type":"tool_call","tool":"analyze_jurisdiction"}tools_used — Summary after completion: {"type":"tools_used","tools":[...]}usage — Token counts: {"type":"usage","input_tokens":1234,"output_tokens":567}error — Error event: {"type":"error","message":"..."}[DONE] — Stream terminatorConnection: Returns text/event-stream with Cache-Control: no-cache.
Example stream:
Auth0 JWT Bearer Token Authentication
All protected endpoints require a valid JWT token issued by Auth0.
dev-4fszoklachwdh46m.us.auth0.comhttps://dev-4fszoklachwdh46m.us.auth0.com/https://api.theholefoundation.orghttps://dev-4fszoklachwdh46m.us.auth0.com/.well-known/jwks.jsonFor End Users (Web Application):
For M2M (Service-to-Service):
Include the JWT in the Authorization header of all API requests:
Step 1: Fetch JWKS from Auth0
Step 2: Validate JWT
Step 3: Extract User ID
Step 4: Check Permissions
Every Auth0 JWT contains these claims:
read:transparencyread:transparencyread:foia, write:foiachat:assistantcompile:documentsread:database (admin: admin:database)execute:workflowsread:storage, write:storageread:vectors, write:vectors (admin: admin:vectors)read:projects, write:projects401 Unauthorized - Missing or invalid token:
401 Unauthorized - Expired token:
403 Forbidden - Insufficient permissions:
iss claim matches Auth0 tenantaud claim matches your API identifierexp claim to reject expired tokenssub claim for resource scopingsub claim to prevent abuseBetterAuth (Neon’s authentication layer) uses Auth0 as the JWT provider:
auth.user_id() functionsub claimExample RLS Policy:
All generated SDKs include Auth0 authentication helpers:
TypeScript SDK:
Python SDK: