Reports
| Method | Path | Purpose |
|---|---|---|
GET | /api/reports | List all reports. |
POST | /api/reports | Create 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
| Method | Path | Purpose |
|---|---|---|
GET | /api/reports/{id}/templates | List asset metadata. |
POST | /api/reports/{id}/templates | Add 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:
- HTML —
application/jsonwith{ "name": "page.html", "content": "<…>" }. - Any kind (incl. DOCX/XLSX) —
multipart/form-datawith afilefield and an optionalnamefield.
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" }.