> ## 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.

# Download a boleto PDF

> Downloads the PDF of a boleto of an invoice your organization issued.

Pass the boleto's statement (`statement`, the ID of a `BANK_SLIP_CREATED` statement) or omit it for the invoice's latest boleto that is not paid. The PDF comes base64-encoded, as text: decode it to get the file. The invoice must accept `BANK_SLIP`.

Any member of the organization, or an admin of the realm, can download it.


## OpenAPI

````yaml /api-reference/billing.openapi.json get /realms/{realmId}/organizations/{organizationId}/invoices/{invoiceId}/download-pdf
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/{invoiceId}/download-pdf:
    get:
      tags:
        - Invoice Statements
      summary: Download a boleto PDF
      description: Downloads the PDF of a boleto of an invoice your organization issued.
      operationId: >-
        getRealmsByRealmIdOrganizationsByOrganizationIdInvoicesByInvoiceIdDownloadPdf
      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 that issued the invoice.

            Format: `UUID`
          schema:
            type: string
            format: uuid
          example: c4bd3f21-dfbd-44e8-8055-68ba15bed410
        - name: invoiceId
          in: path
          required: true
          description: |-
            ID of the invoice.

            Format: `UUID`
          schema:
            type: string
            format: uuid
          example: 0b7c2a44-6f1e-4d3b-9a8e-5c2f1d0e9b7a
        - name: statement
          in: query
          required: false
          description: >-
            ID of the boleto's statement (`BANK_SLIP_CREATED`). Omit it for the
            invoice's latest unpaid boleto.


            Format: `UUID`
          schema:
            type: string
            format: uuid
          example: 9d4e1f6a-3b2c-4a5d-8e7f-1a2b3c4d5e6f
      responses:
        '200':
          description: The boleto's PDF, base64-encoded.
          content:
            text/plain:
              schema:
                type: string
                format: byte
                description: The boleto's PDF, base64-encoded.
        '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
        '404':
          description: >-
            `INVOICE_NOT_FOUND` — The organization issued no invoice with this
            ID.


            `INVOICE_STATEMENT_NOT_FOUND` — The invoice has no such boleto
            statement, or — without `statement` — no boleto that is not paid.
          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:
                      - INVOICE_NOT_FOUND
                      - INVOICE_STATEMENT_NOT_FOUND
                    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: INVOICE_NOT_FOUND
                origin: BILLING
                message: invoice not found
        '422':
          description: >-
            `INVOICE_INVALID_PAYMENT_METHOD` — `BANK_SLIP` is not one of the
            invoice's `allowedPaymentMethods`.


            `BAD_REQUEST` — A path parameter or `statement` is not a valid ID;
            `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:
                      - INVOICE_INVALID_PAYMENT_METHOD
                      - 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: INVOICE_INVALID_PAYMENT_METHOD
                origin: BILLING
                message: Invoice does not have a bank slip payment method

````

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