Chronicle

Admin API

HTTP admin API — 21 endpoints for events, verification, erasure, retention, reports, and stats.

The handler package exposes 21 REST endpoints using the Forge router with full OpenAPI metadata. Routes are mounted under /v1/ and require an AppID in the request context.

Setup

import (
    "net/http"
    "log/slog"

    "github.com/xraph/chronicle/handler"
)

mux := http.NewServeMux()

api := handler.New(handler.Dependencies{
    AuditStore:     myStore,
    VerifyStore:    myStore,
    ErasureStore:   myStore,
    RetentionStore: myStore,
    ReportStore:    myStore,
    Compliance:     complianceEngine,
    Retention:      retentionEnforcer,
    Logger:         slog.Default(),
}, mux)

api.RegisterRoutes(mux)

http.ListenAndServe(":8080", mux)

Authentication

Every request must have an AppID in the context (populated by your auth middleware). Requests without an AppID return 401 Unauthorized. TenantID is also enforced on all queries to prevent cross-tenant access.

Error format

{"error": "chronicle: event not found"}

Events

MethodPathDescription
GET/v1/eventsList events with filters (category, action, severity, outcome, time range)
GET/v1/events/:idGet a single event by ID
GET/v1/events/user/:userIdGet events for a specific user
POST/v1/events/aggregateGrouped counts for analytics

List events query parameters

ParameterDescription
categoryFilter by event category
actionFilter by action verb
severityinfo, warning, or critical
outcomesuccess, failure, or denied
fromStart time (RFC3339)
toEnd time (RFC3339)
limitPage size (default 20)
offsetPage offset
orderasc or desc

Verification

MethodPathDescription
POST/v1/verifyVerify hash chain integrity

Request body:

{
  "stream_id": "stream_01j9vk...",
  "from_seq": 0,
  "to_seq": 0
}

Response: verify.Reportvalid, verified, gaps, tampered.

Erasure

MethodPathDescription
POST/v1/erasuresRequest GDPR erasure for a subject
GET/v1/erasuresList erasure records
GET/v1/erasures/:idGet a specific erasure record

Retention

MethodPathDescription
GET/v1/retentionList retention policies
POST/v1/retentionCreate or update a retention policy
DELETE/v1/retention/:idDelete a policy
POST/v1/retention/enforceTrigger immediate retention enforcement
GET/v1/retention/archivesList archive records

Reports

MethodPathDescription
GET/v1/reportsList compliance reports
POST/v1/reports/soc2Generate SOC2 Type II report
POST/v1/reports/hipaaGenerate HIPAA report
POST/v1/reports/euaiactGenerate EU AI Act report
POST/v1/reports/customGenerate custom report
GET/v1/reports/:idGet a specific report
GET/v1/reports/:id/export/:formatExport report (json, csv, markdown, html)

Stats

MethodPathDescription
GET/v1/statsAggregate statistics for audit events

Forge extension

When using the Forge extension, routes are registered automatically during Register unless WithDisableRoutes(true) is set:

ext := extension.New(
    extension.WithStore(s),
    // WithDisableRoutes defaults to false — routes are auto-registered
)
app.Register(ext)

Access the underlying handler.API for manual control:

ext.API().RegisterRoutes(customRouter)

Or get an http.Handler for standalone use:

h := ext.Handler()
http.ListenAndServe(":8080", h)

On this page