> ## Documentation Index
> Fetch the complete documentation index at: https://docs.timbrix.mx/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Invoice Report Summary

> Subtotal/total are summed via SQL (unbounded). IVA is computed by parsing each matching invoice's stamped XML — capped at 2000 matching invoices per request; beyond that, `iva` is `null` and `ivaCapped` is `true`, and the caller should narrow the date range.

Returns fiscal totals (subtotal, IVA, total) and vigente/cancelado counts for invoices matching the given filters. IVA is computed by parsing each matching invoice's stamped XML — it is never derived as `total - subtotal`, since that breaks under retenciones or a non-16% rate.

## Authentication

Accepts **either**:

* A Supabase Bearer session (`Authorization: Bearer <token>`) with the `X-Organization-Id: <org-id>` header.
* An API key (`X-API-Key: sk_...`) with the `read:invoices` scope.

## Query Parameters

| Parameter     | Type                          | Description                                                                                                                                                                                                    |
| ------------- | ----------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `dateFrom`    | string (ISO date)             | Filtra por fecha de registro en Timbrix (`createdAt`), desde (inclusive). Un valor de solo fecha (`YYYY-MM-DD`) se ancla al **inicio** del día en America/Mexico\_City.                                        |
| `dateTo`      | string (ISO date)             | Filtra por fecha de registro en Timbrix (`createdAt`), hasta (inclusive). Un valor de solo fecha (`YYYY-MM-DD`) se ancla al **final** del día (23:59:59.999) en America/Mexico\_City.                          |
| `type`        | `"I"` \| `"E"` \| `"T"`       | Filtra por tipo de comprobante                                                                                                                                                                                 |
| `status`      | `"vigente"` \| `"cancelado"`  | Filtra por estatus                                                                                                                                                                                             |
| `rfcReceptor` | string                        | Filtra por RFC exacto del receptor                                                                                                                                                                             |
| `environment` | `"sandbox"` \| `"production"` | Filtra por entorno. Ignorado con API key (siempre usa el entorno de la key). Con sesión de Supabase, **por defecto es `production`** — pasa `environment=sandbox` explícitamente para incluir CFDI de sandbox. |

## Example Request

```bash cURL theme={null}
curl -X GET "https://api.timbrix.mx/invoices/report/summary?dateFrom=2026-08-01&dateTo=2026-08-31" \
  -H "Authorization: Bearer <your_token>" \
  -H "X-Organization-Id: 550e8400-e29b-41d4-a716-446655440000"
```

```typescript TypeScript SDK theme={null}
const summary = await timbrix.invoices.reportSummary(
  { dateFrom: "2026-08-01", dateTo: "2026-08-31" },
  "550e8400-e29b-41d4-a716-446655440000"
)
console.log(summary.subtotal, summary.iva, summary.total)
```

## Example Response

```json theme={null}
{
  "subtotal": 12500.5,
  "total": 14500.58,
  "iva": 2000.08,
  "ivaCapped": false,
  "retenciones": 350.5,
  "ivaIncomplete": false,
  "vigenteCount": 48,
  "canceladoCount": 2,
  "totalCount": 50
}
```

| Field            | Type             | Description                                                                                                                                     |
| ---------------- | ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| `subtotal`       | number           | Suma de subtotales de las facturas que coinciden con el filtro                                                                                  |
| `total`          | number           | Suma de totales de las facturas que coinciden con el filtro                                                                                     |
| `iva`            | number \| `null` | Suma de IVA trasladado (`Impuesto="002"` únicamente — nunca IEPS ni otro tipo) leído del XML de cada CFDI — `null` cuando `ivaCapped` es `true` |
| `ivaCapped`      | boolean          | `true` cuando el filtro coincide con demasiadas facturas para calcular IVA en una solicitud                                                     |
| `retenciones`    | number \| `null` | Suma de impuestos retenidos (ISR, IVA retenido, etc.) leído del XML de cada CFDI — `null` cuando `ivaCapped` es `true`, misma regla que `iva`   |
| `ivaIncomplete`  | boolean          | `true` cuando uno o más CFDI del rango filtrado no pudieron parsearse — `iva`/`retenciones` están subestimados para este reporte                |
| `vigenteCount`   | integer          | Facturas vigentes que coinciden con el filtro                                                                                                   |
| `canceladoCount` | integer          | Facturas canceladas que coinciden con el filtro                                                                                                 |
| `totalCount`     | integer          | `vigenteCount + canceladoCount`                                                                                                                 |


## OpenAPI

````yaml GET /invoices/report/summary
openapi: 3.1.0
info:
  title: Timbrix API
  description: >-
    REST API with OAuth2 server for managing organizations, members, and
    webhooks
  version: '1.0'
  contact: {}
servers:
  - url: https://api.timbrix.mx
    description: Production
security: []
tags:
  - name: organizations
    description: Organization management endpoints
  - name: oauth
    description: OAuth2 authentication and authorization
  - name: webhooks
    description: Webhook configuration and delivery
  - name: users
    description: User information endpoints
  - name: api-keys
    description: API Keys management and validation
paths:
  /invoices/report/summary:
    get:
      tags:
        - invoices
      summary: Get a fiscal totals summary for a filtered set of invoices
      description: >-
        Subtotal/total are summed via SQL (unbounded). IVA is computed by
        parsing each matching invoice's stamped XML — capped at 2000 matching
        invoices per request; beyond that, `iva` is `null` and `ivaCapped` is
        `true`, and the caller should narrow the date range.
      operationId: InvoicesController_reportSummary
      parameters:
        - name: dateFrom
          required: false
          in: query
          description: >-
            Filtra por fecha de registro en Timbrix (createdAt), desde
            (inclusive, ISO 8601). Un valor de solo fecha (YYYY-MM-DD) se ancla
            al inicio del día en America/Mexico_City.
          schema:
            example: '2026-08-01'
            type: string
        - name: dateTo
          required: false
          in: query
          description: >-
            Filtra por fecha de registro en Timbrix (createdAt), hasta
            (inclusive, ISO 8601). Un valor de solo fecha (YYYY-MM-DD) se ancla
            al final del día (23:59:59.999) en America/Mexico_City, incluyendo
            el día completo.
          schema:
            example: '2026-08-31'
            type: string
        - name: type
          required: false
          in: query
          description: Filtra por tipo de comprobante
          schema:
            type: string
            enum:
              - I
              - E
              - T
        - name: status
          required: false
          in: query
          description: Filtra por estatus
          schema:
            type: string
            enum:
              - vigente
              - cancelado
        - name: rfcReceptor
          required: false
          in: query
          description: Filtra por RFC exacto del receptor
          schema:
            example: XAXX010101000
            type: string
        - name: environment
          required: false
          in: query
          description: >-
            Filtra por entorno. Ignorado para peticiones autenticadas con API
            key (siempre se usa el entorno de la key). Para una sesión de
            Supabase, por defecto es 'production' — pasa este parámetro para
            incluir CFDI de sandbox.
          schema:
            type: string
            enum:
              - sandbox
              - production
        - name: X-Organization-Id
          in: header
          description: >-
            Required for Supabase session auth. Ignored when authenticating with
            an API key (the organization resolves from the key).
          required: false
          schema:
            type: string
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InvoiceReportSummaryDto'
      security:
        - apiKey: []
        - bearer: []
components:
  schemas:
    InvoiceReportSummaryDto:
      type: object
      properties:
        subtotal:
          type: number
          example: 12500.5
        total:
          type: number
          example: 14500.58
        iva:
          type: object
          example: 2000.08
          nullable: true
          description: >-
            Suma de IVA trasladado leído del XML de cada CFDI — null cuando el
            rango filtrado excede el límite calculable (ver ivaCapped)
        ivaCapped:
          type: boolean
          example: false
          description: >-
            true cuando el rango filtrado tiene demasiados CFDI para calcular
            IVA en esta solicitud — reduce el rango de fechas
        retenciones:
          type: object
          example: 350.5
          nullable: true
          description: >-
            Suma de impuestos retenidos (ISR, IVA retenido, etc.) leída del XML
            de cada CFDI — null cuando el rango filtrado excede el límite
            calculable (ver ivaCapped)
        ivaIncomplete:
          type: boolean
          example: false
          description: >-
            true cuando uno o más CFDI del rango filtrado no pudieron parsearse
            — iva/retenciones están incompletos (subestimados) para este reporte
        vigenteCount:
          type: number
          example: 48
        canceladoCount:
          type: number
          example: 2
        totalCount:
          type: number
          example: 50
      required:
        - subtotal
        - total
        - iva
        - ivaCapped
        - retenciones
        - ivaIncomplete
        - vigenteCount
        - canceladoCount
        - totalCount
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: X-API-Key
      description: 'API Key for authentication (format: sk_...)'
    bearer:
      scheme: bearer
      bearerFormat: JWT
      type: http

````