Skip to main content

Reports

MethodPathPurpose
GET/api/reportsList all reports.
POST/api/reportsCreate a report.
GET/api/reports/{id}Get a report by slug or id.
PUT/api/reports/{id}Update editable fields (not templates).
DELETE/api/reports/{id}Delete a report.

{id} accepts either the report slug or its Mongo id.

Create / update body (template assets are managed separately and ignored here):

{
"slug": "monthly-statement",
"name": "Monthly Statement",
"description": "Customer account statement",
"engine": "handlebars",
"helpersHbs": "Handlebars.registerHelper('money', n => n + ' €');",
"sampleData": { "customer": { "name": "Acme" } },
"outputOptions": {
"template": "statement.html",
"preferredOutput": "pdf",
"pdf": { "enabled": true, "printBackground": true, "format": "A4" }
},
"status": "draft"
}

Validation: slug is required and must match lowercase letters/numbers/single dashes; engine must be handlebars; status must be draft, published, or archived; outputOptions.template (if set) must reference an existing asset; pdf.format must be a supported page size.

Template assets

MethodPathPurpose
GET/api/reports/{id}/templatesList asset metadata.
POST/api/reports/{id}/templatesAdd an asset.
GET/api/reports/{id}/templates/{name}Download one asset's content.
PUT/api/reports/{id}/templates/{name}Replace an existing asset.
DELETE/api/reports/{id}/templates/{name}Delete an asset.

Two ways to upload, depending on kind:

  • HTMLapplication/json with { "name": "page.html", "content": "<…>" }.
  • Any kind (incl. DOCX/XLSX)multipart/form-data with a file field and an optional name field.

On POST, a name collision is auto-resolved to <base>-N.<ext> and the asset is returned with 201. On PUT, the name in the body must match the URL. Deleting the active template clears outputOptions.template; its history snapshots are preserved.

Metadata response shape: { "name", "kind", "size", "updatedAt" }.