Skip to main content
GET
/
api
/
v1
/
admin
/
dashboard
Dashboard Overview
curl --request GET \
  --url https://api.example.com/api/v1/admin/dashboard
{
  "kpis": {
    "totalSales": 123,
    "totalPayouts": 123,
    "totalTickets": 123,
    "totalWinningTickets": 123,
    "netProfit": 123,
    "margin": 123
  },
  "alerts": [
    {
      "type": "<string>",
      "severity": "<string>",
      "message": "<string>",
      "value": 123
    }
  ],
  "byVentana": [
    {}
  ],
  "byLoteria": [
    {}
  ],
  "byVendedor": [
    {}
  ]
}

Overview

Returns the main dashboard with all metrics including sales, payouts, exposure, alerts, and dimensional breakdowns. Supports RBAC filtering by banca/ventana.

Authentication

Requires JWT authentication. VENDEDOR role is not authorized.
  • ADMIN: Can view all data or filter by banca (via active banca context)
  • VENTANA: Can only view their own window data

Query Parameters

date
enum
default:"today"
Date range preset: today, yesterday, week, month, year, range
fromDate
string
Start date in YYYY-MM-DD format (required if date=range)
toDate
string
End date in YYYY-MM-DD format (required if date=range)
ventanaId
string
Filter by specific ventana (admin only)
loteriaId
string
Filter by specific lottery
betType
string
Filter by bet type
scope
enum
default:"all"
Data scope: all, mine
dimension
enum
Breakdown dimension: ventana, loteria, vendedor
interval
enum
Time series interval: hour, day, week

Response

kpis
object
Key performance indicators
alerts
array
Risk alerts and notifications
byVentana
array
Breakdown by ventana (if dimension=ventana)
byLoteria
array
Breakdown by lottery (if dimension=loteria)
byVendedor
array
Breakdown by seller (if dimension=vendedor)

RBAC Filtering

  • VENTANA users: Automatically filtered to their window (ventanaId forced)
  • ADMIN with active banca: Automatically filtered to active banca context
  • ADMIN without banca: Can see all data or filter manually

Example Request

GET /api/v1/admin/dashboard?date=today&dimension=ventana&scope=all

Example Response

{
  "success": true,
  "data": {
    "kpis": {
      "totalSales": 1500000,
      "totalPayouts": 800000,
      "totalTickets": 1234,
      "totalWinningTickets": 89,
      "netProfit": 700000,
      "margin": 46.67
    },
    "alerts": [
      {
        "type": "HIGH_EXPOSURE",
        "severity": "warning",
        "message": "Exposición alta en número 25",
        "value": 150000
      }
    ],
    "byVentana": [
      {
        "ventanaId": "abc-123",
        "ventanaName": "Ventana Centro",
        "sales": 500000,
        "payouts": 250000,
        "tickets": 400,
        "netProfit": 250000,
        "margin": 50.0
      }
    ]
  },
  "meta": {
    "range": {
      "fromAt": "2024-03-15T06:00:00.000Z",
      "toAt": "2024-03-16T05:59:59.999Z"
    },
    "generatedAt": "2024-03-15T12:00:00.000Z"
  }
}

Date Range Resolution

All date parameters use Costa Rica timezone (UTC-6). Dates are converted from CR local time to UTC for database queries.
  • today: Current CR day (06:00 UTC to 05:59:59 UTC next day)
  • week: Current CR week (Monday to Sunday)
  • month: Current CR month
  • range: Custom range using fromDate and toDate

Build docs developers (and LLMs) love