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
]
}| Field | Type | Description |
|---|---|---|
id | string (cuid) | Unique report identifier |
timestamp | ISO8601 | Report time period start |
intervalInMinutes | number | Time window in minutes |
totalRevenue | number | Total revenue |
totalCashRevenue | number | Cash payment revenue |
totalCardRevenue | number | Card payment revenue |
totalOrders | number | Number of orders in period |
averageCompletitionTime | number | null | Average order completion time in minutes |
categoryStats | array | Array of CategoryStats objects |
cashRegisterStats | array | Array 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
}
]
}| Field | Type | Description |
|---|---|---|
id | string (cuid) | Unique category stats identifier |
reportId | string (cuid) | Associated report identifier |
categoryId | string (cuid) | Unique category identifier |
categoryName | string | Name of the category |
revenue | number | Total revenue for this category |
quantity | number | Total items sold in this category |
foodStats | array | Array of specific food item statistics (FoodStats) |
FoodStats Object (Nested in CategoryStats)
| Field | Type | Description |
|---|---|---|
id | string (cuid) | Unique food stats identifier |
categoryStatsId | string (cuid) | Associated category stats identifier |
foodId | string (cuid) | Unique food item identifier |
foodName | string | Name of the food item |
revenue | number | Total revenue for this food item |
quantity | number | Total 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
}| Field | Type | Description |
|---|---|---|
id | string (cuid) | Unique cash register stats identifier |
reportId | string (cuid) | Associated report identifier |
cashRegisterId | string (cuid) | Unique cash register identifier |
cashRegisterName | string | Name of the cash register |
totalRevenue | number | Total revenue recorded by this register |
totalCardRevenue | number | Total card revenue recorded |
totalCashRevenue | number | Total 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:
| Parameter | Type | Description |
|---|---|---|
from | ISO8601 | Start date and time (required) |
to | ISO8601 | End date and time (optional) |
groupBy | string | Time 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:
| Field | Type | Description |
|---|---|---|
cashRegister | string (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
| Status | Body | Description |
|---|---|---|
| 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 |