Skip to content

API Reference

GRCFlow exposes a REST API at /api/v1/. As of v2.0.5 the backend shipped 400+ routes across 7 compliance frameworks (the catalog has since grown to 26 frameworks / 3,210 controls), risk, vendor, incident, BCM, evidence, reports, and admin surfaces - far more than can be kept in sync by hand in a Markdown file.

Canonical API reference = your running backend

The authoritative, always-current reference is the OpenAPI spec generated by FastAPI itself, served from your own deployment:

Location What it is
/openapi.json Machine-readable OpenAPI 3.1 schema (always available)
/docs Interactive Swagger UI - development only
/redoc ReDoc-rendered reference - development only

The interactive /docs and /redoc UIs are enabled only when ENVIRONMENT=development; they are disabled in production. The /openapi.json schema is always served. In development they live at http://localhost:8000/docs.

The sections below are a hand-curated tour of the most common surfaces for developers getting started. They are not exhaustive and they lag the backend - always cross-check against /openapi.json before coding.

Authentication

All API requests must include either:

  • a valid Cloudflare Access JWT in the CF_Authorization cookie or Cf-Access-Jwt-Assertion header (Cloudflare-mode deployments), or
  • a local JWT in the Authorization: Bearer <token> header (local-mode deployments - obtained via POST /api/v1/auth/login), or
  • an API key in the Authorization: Bearer sk-<key> header for machine-to-machine callers (there is no X-API-Key header).

API keys are scoped and deny-by-default. A key acts as the user who created it, is confined to that user's organization, and carries a read/write scope derived from each request (read: for safe methods, write: otherwise); a route with no scope mapping is refused with 403. Keys cannot reach user, invitation, organization-settings, system-admin, audit-log or explorer routes, and a key stops working when its creator is demoted, deactivated or deleted. See API Keys for the full scope table.

Base URL

https://your-domain.com/api/v1

Common Response Codes

Code Description
200 Success
201 Created
400 Bad Request - Invalid input
401 Unauthorized - Missing/invalid token
403 Forbidden - Insufficient permissions (write to an unlicensed install, or a scope an API key lacks)
404 Not Found
409 Conflict - e.g. install already initialized, or an assessment already completed
410 Gone - downloading a report that failed to generate
415 Unsupported Media Type - evidence upload of a disallowed file type
422 Validation Error - e.g. an empty (0-byte) evidence file
423 Locked - writing a finding on a completed assessment (reopen it first)
500 Internal Server Error - e.g. report generation failed (the reason is in detail)
503 Service Unavailable - evidence storage not configured, or session_store_unavailable when Redis is unreachable at sign-in

Frameworks

Since 2.3.1 the /frameworks/* routes require a signed-in active user (an API key needs the read:controls scope); they were previously anonymous.

List Frameworks

GET /frameworks

Response:

{
  "frameworks": [
    {
      "id": "SOC2",
      "name": "SOC 2 Type II",
      "version": "2017",
      "description": "Trust Services Criteria",
      "control_count": 61
    }
  ]
}

Get Framework

GET /frameworks/{framework_id}

List Framework Controls

GET /frameworks/{framework_id}/controls

Organizations

List Organizations

GET /orgs

Create Organization

POST /orgs
Content-Type: application/json

{
  "name": "Acme Corp",
  "slug": "acme-corp"
}

Admin only. A license covers one organization per install: once the install has its organization (first-run setup creates it), this endpoint answers 403 with {"detail": {"error": "organization_limit_reached", ...}} and creates nothing. On an install that has no organization yet, the caller becomes the new organization's administrator.

Get Organization

GET /orgs/{org_id}

Update Organization

PATCH /orgs/{org_id}
Content-Type: application/json

{
  "name": "Acme Corporation"
}

Delete Organization

DELETE /orgs/{org_id}

Users

Get Current User

GET /users/me

List Organization Users

GET /orgs/{org_id}/users

Create User

POST /orgs/{org_id}/users
Content-Type: application/json

{
  "email": "user@example.com",
  "display_name": "John Doe",
  "role": "auditor"
}

Roles: admin, manager, compliance_manager, contributor, auditor, viewer, employee (contributor = edit assigned compliance content, no admin; employee = own tasks/training/policy-attestation only)

Get User

GET /orgs/{org_id}/users/{user_id}

Update User

PATCH /orgs/{org_id}/users/{user_id}
Content-Type: application/json

{
  "role": "auditor"
}

Delete User

DELETE /orgs/{org_id}/users/{user_id}

Deactivate / Invite

POST /orgs/{org_id}/users/invite
POST /orgs/{org_id}/users/{user_id}/deactivate

Assessments

List Assessments

GET /orgs/{org_id}/assessments

Query Parameters: - framework - Filter by framework - status - Filter by status (pending, running, completed, failed)

Create Assessment

POST /orgs/{org_id}/assessments
Content-Type: application/json

{
  "framework": "SOC2",
  "name": "Q1 2026 SOC 2 Assessment",
  "version": "2017"
}

Get Assessment

GET /orgs/{org_id}/assessments/{assessment_id}

Delete Assessment

DELETE /orgs/{org_id}/assessments/{assessment_id}

Execute Assessment

Start AI-powered assessment execution.

POST /orgs/{org_id}/assessments/{assessment_id}/execute

Resume Assessment

Resolve an AI run that is paused at the human-review gate.

POST /orgs/{org_id}/assessments/{assessment_id}/resume
Content-Type: application/json

{
  "approval": true
}

{"approval": true} records the AI results as findings for review and lets the run finish (no control is marked passed or failed - each stays in manual review). {"approval": false} ends the run with status failed and records no findings.

Reopen Assessment

Return a completed assessment to pending so its locked findings can be edited.

POST /orgs/{org_id}/assessments/{assessment_id}/reopen

Returns 409 if the assessment is not completed.

Cancel Assessment

POST /orgs/{org_id}/assessments/{assessment_id}/cancel

Get Assessment Status

GET /orgs/{org_id}/assessments/{assessment_id}/status

Response:

{
  "assessment_id": "uuid",
  "status": "running",
  "progress": { "total": 20, "completed": 9 },
  "current_node": "evaluate_controls",
  "next_nodes": ["aggregate_findings"],
  "is_interrupted": false,
  "awaiting_review": false,
  "review": null,
  "error": null
}

progress is an object, not a percentage. When an AI run pauses for human review the status stays running, awaiting_review becomes true, and review carries the per-control proposed outcomes and confidence for the Awaiting your review panel. is_interrupted is also true between steps of a running job, so key the review panel on awaiting_review.


Findings

List Findings

GET /orgs/{org_id}/findings

Query Parameters: - assessment_id - Filter by assessment - status - Filter by status (pass, fail, not_applicable, manual_review) - severity - Filter by severity (critical, high, medium, low, info)

Get Finding

GET /orgs/{org_id}/findings/{finding_id}

Update Finding

PATCH /orgs/{org_id}/findings/{finding_id}
Content-Type: application/json

{
  "status": "pass",
  "remediation": "Implemented MFA for all users"
}

A finding on a completed assessment is locked: create, update and review return 423. Reopen the assessment first.

Findings from an AI documentation review carry extra, non-authoritative fields - ai_assessment (appears_satisfied / gap_identified / insufficient_evidence / no_evidence), ai_assessment_label, ai_assessment_confidence and ai_review_label. The control's status is unaffected by them and stays manual_review until a person or a policy-engine decision resolves it. See Findings.


Risk Management

The risk surface was restructured in v2.0 into sibling namespaces under /orgs/{org_id}/risks/:

Namespace Purpose
/risks/register Risk-register entries (inherent + residual scoring)
/risks/kris Key Risk Indicators (metrics + thresholds)
/risks/fair FAIR quantitative analyses
/risks/scenarios Scenario-based risk models
/risks/heatmap Aggregated heatmap data for the UI
/risks/dashboard Summary metrics for the Risk dashboard

List / Create Risk Register Entries

GET  /orgs/{org_id}/risks/register
POST /orgs/{org_id}/risks/register

POST body:

{
  "scenario_id": "uuid",
  "owner_id": "uuid",
  "business_unit": "Engineering",
  "inherent_likelihood": 3,
  "inherent_impact": 4,
  "residual_likelihood": 2,
  "residual_impact": 3,
  "treatment_strategy": "mitigate",
  "treatment_plan": "Roll out vendor security reviews and contractual controls"
}

A register entry instantiates a RiskScenario (referenced by scenario_id), so create the scenario under /risks/scenarios first.

Likelihood/Impact Scale: 1–5 (1 = Very Low, 5 = Very High) Treatment Strategy: mitigate, accept, transfer, avoid Risk Appetite Status: within_appetite, approaching_limit, exceeds_appetite, critical

Get / Update / Delete Risk Register Entry

GET    /orgs/{org_id}/risks/register/{entry_id}
PATCH  /orgs/{org_id}/risks/register/{entry_id}
DELETE /orgs/{org_id}/risks/register/{entry_id}

Get Risk Heatmap

GET /orgs/{org_id}/risks/heatmap

Response:

{
  "risks": [
    {
      "id": "uuid",
      "title": "Ransomware Attack",
      "inherent_likelihood": 3,
      "inherent_impact": 4,
      "inherent_score": 12,
      "residual_likelihood": 2,
      "residual_impact": 3,
      "residual_score": 6,
      "appetite_status": "within_appetite",
      "treatment": "mitigate"
    }
  ],
  "summary": {}
}

Key Risk Indicators (KRIs)

GET    /orgs/{org_id}/risks/kris
POST   /orgs/{org_id}/risks/kris
GET    /orgs/{org_id}/risks/kris/{kri_id}
PATCH  /orgs/{org_id}/risks/kris/{kri_id}
DELETE /orgs/{org_id}/risks/kris/{kri_id}
Content-Type: application/json

{
  "current_value": 245
}

Vendors

List Vendors

GET /orgs/{org_id}/vendors

Query Parameters: - status - Filter by status (prospective, onboarding, active, under_review, watch_list, offboarding, terminated) - tier - Filter by criticality tier (strategic, critical, operational, commodity)

Create Vendor

POST /orgs/{org_id}/vendors
Content-Type: application/json

{
  "name": "Cloud Provider Inc",
  "service_categories": ["infrastructure"],
  "criticality_tier": "critical",
  "primary_contact_email": "security@cloudprovider.com",
  "a2a_endpoint": "https://api.cloudprovider.com/.well-known/sovereign-a2a"
}

Get Vendor

GET /orgs/{org_id}/vendors/{vendor_id}

Update / Delete Vendor

PATCH  /orgs/{org_id}/vendors/{vendor_id}
DELETE /orgs/{org_id}/vendors/{vendor_id}
Content-Type: application/json

{
  "status": "active",
  "inherent_risk_rating": 85
}

See also: /orgs/{org_id}/vendors/assessments, /vendors/contracts, /vendors/stats.

A2A (Agent-to-Agent) Attestation

A2A is an MCP-over-HTTP protocol, not a bespoke REST endpoint. Instead of POST /vendors/{id}/attestation, an attestation is requested by speaking MCP to the vendor's A2A server (and to ours - we expose one too):

POST /api/v1/a2a/mcp
Content-Type: application/json

The client envelope is a JSON-RPC 2.0 request; the compliance/attest method requests an attestation for a single framework, with an optional list of controls (omit for all) and a requesting_party:

{
  "jsonrpc": "2.0",
  "method": "compliance/attest",
  "params": {
    "framework": "SOC2",
    "controls": ["CC6.1", "CC6.2"],
    "requesting_party": {
      "name": "ACME Corp",
      "identifier": "DUNS:123456789"
    },
    "nonce": "..."
  },
  "id": "request-123"
}

The other supported methods are compliance/verify, compliance/status, and compliance/capabilities.

Health + metrics:

GET /api/v1/a2a/health
GET /api/v1/a2a/metrics

See the A2A CLI for a concrete client: python -m src.backend.a2a.cli attest ….


Incidents

List Incidents

GET /orgs/{org_id}/incidents

Query Parameters: - status - Filter by status (new, triaging, in_progress, pending, resolved, closed, false_positive) - severity - Filter by severity (critical, high, medium, low, informational) - phase - Filter by NIST phase (detection, analysis, containment, eradication, recovery, post_incident)

Create Incident

POST /orgs/{org_id}/incidents
Content-Type: application/json

{
  "title": "Suspicious Login Activity",
  "description": "Multiple failed login attempts from unusual IP range",
  "category": "unauthorized_access",
  "severity": "high",
  "affected_systems": ["auth-server-01", "vpn-gateway"]
}

Categories: malicious_code, unauthorized_access, data_breach, denial_of_service, phishing, insider_threat, physical_security, other

Severity: critical, high, medium, low, informational

Get Incident

GET /orgs/{org_id}/incidents/{incident_id}

Response includes: - Incident details - Current phase - SLA status - Assigned tasks - Response timeline

Update Incident

PATCH /orgs/{org_id}/incidents/{incident_id}
Content-Type: application/json

{
  "severity": "critical",
  "commander_id": "uuid",
  "affected_records": 5000
}

Transition Incident Phase

Phase transitions are made with a standard PATCH on the incident:

PATCH /orgs/{org_id}/incidents/{incident_id}
Content-Type: application/json

{
  "phase": "containment",
  "notes": "Initial analysis complete, moving to containment"
}

Valid phases follow NIST 800-61: detection, analysis, containment, eradication, recovery, post_incident.

Get / Append Incident Timeline

GET  /orgs/{org_id}/incidents/{incident_id}/timeline
POST /orgs/{org_id}/incidents/{incident_id}/timeline

Response:

{
  "items": [
    {
      "timestamp": "2026-01-27T10:05:00Z",
      "event_type": "phase_transition",
      "description": "Phase changed from detection to analysis",
      "actor": "John Doe"
    }
  ]
}

Incident Tasks, Evidence, Metrics

GET,POST           /orgs/{org_id}/incidents/{incident_id}/tasks
PATCH,DELETE       /orgs/{org_id}/incidents/{incident_id}/tasks/{task_id}
POST               /orgs/{org_id}/incidents/{incident_id}/evidence/collect
GET                /orgs/{org_id}/incidents/{incident_id}/evidence/export
GET                /orgs/{org_id}/incidents/{incident_id}/metrics

Playbook execution has moved into the OPA policy surface; call POST /api/v1/orgs/{org_id}/opa/test with the incident context to evaluate a ransomware / phishing / DoS playbook policy. See the OpenAPI schema for the full request envelope.


Business Continuity Management

List Business Processes

GET /orgs/{org_id}/bcm/processes

Create Business Process

POST /orgs/{org_id}/bcm/processes
Content-Type: application/json

{
  "name": "Order Fulfillment",
  "description": "End-to-end order processing and delivery",
  "criticality": "business_critical",
  "rto_hours": 4,
  "rpo_hours": 1,
  "mtd_hours": 24,
  "process_owner_id": "uuid"
}

Criticality: mission_critical, business_critical, important, support

List / Create Dependencies

GET    /orgs/{org_id}/bcm/dependencies
POST   /orgs/{org_id}/bcm/dependencies
PATCH  /orgs/{org_id}/bcm/dependencies/{dependency_id}
DELETE /orgs/{org_id}/bcm/dependencies/{dependency_id}

Dependency Graph

Returns the full node/edge graph for the Bow-Tie / BCM visualization.

GET /orgs/{org_id}/bcm/dependency-graph

Response:

{
  "nodes": [
    {"id": "process-1", "type": "process", "name": "Order Fulfillment"},
    {"id": "asset-1", "type": "asset", "name": "PostgreSQL Primary"}
  ],
  "edges": [
    {"source": "process-1", "target": "asset-1", "dependency_type": "requires"}
  ]
}

Process → DR Plan Generation

Generates a tiered disaster-recovery plan (RTO/RPO-sequenced) for a single business process by walking its dependency graph.

POST /orgs/{org_id}/bcm/processes/{process_id}/generate-dr-plan

Response:

{
  "tiers": [
    {"tier": 1, "rto_hours": 1, "items": [{"type": "asset", "name": "Core Database"}]},
    {"tier": 2, "rto_hours": 4, "items": [{"type": "process", "name": "Order Fulfillment"}]}
  ]
}

Recovery Plans

GET,POST          /orgs/{org_id}/bcm/recovery-plans
GET,PATCH,DELETE  /orgs/{org_id}/bcm/recovery-plans/{plan_id}

Climate-Risk Analysis

POST /orgs/{org_id}/bcm/climate-risk

Assesses physical and transition climate risk for one business location and the assets listed in the request. Returns an overall rating, the physical and transition risks, per-asset exposure and recommendations. It does not analyze the dependency graph and does not report single points of failure; there is no single-point-of-failure endpoint.


Evidence

List Evidence

GET /orgs/{org_id}/evidence

Query Parameters: - finding_id - Filter by finding - assessment_id - Filter by assessment

Get Upload URL

Get a pre-signed URL to upload evidence to R2.

POST /orgs/{org_id}/evidence/upload-url
Content-Type: application/json

{
  "filename": "soc2-report-2026.pdf",
  "content_type": "application/pdf",
  "assessment_id": "uuid",
  "control_id": "CC6.1"
}

An optional size may be sent; a 0-byte file is refused here with 422. The file type is enforced on the server by extension and declared content type: a disallowed type (executables, scripts, no extension, or anything outside the allow-list such as .zip) is refused with 415. See Evidence for the allow-list. After uploading to the presigned URL, call POST /orgs/{org_id}/evidence/confirm to record the object (its SHA-256 is verified there; an empty object is rejected with 422).

Response:

{
  "upload_url": "https://...",
  "object_key": "evidence/...",
  "expires_in": 3600,
  "max_size": 104857600
}

Get Download URL

GET /orgs/{org_id}/evidence/download-url?key=<object_key>

Takes the evidence object key as a query parameter and returns a short-lived presigned URL. Requires the evidence store (Cloudflare R2) to be configured - otherwise returns 503 storage unavailable.

Integrity + Metadata

GET  /orgs/{org_id}/evidence/metadata?key=<object_key>
POST /orgs/{org_id}/evidence/verify

Bulk Import

POST /orgs/{org_id}/evidence-import/csv
POST /orgs/{org_id}/evidence-import/json

Reports

List / Create Reports

GET  /orgs/{org_id}/reports
POST /orgs/{org_id}/reports
Content-Type: application/json

{
  "report_type": "detailed_findings",
  "assessment_id": "uuid",
  "format": "pdf"
}

Report Types: executive_summary, detailed_findings, remediation_plan, evidence_package, gap_analysis, statement_of_applicability, system_security_plan, poam, board_pack, pci_saq, pci_roc, pci_aoc

pci_saq, pci_roc and pci_aoc exist only for PCI DSS assessments with a PCI engagement; for any other assessment creation returns 400 with the reason. pci_saq applies to SAQ engagements and pci_roc to ROC engagements (400 otherwise); pci_aoc applies to both. See PCI DSS Engagements.

Formats: pdf, json, csv, html, xlsx (the Reports page offers all five)

Creation returns 201 only when a file was produced. A generation that fails returns 500 with the reason in detail, and the attempt is listed with status failed; downloading a failed report returns 410.

Preview, Get Detail, Download

GET /orgs/{org_id}/reports/preview
GET /orgs/{org_id}/reports/{report_id}
GET /orgs/{org_id}/reports/{report_id}/download

PCI DSS Engagements

SAQ, ROC and AOC support on a PCI DSS assessment. Every route returns 400 for an assessment of another framework. Reads need assessment:read; writes need assessment:update, are recorded in the audit log, and return 423 once the assessment is completed (reopen it first).

GET /orgs/{org_id}/assessments/{assessment_id}/pci/validation-types
GET /orgs/{org_id}/assessments/{assessment_id}/pci/engagement
PUT /orgs/{org_id}/assessments/{assessment_id}/pci/engagement
GET /orgs/{org_id}/assessments/{assessment_id}/pci/requirements
PUT /orgs/{org_id}/assessments/{assessment_id}/pci/responses/{requirement_id}
PUT /orgs/{org_id}/assessments/{assessment_id}/pci/responses
GET /orgs/{org_id}/assessments/{assessment_id}/pci/validation

Set Up or Update the Engagement

PUT /orgs/{org_id}/assessments/{assessment_id}/pci/engagement
Content-Type: application/json

{
  "validation_type": "saq_a",
  "entity_type": "merchant",
  "profile": {
    "company": {"name": "Northwind Outfitters", "contact_name": "Dana Whitfield",
                "contact_email": "dana@northwind.example"},
    "payment_channels": ["ecommerce"],
    "eligibility_confirmed": [0, 1, 2, 3, 4, 5, 6],
    "overall_status": "compliant"
  }
}

Validation types: roc, saq_a, saq_a_ep, saq_b, saq_b_ip, saq_c, saq_c_vt, saq_p2pe, saq_spoc, saq_d_merchant, saq_d_service_provider

Entity types: merchant, service_provider (422 when the entity type cannot use the validation type)

Omit profile to keep the stored profile; when sent it replaces the stored profile as a whole. GET .../engagement returns 404 until an engagement exists. Changing the validation type keeps every recorded response and clears eligibility_confirmed.

Set a Requirement Response

PUT /orgs/{org_id}/assessments/{assessment_id}/pci/responses/8.3.6
Content-Type: application/json

{
  "response": "not_in_place",
  "remediation_target_date": "2027-01-31",
  "remediation_action": "Enforce the password length in the directory policy."
}

Responses: in_place, in_place_ccw, not_applicable, not_tested, not_in_place. Each validation type offers a subset (not_tested only for SAQ D and a ROC; a ROC uses in_place with "compensating_control": true instead of in_place_ccw). "response": null clears the response.

ROC engagements also accept customized_approach (boolean) with customized (control_name, control_description, objective_met, controls_matrix_reference, risk_analysis_reference, attesting_assessors, effectiveness_tests, maintenance_tests), and procedures: one entry per testing procedure with procedure_id (as listed in testing_procedures of the requirement), response, and the reference lists documentation_refs, interview_refs, other_evidence_refs and sample_set_refs, which cite the registers under profile.roc. Setting profile.designated_entity to true on a ROC engagement adds the 20 Appendix A3 requirements, which offer in_place, not_applicable and not_in_place only.

Detail fields: explanation and not_tested_description (Not Applicable / Not Tested), ccw (constraints, definition, objective, identified_risk, validation, maintenance), remediation_target_date, remediation_action, legal_exception, legal_exception_detail, and notes. Only the detail that belongs to the response is stored. 422 for a response the validation type does not offer or a requirement outside it.

PUT .../pci/responses takes {"items": [{"requirement_id": "...", ...}]} (up to 300) and is all or nothing.

Readiness

GET .../pci/validation returns ready and a list of gaps (code, message, requirement_ids, fields). While gaps remain, the pci_saq, pci_roc and pci_aoc reports are generated as drafts.


Segregation of Duties

Detects segregation-of-duties (SoD) conflicts - "toxic" combinations of roles or entitlements one person should not hold at once - and tracks the resulting violations and their mitigating controls. SOX-oriented.

No screen in the app yet. These endpoints are mounted and functional, but there is no dedicated SoD page; the only place SoD data surfaces in the UI is as a widget inside Analytics. Reads require ORG_READ; writes require ORG_CONFIGURE (admin).

Prefix: /orgs/{org_id}/sod

Method & path Purpose
GET /dashboard SoD summary statistics.
GET /rules · POST /rules List / create SoD rules.
POST /rules/initialize-defaults Seed the default SOX rule set.
GET/PATCH/DELETE /rules/{rule_id} Read, update, delete a rule.
GET /violations · GET /violations/{id} · PATCH /violations/{id} List, read, and work the violation workflow.
GET /controls · POST /controls · GET/PATCH/DELETE /controls/{id} Mitigating controls CRUD.
POST /analyze Run conflict analysis.
POST /analyze-role-matrix Analyze a supplied role matrix for conflicts.

Regulatory Change Management

Tracks regulations, regulatory changes, their compliance gaps, coverage, and deadlines, and maps regulations to controls.

No screen in the app yet. The router is mounted but there is no page, route, or sidebar entry - it is backend-only. Reads require ORG_READ; writes require ORG_CONFIGURE (admin).

Prefix: /orgs/{org_id}/regulatory

Method & path Purpose
GET "" · POST "" · GET/PATCH/DELETE /{regulation_id} Regulations CRUD.
GET /changes · POST /changes List / create regulatory changes.
POST /changes/{change_id}/acknowledge Acknowledge a change.
GET /gaps · GET/PATCH /gaps/{gap_id} List, read, and update semantic gaps.
POST /analyze Semantic gap analysis of a regulation against your controls.
GET /coverage · GET /deadlines Coverage summary and upcoming deadlines.
GET /{regulation_id}/mappings · POST /{regulation_id}/mappings Regulation-to-control mappings.
POST /{regulation_id}/mappings/{mapping_id}/verify · DELETE /{regulation_id}/mappings/{mapping_id} Verify or remove a mapping.

Contracts & Obligations

Tracks contracts and the obligations within them, with AI-assisted contract analysis and per-obligation completion tracking.

No screen in the app yet. Both routers are mounted but there is no page, route, or sidebar entry - backend-only. Reads require ORG_READ; writes require ORG_CONFIGURE (admin).

Prefix: /orgs/{org_id}/contracts (plus /orgs/{org_id}/obligations)

Method & path Purpose
GET "" · POST "" · GET/PATCH/DELETE /{contract_id} Contracts CRUD.
GET /expiring Contracts expiring soon.
POST /analyze Analyze supplied contract text with AI.
POST /{contract_id}/analyze Analyze a stored contract with AI.
GET /{contract_id}/obligations · POST /{contract_id}/obligations List / add obligations on a contract.
PATCH /{contract_id}/obligations/{obligation_id} Update an obligation.
POST /{contract_id}/obligations/{obligation_id}/complete Mark an obligation complete.
GET /orgs/{org_id}/obligations List obligations across all contracts.

Audit Trail

All audit routes require authentication (reading needs AUDIT_READ; exporting needs AUDIT_EXPORT, i.e. admin or auditor; retention needs ORG_CONFIGURE) and reject cross-organization callers. They are not reachable by API keys.

GET  /orgs/{org_id}/audit/log                 # browse (filters + pagination)
GET  /orgs/{org_id}/audit/entity-types        # distinct entity_type values present, for the filter
POST /orgs/{org_id}/audit/verify-chain        # recompute the hash chain
POST /orgs/{org_id}/audit/verify-signatures   # check Ed25519 signatures
GET  /orgs/{org_id}/audit-log/export          # export (csv, json, cef)

GET .../audit/entity-types returns { "items": ["finding", "policy", "risk", ...] }.

GET .../audit-log/export requires AUDIT_EXPORT (admin or auditor), applies the same entity_type/action/date filters as the browse endpoint, and includes the hash-chain checksums and Ed25519 signature fields. Each export is itself recorded as an EXPORT audit entry (actor, format, filters and row count, never the exported rows); CSV output is neutralized against spreadsheet-formula injection.

Setup & License

POST /setup/license
Content-Type: application/json

{ "license_key": "<signed key>" }

Anonymous only while no valid license is active (none, invalid or expired), so an operator can never be locked out. Once a valid license is active, replacing it requires a signed-in administrator (an anonymous caller gets 401, a non-admin 403); API keys are always treated as anonymous here.

Health & Status

Health Check

GET /health

Response:

{
  "status": "healthy",
  "components": {
    "database": "healthy",
    "redis": "healthy",
    "llm": "healthy"
  },
  "version": "2.5.3",
  "timestamp": "2026-06-20T15:48:22+00:00",
  "uptime_seconds": 56876.63
}


Error Responses

All errors follow this format:

{
  "detail": "Error message describing what went wrong",
  "code": "ERROR_CODE",
  "field": "field_name"  // Optional, for validation errors
}

Common Error Codes

Code Description
UNAUTHORIZED Missing or invalid authentication
FORBIDDEN User lacks required permission
NOT_FOUND Resource does not exist
VALIDATION_ERROR Input validation failed
CONFLICT Resource already exists
RATE_LIMITED Too many requests

Rate Limits

Endpoint Limit
Default 100 requests/minute
Assessment execution 5 concurrent
Report generation 10/hour
Evidence upload 50/hour

Rate limit headers are included in all responses: - X-RateLimit-Limit - X-RateLimit-Remaining - X-RateLimit-Reset


OpenAPI Specification

The full OpenAPI 3.1 specification is available at:

GET /openapi.json

Interactive API documentation (Swagger UI) - available only when ENVIRONMENT=development, disabled in production:

GET /docs