Skip to Content
MySagra 1.5.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.

Data Aggregation Note: We use BullMQ  to process and save a snapshot of the report data into the database every hour. When you request reports via the API, the system retrieves these hourly snapshots and combines them with dynamically generated “live” data covering the time from the last snapshot up to the exact moment of your API call. This ensures reporting is both highly performant and perfectly up-to-date.

Objects

Report Object

The primary object representing a summary of sales during a specific time interval. It includes overall totals, as well as detailed statistics broken down by food categories and individual cash registers.

{ "id": "clx...", "timestamp": "2026-01-15T12:00:00Z", "intervalInMinutes": 60, "totalRevenue": 1250.50, "totalCashRevenue": 800.00, "totalCardRevenue": 450.50, "totalOrders": 42, "averageCompletitionTime": 8, "categoryStats": [ // ... CategoryStats Objects ], "cashRegisterStats": [ // ... CashRegisterStats Objects ] }
FieldTypeDescription
idstring (cuid)Unique report identifier
timestampISO8601Report time period start
intervalInMinutesnumberTime window in minutes
totalRevenuenumberTotal revenue
totalCashRevenuenumberCash payment revenue
totalCardRevenuenumberCard payment revenue
totalOrdersnumberNumber of orders in period
averageCompletitionTimenumber | nullAverage order completion time in minutes
categoryStatsarrayArray of CategoryStats objects
cashRegisterStatsarrayArray of CashRegisterStats objects

CategoryStats Object

Represents the statistics grouped by food category within a report. It also contains an array of FoodStats for detailed item-level statistics within that category.

{ "id": "clx...", "reportId": "clx...", "categoryId": "clx...", "categoryName": "Primi Piatti", "revenue": 500.50, "quantity": 25, "foodStats": [ { "id": "clx...", "categoryStatsId": "clx...", "foodId": "clx...", "foodName": "Spaghetti alla Carbonara", "revenue": 250.25, "quantity": 15 } ] }
FieldTypeDescription
idstring (cuid)Unique category stats identifier
reportIdstring (cuid)Associated report identifier
categoryIdstring (cuid)Unique category identifier
categoryNamestringName of the category
revenuenumberTotal revenue for this category
quantitynumberTotal items sold in this category
foodStatsarrayArray of specific food item statistics (FoodStats)

FoodStats Object (Nested in CategoryStats)

FieldTypeDescription
idstring (cuid)Unique food stats identifier
categoryStatsIdstring (cuid)Associated category stats identifier
foodIdstring (cuid)Unique food item identifier
foodNamestringName of the food item
revenuenumberTotal revenue for this food item
quantitynumberTotal quantity sold

CashRegisterStats Object

Represents the statistics generated by a specific cash register during the report period.

{ "id": "clx...", "reportId": "clx...", "cashRegisterId": "clx...", "cashRegisterName": "Cassa Principale", "totalRevenue": 1250.50, "totalCardRevenue": 450.50, "totalCashRevenue": 800.00 }
FieldTypeDescription
idstring (cuid)Unique cash register stats identifier
reportIdstring (cuid)Associated report identifier
cashRegisterIdstring (cuid)Unique cash register identifier
cashRegisterNamestringName of the cash register
totalRevenuenumberTotal revenue recorded by this register
totalCardRevenuenumberTotal card revenue recorded
totalCashRevenuenumberTotal cash revenue recorded

Endpoints

GET /v1/reports

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

GET /v1/reports?from=2026-01-01T00:00:00Z&to=2026-01-31T23:59:59Z&groupBy=day Authorization: Bearer <token>

Query Parameters:

ParameterTypeDescription
fromISO8601Start date and time (required)
toISO8601End date and time (optional)
groupBystringTime window grouping: 1h, 4h, 12h, day, all (required)

Response: 200 OK

Returns an array of Report Object.

[ { "id": "clx...", "timestamp": "2026-01-15T00:00:00Z", "intervalInMinutes": 1440, "totalRevenue": 1250.50, "totalCashRevenue": 800.00, "totalCardRevenue": 450.50, "totalOrders": 42, "averageCompletitionTime": 8, "categoryStats": [ ... ], "cashRegisterStats": [ ... ] } ]

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

Returns a single Report Object.

POST /v1/reports/general-closure

Trigger a general closure event for a specific cash register. This finalizes the current event period for the register.

Requires: Bearer token (admin only).

Request Body:

FieldTypeDescription
cashRegisterstring (cuid)Cash register CUID that requests the general closure (required)
POST /v1/reports/general-closure Authorization: Bearer <token> Content-Type: application/json { "cashRegister": "clx..." }

Response: 201 Created

Returns the generated Report Object for the closure.

{ "id": "clx...", "timestamp": "2026-01-15T23:59:00Z", "intervalInMinutes": 1440, "totalRevenue": 3521.50, "totalCashRevenue": 2000.00, "totalCardRevenue": 1521.50, "totalOrders": 142, "averageCompletitionTime": null, "categoryStats": [ ... ], "cashRegisterStats": [ ... ] }

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
400{ "message": "Bad Request" }Invalid query parameters or body (e.g. missing from, invalid groupBy)
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