> ## 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 tax document

> Gets a temporary link to download the PDF or the XML of a tax document.

Choose the file with `type`. The files exist only once the document is `AUTHORIZED`: before that, the request answers 404. Open the returned `url` within 1 hour, and the browser saves the file under the returned `fileName`.


## OpenAPI

````yaml /api-reference/accounting.openapi.json get /realms/{realmId}/organizations/{organizationId}/tax-document/{taxDocumentId}/download
openapi: 3.0.3
info:
  title: Accounting
  version: 1.0.0
  description: >-
    Portão 3 accounting 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). NFSe issuance: the
    organization's tax issuer (setup, certificate, logo), its tax documents
    (issue, list, download, cancel, CSV batches) and the city special-tax-regime
    lookup. Every route validates path, query, body and multipart form through a
    zod Input class (`accounting/app/use-case/*/inputs`), which documents it;
    responses are the named interfaces in
    `accounting/app/use-case/*/outputs/*Response.ts`. Confidence tiers:
    generated:typed=24 copied:manual=0 unknown=0.
servers:
  - url: https://api.accounting.v2.portao3.com.br/
    description: production
  - url: https://api.accounting.dev.3pers.com.br/
    description: development
security: []
tags:
  - name: Tax Issuers
  - name: Tax Documents (NFSe)
  - name: Tax Codes
paths:
  /realms/{realmId}/organizations/{organizationId}/tax-document/{taxDocumentId}/download:
    get:
      tags:
        - Tax Documents (NFSe)
      summary: Download a tax document
      description: Gets a temporary link to download the PDF or the XML of a tax document.
      operationId: >-
        getRealmsByRealmIdOrganizationsByOrganizationIdTaxDocumentByTaxDocumentIdDownload
      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 the organization that owns the tax document.

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

            Format: `UUID`
          schema:
            type: string
            format: uuid
          example: 3d6f9a2b-1c4e-4f8a-9b7d-5e2c1a0f8b63
        - name: type
          in: query
          required: true
          description: 'Which file to download: the `PDF` of the document or its `XML`.'
          schema:
            type: string
            enum:
              - PDF
              - XML
          example: XML
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  fileName:
                    type: string
                    description: >-
                      Name of the file: `NFSe-<number>` once the document has
                      its NFSe number, else `RPS-<series>-<number>`, else the ID
                      of the document, followed by the extension (`.pdf` or
                      `.xml`). Files of `TEST` documents are prefixed with
                      `HOMOLOGACAO-`.
                    example: NFSe-2874.xml
                  url:
                    type: string
                    description: >-
                      Temporary download link, valid for 1 hour. Opening it
                      makes the browser save the file.
                    example: >-
                      https://files.example.com/nfse/xml/3d6f9a2b-1c4e-4f8a-9b7d-5e2c1a0f8b63.xml?X-Signature=abc123
                required:
                  - fileName
                  - url
                description: A temporary link to one file of a tax document.
        '404':
          description: >-
            `TAX_DOCUMENT_NOT_FOUND` — No tax document with this ID exists in
            the organization.


            `TAX_DOCUMENT_PDF_NOT_FOUND` — The PDF is not available: it exists
            only once the document is `AUTHORIZED`.


            `TAX_DOCUMENT_XML_NOT_FOUND` — The XML is not available: it exists
            only once the document is `AUTHORIZED`.
          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:
                      - TAX_DOCUMENT_NOT_FOUND
                      - TAX_DOCUMENT_PDF_NOT_FOUND
                      - TAX_DOCUMENT_XML_NOT_FOUND
                    description: >-
                      Stable, machine-readable error code. Branch on this, never
                      on `message`.
                  origin:
                    type: string
                    enum:
                      - ACCOUNTING
                    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: TAX_DOCUMENT_NOT_FOUND
                origin: ACCOUNTING
                message: Tax document not found
        '422':
          description: >-
            `BAD_REQUEST` — A path parameter is not a valid ID, or `type` is
            missing or is not `PDF` or `XML`; `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:
                      - BAD_REQUEST
                    description: >-
                      Stable, machine-readable error code. Branch on this, never
                      on `message`.
                  origin:
                    type: string
                    enum:
                      - ACCOUNTING
                    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: BAD_REQUEST
                origin: ACCOUNTING
                message: >-
                  Bad Request: Your request is invalid or incomplete. Please
                  make sure you are requesting with the right fields.
                fields:
                  - field: type
                    message: 'Invalid option: expected one of "PDF"|"XML"'
                    code: TYPE_ONE_OF
                    values:
                      - PDF
                      - XML

````

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