API Reference

All endpoints require authentication via session cookie. Base URL: https://regtwinai.com

Streaming endpoints return Server-Sent Events (SSE). All request/response bodies are JSON unless noted otherwise.

Authentication

POST/api/auth/register

Register a new user and organization

Request Body

{ "name": "Jane Smith", "email": "jane@bank.com", "password": "...", "orgName": "First National Bank" }

Response

{ "user": { "id": "...", "email": "...", "name": "..." } }
POST/api/auth/[...nextauth]

NextAuth.js authentication (credentials, Google, Microsoft SSO)

Request Body

{ "email": "...", "password": "..." }

Response

Session object

Regulations

GET/api/regulations

List all regulations for the authenticated organization

Response

[{ "id": "...", "agency": "OCC", "referenceCode": "12 CFR 30", "title": "Safety and Soundness", "status": "active" }]
POST/api/regulations

Create a new regulation

Request Body

{ "agency": "OCC", "referenceCode": "12 CFR 30", "title": "...", "description": "..." }

Response

{ "id": "...", "agency": "OCC", ... }

Controls

GET/api/controls

List all controls for the organization

Response

[{ "id": "...", "title": "AML Transaction Monitoring", "controlType": "detective", "status": "active" }]
POST/api/controls

Create a new control

Request Body

{ "title": "...", "description": "...", "controlType": "preventive", "department": "BSA/AML" }

Response

{ "id": "...", ... }

Mappings

GET/api/mappings

List regulation-to-control mappings

Response

[{ "regulationId": "...", "controlId": "...", "gapStatus": "fully_mapped" }]
POST/api/mappings

Create a regulation-control mapping

Request Body

{ "regulationId": "...", "controlId": "...", "gapStatus": "fully_mapped" }

Response

{ "id": "...", ... }

AI Agents (Streaming)

POST/api/ai/assess

Run regulatory impact assessment

Request Body

{ "regulationId": "..." }

Response

{ "taskId": "...", "assessment": { "keyRequirements": [...], "controlGaps": [...] } }
POST/api/ai/gaps/stream

Stream gap analysis (SSE)

Response

Server-Sent Events: thinking → tool_call → tool_result → action → complete
POST/api/ai/predict/stream

Stream audit predictions (SSE)

Response

Server-Sent Events with predicted findings and readiness score
POST/api/ai/report/stream

Stream board report generation (SSE)

Request Body

{ "reportType": "board" | "committee" | "management" }

Response

Server-Sent Events with generated report
POST/api/ai/remediation/stream

Stream remediation plan generation (SSE)

Response

Server-Sent Events with plans and milestones
POST/api/ai/defend/stream

Stream exam defense analysis (SSE)

Request Body

{ "findingId": "...", "mode": "decompose" | "map" | "draft_response" | "generate_evidence" | "simulate_examiner" }

Response

Server-Sent Events with defense artifacts

Exam Defense

GET/api/defend/findings

List all examination findings

Response

[{ "id": "...", "title": "BSA/AML Deficiencies", "findingType": "mra", "regulator": "occ", "status": "uploaded" }]
POST/api/defend/findings

Upload a new finding

Request Body

{ "title": "...", "findingType": "mra", "regulator": "occ", "rawText": "Full finding text..." }

Response

{ "id": "...", "status": "uploaded" }
GET/api/defend/findings/:id

Get finding with obligations, mappings, evidence, and response drafts

Response

{ "id": "...", "obligations": [...], "responseDrafts": [...] }
PUT/api/defend/findings/:id

Update finding (title, status, etc.)

Request Body

{ "title": "Updated title", "status": "submitted" }

Response

{ "id": "...", ... }
GET/api/defend/findings/:id/response

Get response drafts for a finding

Response

[{ "id": "...", "version": 1, "responseText": "...", "acceptanceProbability": 0.82 }]
PUT/api/defend/findings/:id/response

Update/approve a response draft

Request Body

{ "draftId": "...", "status": "approved" }

Response

{ "id": "...", "status": "approved" }
PUT/api/defend/evidence/:id

Update evidence item status or attach artifact

Request Body

{ "status": "collected", "artifactUrl": "https://..." }

Response

{ "id": "...", "status": "collected" }

Comments

GET/api/defend/comments?entityType=finding&entityId=:id

List comments for a finding or response draft

Response

[{ "id": "...", "body": "Looks good, approve.", "authorName": "Jane" }]
POST/api/defend/comments

Add a comment with @mentions

Request Body

{ "entityType": "finding", "entityId": "...", "body": "@jane please review this", "mentions": ["jane"] }

Response

{ "id": "...", ... }

Audit Trail

GET/api/ai/audit

List all agent tasks with status and confidence

Response

[{ "id": "...", "agentType": "audit_defender", "taskType": "finding_decomposition", "status": "completed", "confidenceScore": 0.87 }]
GET/api/ai/audit?taskId=:id

Get full task detail with reasoning chain and approvals

Response

{ "task": {...}, "reasoning": [{...}], "approvals": [{...}] }
GET/api/ai/audit/export

Export full audit trail (all tasks with reasoning chains)

Response

{ "exportedAt": "...", "totalTasks": 42, "tasks": [...] }

Calendar

GET/api/calendar

Get all compliance deadlines (findings, obligations, remediation, milestones)

Response

[{ "id": "...", "type": "finding_deadline", "title": "...", "date": "2026-06-30", "status": "...", "severity": "high" }]

File Upload

POST/api/upload

Upload evidence file (PDF, images, Excel, Word). Max 10MB.

Request Body

multipart/form-data with 'file' field

Response

{ "url": "https://...", "pathname": "...", "size": 1234, "contentType": "application/pdf" }

Settings & Admin

GET/api/notifications

List notification recipients

Response

[{ "id": "...", "name": "...", "email": "...", "watchdogAlerts": true, "defendAlerts": true }]
PUT/api/notifications

Update recipient preferences

Request Body

{ "id": "...", "watchdogAlerts": true, "defendAlerts": false }

Response

{ "id": "...", ... }
GET/api/users/search?q=jane

Search users in org (for @mentions)

Response

[{ "id": "...", "name": "Jane Smith", "email": "jane@bank.com" }]

Need help? Contact support@regtwinai.com