Analytics API

REST endpoints for the Analytics module — dashboards, reports, KPIs, goals, custom metrics.

Endpoints

MethodPathPurpose
GET/api/analytics/overviewTenant-wide KPI roll-up.
GET/api/analytics/overview/comparisonPeriod-over-period deltas.
GET/api/analytics/funnelSales funnel breakdown.
GET/api/analytics/insightsLLM-generated explanations of recent metric movement.
GET/api/analytics/anomaliesDetected anomalies (z-score over rolling window).
GET/api/analytics/dashboardsList custom dashboards.
POST/api/analytics/dashboardsCreate a dashboard.
GET/PATCH/DELETE/api/analytics/dashboards/{id}CRUD.
GET/api/analytics/dashboards/{id}/widgetsList widgets in a dashboard.
POST/api/analytics/dashboards/{id}/shareGenerate a public share token.
GET/api/analytics/dashboards/public/{token}Public read-only access (token-gated).
GET/api/analytics/reportsList saved reports.
POST/api/analytics/reportsCreate a report definition (config + schedule).
GET/PATCH/DELETE/api/analytics/reports/{id}CRUD.
POST/api/analytics/reports/exportOne-shot export (csv/json/pdf) without saving.
POST/api/analytics/reports/scheduleSet or update a report's email schedule.
GET/api/analytics/goalsList KPI goals.
POST/api/analytics/goalsCreate.
GET/api/analytics/custom-metricsList custom metric definitions.
POST/api/analytics/custom-metricsCreate.
POST/api/analytics/alerts/checkRun alert evaluation (internal, used by cron).

Key entity shapes

Report

{
  "id": "uuid",
  "name": "string",
  "report_type": "performance | content | social | seo | custom",
  "config": {
    "metrics": ["string"],
    "dimensions": ["string"],
    "filters": { },
    "period": "last_7_days | last_30_days | last_90_days | …",
    "visualization": "table | bar | line | pie"
  },
  "schedule": {
    "enabled": true,
    "frequency": "daily | weekly | monthly",
    "recipients": ["email"],
    "format": "csv | json | pdf"
  }
}

Permissions

Seeded slugs: analytics.dashboard.read, analytics.reports.read|create|export. Dashboards / goals / custom-metrics endpoints gate on those overlays — there are no separate seeded analytics.goals.* or analytics.custom_metrics.* slugs. The reports/schedule endpoint requires analytics.reports.create (creating/updating the schedule is the same RBAC bucket as creating a report definition).

Events

The analytics module does not publish to the platform event bus today. Report runs, goal hits, and anomaly detections surface in the in-app activity feed but are not emitted as webhook events.

Scheduled exports

analytics-scheduled-exports cron walks analytics_reports rows with schedule.enabled=true whose last_run_at is older than the frequency window, and enqueues a generate-report worker job per due row. The worker writes the artifact to the reports storage bucket and emails the signed URL to schedule.recipients. PDF format renders printable HTML (user prints-to-PDF).

OpenAPI

Full schema at /api/openapi.json.