Skip to Content
MySagra 1.4.0 is released 🎉

Reports

Reports provide aggregated sales statistics and event data. Reports can be grouped by time window (hourly, daily) or retrieved as a full-period summary. A general closure finalizes the current event accounting.

Report Object

{ "id": "clx...", "timestamp": "2026-01-15T12:00:00Z", "intervalInMinutes": 60, "totalRevenue": "1250.50", "totalCashRevenue": "800.00", "totalCardRevenue": "450.50", "totalOrders": 42, "averageCompletitionTime": 8 }
FieldTypeDescription
idstringUnique report identifier
timestampISO8601Report time period start
intervalInMinutesintegerTime window in minutes
totalRevenuestringTotal revenue (decimal as string)
totalCashRevenuestringCash payment revenue
totalCardRevenuestringCard payment revenue
totalOrdersintegerNumber of orders in period
averageCompletitionTimeintegerAverage order completion time in minutes

Endpoints

GET /v1/reports

Retrieve reports grouped by time window. Requires: Bearer token (admin only).

GET /v1/reports?groupBy=1h Authorization: Bearer <token>

Query Parameters:

ParameterValueDescription
groupBy1h | 4h | 12h | day | allTime window grouping. Default: all

Response: 200 OK

[ { "id": "clx...", "timestamp": "2026-01-15T12:00:00Z", "intervalInMinutes": 60, "totalRevenue": "1250.50", "totalCashRevenue": "800.00", "totalCardRevenue": "450.50", "totalOrders": 42, "averageCompletitionTime": 8 }, { "id": "clx...", "timestamp": "2026-01-15T13:00:00Z", "intervalInMinutes": 60, "totalRevenue": "980.30", "totalCashRevenue": "620.00", "totalCardRevenue": "360.30", "totalOrders": 35, "averageCompletitionTime": 7 } ]

GET /v1/reports/{id}

Retrieve a specific report by ID. Requires: Bearer token (admin only).

GET /v1/reports/clx... Authorization: Bearer <token>

Response: 200 OK

{ "id": "clx...", "timestamp": "2026-01-15T12:00:00Z", "intervalInMinutes": 60, "totalRevenue": "1250.50", "totalCashRevenue": "800.00", "totalCardRevenue": "450.50", "totalOrders": 42, "averageCompletitionTime": 8 }

POST /v1/reports/general-closure

Trigger a general closure event. This finalizes the current event period and sends a general-closure SSE event to the printer channel, which triggers thermal printers to output a closure report.

Requires: Bearer token (admin only).

POST /v1/reports/general-closure Authorization: Bearer <token>

Response: 201 Created

{ "id": "clx...", "timestamp": "2026-01-15T23:59:00Z", "totalOrders": 142, "totalRevenue": "3521.50" }

The general-closure event is broadcast to the printer SSE channel and includes closure data. See Events (SSE) for details on the SSE payload.

Error Responses

StatusBodyDescription
401{ "message": "Unauthorized" }Missing or invalid Bearer token
403{ "message": "Forbidden" }Insufficient permissions (non-admin user)
404{ "message": "Report not found" }Report ID does not exist
Last updated on