/api/v1/reports/*, require tenant
authentication, and scope every read/write to the caller’s tenant.
Authentication
Same headers as every other v1 route:X-API-Key: krn_…plusX-Tenant-Id: <uuid>, or- a session cookie bound to a tenant-linked user account.
- Viewer, editor, admin: all
GETroutes + preview. - Editor, admin: create/update/delete templates, schedules; run-now.
- Admin: only admin-specific routes (none here).
Templates
GET /api/v1/reports/templates
List tenant-scoped templates, newest first.
POST /api/v1/reports/templates
Create a template.
Body:
GET /api/v1/reports/templates/:id
Returns 404 when not found or cross-tenant.
PATCH /api/v1/reports/templates/:id
Partial update. Any of the fields from POST may be supplied.
DELETE /api/v1/reports/templates/:id
Returns 204. Cascade-deletes dependent ReportSchedule rows.
POST /api/v1/reports/templates/:id/preview
Run the template once without dispatching or persisting. Returns the
sections, narrative, and base64 artifacts inline.
POST /api/v1/reports/templates/:id/run-now
Execute immediately with dispatch: true, persistRun: true. Returns
202 with the runId, artifact metadata, and per-destination
delivery results. Synchronous for Phase 03 — long-running reports block
the HTTP response.
Schedules
GET /api/v1/reports/schedules
List all schedules for the tenant.
POST /api/v1/reports/schedules
cron-parser and computes the initial
nextRunAt. Returns 404 when templateId is unknown or belongs to
a different tenant. Returns 422 on invalid cron.
GET /api/v1/reports/schedules/:id
PATCH /api/v1/reports/schedules/:id
Recomputes nextRunAt when cronExpression or timezone changes.
DELETE /api/v1/reports/schedules/:id
Runs
GET /api/v1/reports/runs
Paginated run history.
Query params:
templateId— filter by templatelimit— 1..200, default 50offset— default 0
artifactPayloads (base64) to keep the list JSON small.
GET /api/v1/reports/runs/:id
Full run record including sectionsData and narrativeOutput.
Artifact list is returned as metadata only (no base64) — use the
dedicated download endpoint to stream binaries.
GET /api/v1/reports/runs/:id/artifacts/:format
Download the rendered artifact binary for the given format. Returns
the file with the correct Content-Type and a
Content-Disposition: attachment; filename="…" header. 404 when the
format was not rendered for the run.
Supported :format values correspond to registered ReportFormats:
pdf, csv, markdown, html.