Skip to main content
GET
/
api
/
v1
/
ventas
/
summary
Sales Summary
curl --request GET \
  --url https://api.example.com/api/v1/ventas/summary
{
  "totalSales": 123,
  "totalPayouts": 123,
  "totalTickets": 123,
  "totalWinners": 123,
  "netRevenue": 123,
  "winRate": 123,
  "avgTicketValue": 123
}

Overview

Returns executive summary with key performance indicators for sales in the specified date range. Applies RBAC filtering by user role.

Authentication

Requires JWT authentication:
  • VENDEDOR: Can only see own sales (scope=mine forced)
  • VENTANA: Can see window or seller data
  • ADMIN: Can see all data or filter by banca

Query Parameters

date
enum
default:"today"
Date range: today, yesterday, week, month, year, range
fromDate
string
Start date YYYY-MM-DD (required if date=range)
toDate
string
End date YYYY-MM-DD (required if date=range)
ventanaId
string
Filter by ventana (admin only)
vendedorId
string
Filter by seller
loteriaId
string
Filter by lottery
scope
enum
Data scope: all, mine

Response

totalSales
number
Total sales amount
totalPayouts
number
Total payouts
totalTickets
number
Number of tickets sold
totalWinners
number
Number of winning tickets
netRevenue
number
Net revenue (sales - payouts)
winRate
number
Win rate percentage
avgTicketValue
number
Average ticket value

Example Request

GET /api/v1/ventas/summary?date=today&scope=all

Example Response

{
  "success": true,
  "data": {
    "totalSales": 1500000,
    "totalPayouts": 800000,
    "totalTickets": 1234,
    "totalWinners": 89,
    "netRevenue": 700000,
    "winRate": 7.21,
    "avgTicketValue": 1215.80
  },
  "meta": {
    "range": {
      "fromAt": "2024-03-15T06:00:00.000Z",
      "toAt": "2024-03-16T05:59:59.999Z",
      "tz": "America/Costa_Rica"
    },
    "effectiveFilters": {
      "ventanaId": null,
      "vendedorId": null
    }
  }
}

Build docs developers (and LLMs) love