Dashboard
Dashboard API
Single endpoint that returns all analytics data for the dashboard view, including KPIs with trend comparison, chart data, and activity breakdowns.
Get Dashboard Data
GET /api/dashboard
Permission: dashboard:view
Returns comprehensive analytics for the current tenant within a given time period. Includes comparison with the previous equivalent period for trend calculation.
Query Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| period | string | No | day, week, or month (default: month) |
| from | string | No | Custom start date (ISO 8601). Overrides period. |
| to | string | No | Custom end date (ISO 8601). Defaults to now. |
Response 200 OK:
{
"data": {
"kpis": {
"generated": { "value": 25, "trend": 12 },
"won": { "value": 8, "rate": 32, "trend": -5 },
"lost": { "value": 3, "rate": 12, "trend": 0 },
"clients": { "value": 145, "newInPeriod": 7, "trend": 40 }
},
"amounts": {
"quoted": 485000,
"won": 195000,
"prevQuoted": 420000
},
"chartData": [
{ "date": "2026-03-01", "generated": 3, "won": 1, "amount": 45000 },
{ "date": "2026-03-02", "generated": 1, "won": 0, "amount": 12000 }
],
"statusDistribution": [
{ "name": "Generadas", "value": 10, "color": "#6366f1" },
{ "name": "Enviadas", "value": 8, "color": "#3b82f6" },
{ "name": "Ganadas", "value": 5, "color": "#10b981" },
{ "name": "Perdidas", "value": 2, "color": "#ef4444" }
],
"recentQuotes": [
{
"id": "clxyz...",
"quoteNumber": 42,
"status": "SENT",
"total": 17900,
"createdAt": "2026-03-31T10:00:00.000Z",
"clientName": "María López",
"companyName": "Distribuidora del Norte S.A."
}
],
"topClients": [
{ "name": "María López", "company": "Distribuidora del Norte S.A.", "count": 5, "total": 89500 }
],
"collaboratorActivity": [
{
"userId": "clxyz...",
"name": "Carlos Méndez",
"generated": 12,
"won": 4,
"lost": 1,
"amount": 245000
}
],
"period": {
"from": "2026-03-01T00:00:00.000Z",
"to": "2026-03-31T18:30:00.000Z",
"label": "month"
}
}
}Response Fields:
| Field | Description |
|---|---|
kpis.generated |
Total quotes created in period with trend % vs previous period |
kpis.won |
Won quotes with conversion rate and trend |
kpis.lost |
Lost quotes with loss rate and trend |
kpis.clients |
Total clients (all-time), new in period, trend of new |
amounts |
Total quoted amount, won amount, and previous period quoted amount |
chartData |
Daily breakdown of quotes for time-series charts |
statusDistribution |
Status counts with colors for donut/pie charts (excludes zero-count statuses) |
recentQuotes |
Last 7 quotes in the period |
topClients |
Top 5 clients by quoted amount in the period |
collaboratorActivity |
Per-user breakdown (Owner/Admin only; empty array for Collaborators) |
Errors:
| Status | Error | When |
|---|---|---|
| 401 | "No autorizado" | Missing or invalid session |
| 403 | "Sin permisos" | Role lacks dashboard:view |
cURL Example:
curl -X GET "https://cotizera.com/api/dashboard?period=month" \
-H "Cookie: next-auth.session-token=YOUR_TOKEN"