Chronicle
1.x
Docs/Chronicle/Admin API
Open

Reading2 min
Updated31 Jul 2026
Sourcev1/subsystems/admin-api.mdx

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.

Setup01

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)

Authentication02

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 format03

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

Events04

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

Verification05

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.

Erasure06

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

Retention07

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

Reports08

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)

Stats09

MethodPathDescription
GET/v1/statsAggregate statistics for audit events

Forge extension10

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)