GET /api/invoices/metrics
Retrieves aggregated metrics and statistics for invoices and expenses, including totals, tax amounts, and payment status summaries. Supports filtering by profile and time period.Authentication
Requires Bearer token authentication. The token must be included in theAuthorization header.
Query Parameters
Filter metrics by profile UUID. If not provided, returns metrics across all user’s profiles.
Filter by month (1-12). Must be provided together with
año for period-specific metrics.Filter by year. Valid range: 2001-2099. Must be provided together with
mes for period-specific metrics.Response
UUID of the fiscal period (only returned when profileId, mes, and año are provided). Used for creating manual income entries.
Aggregated metrics data
Gross profit (ingresos.total - gastos.total)
Net IVA position (ingresos.iva - gastos.ivaDeducible)
Error Codes
Bad Request - Invalid parameters
- Month must be between 1 and 12
- Year must be between 2001 and 2099
Unauthorized - User not authenticated
Internal Server Error - Error calculating metrics
Example Request (All-Time Metrics)
Example Request (Period-Specific Metrics)
Example Response (Period-Specific)
Example Response (All-Time, All Profiles)
Example Response (Invalid Month)
Example Response (Invalid Year)
Notes
- When no filters are provided, returns aggregated metrics across all profiles and time periods for the authenticated user
- The
period_idis only returned when all three parameters (profileId, mes, año) are provided, and is used by the frontend to enable manual income entry utilidadBruta(gross profit) = total income - total expensesivaFavorContra(IVA position) = IVA charged on income - deductible IVA on expenses- Positive value indicates IVA payable to tax authority
- Negative value indicates IVA refund due from tax authority
- Fiscal regime breakdown (
regimenFiscal) is only provided when filtering by a specific profile - Metrics include both PUE (paid in full) and PPD (installment) invoices
- Payment complements are tracked separately in
cobros(collections) andpagos(disbursements)