> ## Documentation Index
> Fetch the complete documentation index at: https://developers.portao3.com.br/llms.txt
> Use this file to discover all available pages before exploring further.

# Export invoices

> Exports the invoices your organization issued as a CSV or XLSX file.

The file has every invoice that matches the same filters and order as the invoice list — plus `contractId` and `dealId`, to export one contract's or one deal's invoices — one per row, with six columns whose headers are in Portuguese: `Descrição` (the description, or the deal's), `Cliente` (the payer's name), `Quantidade` (the installment, as `1/12`, or `Única`), `Data de Vencimento` (the due date, as `DD/MM/YYYY`, UTC), `Status` (the `displayStatus`, in Portuguese) and `Valor` (the invoice amount, in centavos). When no invoice matches, the file has the header and one empty row.

`?type=csv` answers a UTF-8 CSV file; `?type=xlsx` an Excel workbook, base64-encoded. An export is limited to 50,000 invoices and 4 MiB: narrow the filters to export more. Any member of the organization, or an admin of the realm, can export them.


## OpenAPI

````yaml /api-reference/billing.openapi.json get /realms/{realmId}/organizations/{organizationId}/invoices/export
openapi: 3.0.3
info:
  title: Billing
  version: 1.0.0
  description: >-
    Portão 3 billing API. Every endpoint requires a bearer token in the
    Authorization header (Authorization: Bearer <token>) unless its page states
    otherwise; see the Authentication guide. That requirement is not repeated
    per endpoint. Generated by tools/openapi from code (routes + security) and
    the hand-written spec (request/response bodies). Full billing surface —
    contracts, deals, invoices, statements, payment links, checkout and NFSe
    orchestration. (The product/supplier catalog moved to registry.) Confidence
    tiers: generated:typed=74 copied:manual=0 unknown=5.
servers:
  - url: https://api.billing.v2.portao3.com.br/
    description: production
  - url: https://api.billing.dev.3pers.com.br/
    description: development
security: []
tags:
  - name: Contracts
  - name: Deals
  - name: Invoices
  - name: Invoice Entries
  - name: Invoice Statements
  - name: NFSe Configuration
  - name: Payment Links
paths:
  /realms/{realmId}/organizations/{organizationId}/invoices/export:
    get:
      tags:
        - Invoices
      summary: Export invoices
      description: Exports the invoices your organization issued as a CSV or XLSX file.
      operationId: getRealmsByRealmIdOrganizationsByOrganizationIdInvoicesExport
      parameters:
        - name: realmId
          in: path
          required: true
          description: |-
            ID of your realm.

            Format: `UUID`
          schema:
            type: string
            format: uuid
          example: f495ff0c-ab54-4f99-8e92-ca8682e4de9b
        - name: organizationId
          in: path
          required: true
          description: |-
            ID of your organization: the one whose invoices you export.

            Format: `UUID`
          schema:
            type: string
            format: uuid
          example: c4bd3f21-dfbd-44e8-8055-68ba15bed410
        - name: type
          in: query
          required: true
          description: Format of the exported file.
          schema:
            type: string
            enum:
              - csv
              - xlsx
          example: csv
        - name: encoding
          in: query
          required: false
          description: >-
            How an `xlsx` file is encoded in the response body: always `base64`,
            the default. A `csv` file is always sent as plain text.
          schema:
            default: base64
            type: string
            enum:
              - base64
          example: base64
        - name: status
          in: query
          required: false
          description: >-
            Only invoices in these stored statuses (`OPEN`, `CLOSED`, `PAID`,
            `CANCELED`). Repeat the parameter or separate values with commas.


            ---


            Example (comma-separated list): `?status=CLOSED,PAID`
          schema:
            type: array
            items:
              type: string
              enum:
                - OPEN
                - CLOSED
                - PAID
                - CANCELED
          style: form
          explode: false
        - name: debitPartyDocuments
          in: query
          required: false
          description: >-
            Only invoices whose payer (the debit party) has one of these
            CPF/CNPJ documents, digits only (exact match).


            ---


            Example (comma-separated list):
            `?debitPartyDocuments=11144477735,39053344705`
          schema:
            type: array
            items:
              type: string
              maxLength: 32
          style: form
          explode: false
        - name: debitPartyOrgIds
          in: query
          required: false
          description: >-
            Only invoices whose payer (the debit party) pays from a Portão 3
            wallet of one of these organizations. It matches the organization of
            the payer's wallet, so a payer with no wallet (a customer who pays
            by boleto or PIX, for example) is not found by it: filter by
            `debitPartyDocuments` instead.


            Format: `UUID`


            ---


            Example: `?debitPartyOrgIds=5e0a1c2b-3d4f-4a6b-8c9d-0e1f2a3b4c5d`
          schema:
            type: array
            items:
              type: string
              format: uuid
          style: form
          explode: false
        - name: chargeType
          in: query
          required: false
          description: >-
            Only invoices whose deal has one of these charge types (`SINGLE`,
            `RECURRENT`, `SUBSCRIPTION`).


            ---


            Example: `?chargeType=SINGLE`
          schema:
            type: array
            items:
              type: string
              enum:
                - SINGLE
                - RECURRENT
                - SUBSCRIPTION
          style: form
          explode: false
        - name: contractId
          in: query
          required: false
          description: |-
            Only invoices of this contract.

            Format: `UUID`
          schema:
            type: string
            format: uuid
          example: 7e4c2a1b-6d5f-4b3a-9e8d-2f1c0b9a8e7d
        - name: dealId
          in: query
          required: false
          description: |-
            Only invoices of this deal.

            Format: `UUID`
          schema:
            type: string
            format: uuid
          example: 3b9f6d2e-1a4c-4e8b-9f7a-6c5d4e3b2a1f
        - name: description
          in: query
          required: false
          description: Only invoices whose name contains this text (case-insensitive).
          schema:
            type: string
            maxLength: 250
          example: Mensalidade
        - name: startDueAt
          in: query
          required: false
          description: >-
            Only invoices due on or after this moment, inclusive (ISO 8601 date
            or date-time).
          schema:
            anyOf:
              - type: string
                format: date
              - type: string
                format: date-time
          example: '2026-01-01T00:00:00.000Z'
        - name: endDueAt
          in: query
          required: false
          description: >-
            Only invoices due on or before this moment, inclusive (ISO 8601 date
            or date-time).
          schema:
            anyOf:
              - type: string
                format: date
              - type: string
                format: date-time
          example: '2026-01-31T23:59:59.999Z'
        - name: order
          in: query
          required: false
          description: Sort direction. Case-insensitive.
          schema:
            default: DESC
            type: string
            enum:
              - ASC
              - DESC
          example: DESC
        - name: orderBy
          in: query
          required: false
          description: Field to sort the invoices by.
          schema:
            default: createdAt
            type: string
            enum:
              - createdAt
              - dueAt
              - closingAt
              - description
              - status
              - amount
              - invoiceNumber
          example: createdAt
      responses:
        '200':
          description: >-
            `application/csv` — The invoices as a UTF-8 CSV file, when `type` is
            `csv`.


            `application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`
            — The Excel workbook, base64-encoded, when `type` is `xlsx`.
          content:
            application/csv:
              schema:
                type: string
                description: The invoices as a UTF-8 CSV file, when `type` is `csv`.
            application/vnd.openxmlformats-officedocument.spreadsheetml.sheet:
              schema:
                type: string
                format: byte
                description: The Excel workbook, base64-encoded, when `type` is `xlsx`.
        '403':
          description: >-
            `INSUFFICIENT_PERMISSIONS` — You are not a member of the
            organization nor an admin of the realm.
          content:
            application/json:
              schema:
                type: object
                properties:
                  traceId:
                    type: string
                    description: >-
                      Identifier of the request that failed. Quote it when
                      contacting support.
                    example: 1-68ee2a1b-3c4d5e6f7a8b9c0d1e2f3a4b
                  code:
                    type: string
                    enum:
                      - INSUFFICIENT_PERMISSIONS
                    description: >-
                      Stable, machine-readable error code. Branch on this, never
                      on `message`.
                  origin:
                    type: string
                    enum:
                      - BILLING
                    description: Service that produced the error.
                  message:
                    type: string
                    description: >-
                      Human-readable explanation. Its wording may change without
                      notice.
                required:
                  - traceId
                  - code
                  - origin
                  - message
              example:
                traceId: 1-68ee2a1b-3c4d5e6f7a8b9c0d1e2f3a4b
                code: INSUFFICIENT_PERMISSIONS
                origin: BILLING
                message: insufficient permissions
        '422':
          description: >-
            `EXPORT_TOO_LARGE` — More than 50,000 invoices match, or the file
            would exceed 4 MiB.


            `BAD_REQUEST` — A path or query parameter is invalid, such as a
            missing `type` or a removed parameter; `fields` lists each one.
          content:
            application/json:
              schema:
                type: object
                properties:
                  traceId:
                    type: string
                    description: >-
                      Identifier of the request that failed. Quote it when
                      contacting support.
                    example: 1-68ee2a1b-3c4d5e6f7a8b9c0d1e2f3a4b
                  code:
                    type: string
                    enum:
                      - EXPORT_TOO_LARGE
                      - BAD_REQUEST
                    description: >-
                      Stable, machine-readable error code. Branch on this, never
                      on `message`.
                  origin:
                    type: string
                    enum:
                      - BILLING
                    description: Service that produced the error.
                  message:
                    type: string
                    description: >-
                      Human-readable explanation. Its wording may change without
                      notice.
                  fields:
                    type: array
                    description: >-
                      One entry per invalid request field (validation errors
                      only).
                    items:
                      type: object
                      properties:
                        field:
                          type: string
                          description: >-
                            Path of the invalid field, e.g. `label` or
                            `values[0].value`.
                          example: label
                        message:
                          type: string
                          description: Why the field was rejected.
                          example: label is required
                        code:
                          type: string
                          description: >-
                            `<FIELD>_<REASON>` — e.g. `LABEL_REQUIRED`,
                            `TYPE_ONE_OF`, `VALUES_VALUE_TYPE_ERROR`.
                          example: LABEL_REQUIRED
                        values:
                          type: array
                          items:
                            type: string
                          description: >-
                            The accepted values, when the field is an
                            enumeration.
                      required:
                        - field
                        - message
                        - code
                required:
                  - traceId
                  - code
                  - origin
                  - message
              example:
                traceId: 1-68ee2a1b-3c4d5e6f7a8b9c0d1e2f3a4b
                code: EXPORT_TOO_LARGE
                origin: BILLING
                message: >-
                  This export is too large to generate in a single request.
                  Narrow the filters (for example a shorter date range) and try
                  again.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.