Reference

Audit and Tags API

REST reference for GET /api/audit (with origin and workspace filters, CSV export) and GET /api/tags (the cross-artifact tag aggregate). Complements /docs/govern/audit-and-lineage and /docs/govern/tags.

What this page does

This is the endpoint-level REST reference for the governance surfaces documented under Govern:

  • GET /api/audit - the tenant-scoped audit log query surface, with the full query-parameter list, response envelope, and CSV export contract.
  • GET /api/tags - the cross-artifact tag aggregate that powers the Tags index page and the sidebar tag-filter dropdowns.

For the “why” and the operational context (retention, secrets redaction, origin taxonomy, observability, tags validation and normalization) see the governance pages that link back to this one: Audit and lineage and Tags.

GET /api/audit

GET /api/audit?user=&action=&kind=&origin=&workspace=&from=&to=&limit=&cursor=&format=

Auth: any of the five auth modes documented in REST API. The caller must additionally hold allow_admin_policies (a 403 with message “reading the audit log requires allow_admin_policies” is returned otherwise). Every read is scoped to the caller’s tenant from the JWT claims; there is no cross-tenant read path, even on shared-warehouse deployments.

Query parameters (all optional):

ParameterDescription
userFilter by actor email/login.
actionFilter by action string (for example chart.put, policies.update, pat.mint). Enumerated in Audit and lineage - what gets logged.
kindFilter by target_kind (chart, dashboard, query, notebook, connection, pipeline, etc.).
originuser, ai:<playbook-id> (ai:data-analyst, ai:data-engineer, ai:data-architect, ai:diagnostic), or system:<subsystem> (system:scheduler, system:retry, system:migration, system:mcp). Rows written before migration 0009_audit_log_origin.sql backfill with user.
workspace<id> restricts to a workspace the caller is a member of (403 otherwise). all opts back into the tenant-wide view (still gated by allow_admin_policies). Default is all for back-compat with the pre-filter /audit UI; a follow-up flips this to the caller’s own workspaces once the SPA ships the picker. Post-query filter is fail-closed: rows whose target does not resolve to the requested workspace are dropped rather than passed through.
from, toRFC3339 timestamps that bracket the time window. Bad timestamps surface as 400.
limitEffective range [1, 1000]; default 200.
cursorOpaque cursor from a prior response’s next_cursor. Base64url of `occurred_at + ”
formatOmit for JSON. csv returns a 13-column export.

JSON response (default):

{
  "events": [
    {
      "event_id": "1a2b3c4d-...",
      "occurred_at": "2026-08-19 10:14:00.000",
      "tenant_id": "acme",
      "user": "analyst@acme.com",
      "roles": ["editor"],
      "action": "chart.put",
      "target_kind": "chart",
      "target_id": "arr-by-country",
      "request_id": "req-abc",
      "ip": "203.0.113.42",
      "user_agent": "Mozilla/5.0 ...",
      "detail": "{\"before\":{...},\"after\":{...}}",
      "status": "ok",
      "origin": "user"
    }
  ],
  "count": 1,
  "next_cursor": "MjAyNi0wOC0xOSAxMDoxNDowMC4wMDB8MWEyYjNjNGQ..."
}

next_cursor is emitted only when the page filled (len(events) == effective_limit). A short page means the tail has been reached.

CSV response (?format=csv):

The body is a UTF-8 CSV with 13 columns whose order mirrors the SELECT projection: event_id, occurred_at, user, roles, action, target_kind, target_id, request_id, ip, user_agent, detail, status, origin. The trailing origin column shipped alongside migration 0009_audit_log_origin.sql; sweeps that predate the migration will backfill it with user. next_cursor moves to the X-Next-Cursor response header because CSV has no envelope; scripted paginators keep following the chain by re-issuing with ?cursor=<value>.

Errors:

CodeWhen
400from or to is not RFC3339; cursor is malformed base64 or has the wrong shape.
401Missing / expired token.
403Caller lacks allow_admin_policies, or ?workspace=<id> names a workspace the caller is not a member of.
503Audit service is not initialised (BI API booted without an audit sink).

Examples:

# Every mutation the AI data-analyst persona has proposed and applied
curl -s -H "Authorization: Bearer $TOKEN" \
  "https://your-goni.example.com/api/audit?origin=ai:data-analyst&limit=500"

# A compliance sweep of all connection mutations in August, exported to CSV
curl -s -H "Authorization: Bearer $TOKEN" \
  "https://your-goni.example.com/api/audit?kind=connection&from=2026-08-01T00:00:00Z&to=2026-09-01T00:00:00Z&format=csv" \
  -o audit-connection-august.csv

# Scope a sweep to a single workspace the caller is a member of
curl -s -H "Authorization: Bearer $TOKEN" \
  "https://your-goni.example.com/api/audit?workspace=finance&action=chart.put&limit=500"

# Follow pagination
curl -s -H "Authorization: Bearer $TOKEN" \
  "https://your-goni.example.com/api/audit?limit=200&cursor=$NEXT_CURSOR"

Observability: security-sensitive families also increment a Prometheus counter. Today goni_security_event_total{event="pat.mint"} fires on every PAT mint, paired with a Warn-level log line carrying the actor, jti, and TTL. See Audit and lineage - observability for the recommended alerting shape.

GET /api/tags

GET /api/tags

Auth: any authenticated caller. Anonymous callers get a 401 with the message “/api/tags requires authentication”.

Query parameters: none. Scope is derived from the caller’s session - every artifact is filtered through canAccessWorkspace(workspace_id) on the caller’s permissions before its tags are folded into the aggregate. There is no ?workspace= filter; the client cannot ask for a workspace it is not a member of.

Response:

{
  "tags": [
    { "name": "finance", "count": 7, "kinds": [{ "chart": 4, "dashboard": 2, "query": 1 }] },
    { "name": "exec",    "count": 4, "kinds": [{ "chart": 1, "dashboard": 3 }] }
  ]
}
FieldMeaning
nameCanonical (lowercased, trimmed, deduped) tag string. See Tags - validation rules.
countTotal number of artifacts (across all five kinds) that carry the tag.
kindsOne-element array wrapping a map from artifact kind to occurrence count. Kinds with zero occurrences are omitted from the map rather than reported as 0. The single-element outer array is a forward-compatible shape: future per-workspace breakouts can add elements without a breaking rename.

Kind keys are chart, dashboard, notebook, query, and glossary.

Ordering: deterministic - highest count first, tie-broken by name ascending. Snapshot / integration tests can pin the response order without a sort helper, and the SPA’s default rendering matches what a user expects when reading top-to-bottom.

Errors:

CodeWhen
401Anonymous caller.
503Artifact store is not initialised (BI API booted without a store backend).

Example:

curl -s -H "Authorization: Bearer $TOKEN" https://your-goni.example.com/api/tags
  • Audit and lineage - the “why” and operational context for /api/audit, including the emitted action-family enumeration, retention, and observability.
  • Tags - validation rules, normalization, tag surfaces, and the ?tag=<name> URL filter every artifact list page recognises.
  • REST API - the full endpoint catalog, auth modes, error envelope, and rate-limit classes.
  • Environment variables - knobs that shape the BI API’s runtime, including Prometheus scrape targets.

Last updated