> ## 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 an attachment

> Returns a short-lived URL to download the attachment's file.

Any member of the organization can download it. The `url` works for 10 minutes: fetch it with a plain `GET`, without an `Authorization` header, and ask for a new one whenever you need the file — don't store it. It always serves the file exactly as it was uploaded.

Only an `AVAILABLE` attachment can be downloaded. Right after the upload, while it is still `PENDING_UPLOAD`, this answers `409 ATTACHMENT_NOT_AVAILABLE` — retry shortly. A `DELETED` attachment answers the same `409`, for good.


## OpenAPI

````yaml /api-reference/attachment.openapi.json get /realms/{realmId}/organizations/{organizationId}/attachments/{attachmentId}/download
openapi: 3.0.3
info:
  title: Attachment
  version: 1.0.0
  description: >-
    Portão 3 attachment 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). Shared file store: upload a
    file once, keep its ID, and read back its preview, an automatic summary and,
    for a nota fiscal or invoice, its fiscal data. Confidence tiers:
    generated:typed=9 copied:manual=0 unknown=0.
servers:
  - url: https://api.attachment.v2.portao3.com.br/
    description: production
  - url: https://api.attachment.dev.3pers.com.br/
    description: development
security: []
tags:
  - name: Attachments
paths:
  /realms/{realmId}/organizations/{organizationId}/attachments/{attachmentId}/download:
    get:
      tags:
        - Attachments
      summary: Download an attachment
      description: Returns a short-lived URL to download the attachment's file.
      operationId: >-
        getRealmsByRealmIdOrganizationsByOrganizationIdAttachmentsByAttachmentIdDownload
      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 the attachment belongs to.

            Format: `UUID`
          schema:
            type: string
            format: uuid
          example: c4bd3f21-dfbd-44e8-8055-68ba15bed410
        - name: attachmentId
          in: path
          required: true
          description: |-
            ID of the attachment, as returned when it was created.

            Format: `UUID`
          schema:
            type: string
            format: uuid
          example: 3f6c2a1e-8b4d-4f7a-9c2e-5d1b7a9e4c60
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  url:
                    type: string
                    description: >-
                      Pre-signed URL that serves the file for 10 minutes. Fetch
                      it with a plain `GET` and no `Authorization` header;
                      request a new one when it expires instead of storing it.
                      (The example is shortened.)
                    example: >-
                      https://files.example.com/3f6c2a1e-8b4d-4f7a-9c2e-5d1b7a9e4c60.jpg?signature=…
                  name:
                    type: string
                    description: Name of the file, as sent when the attachment was created.
                    example: cupom-fiscal-posto.jpg
                  contentType:
                    type: string
                    description: >-
                      Media type of the file, as declared when the attachment
                      was created.
                    example: image/jpeg
                required:
                  - url
                  - name
                  - contentType
                description: A short-lived link to the attachment's file.
        '403':
          description: >-
            `ATTACHMENT_MEMBERSHIP_REQUIRED` — You are not a member of the
            organization.
          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:
                      - ATTACHMENT_MEMBERSHIP_REQUIRED
                    description: >-
                      Stable, machine-readable error code. Branch on this, never
                      on `message`.
                  origin:
                    type: string
                    enum:
                      - ATTACHMENT
                    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: ATTACHMENT_MEMBERSHIP_REQUIRED
                origin: ATTACHMENT
                message: Organization membership required
        '404':
          description: >-
            `ATTACHMENT_NOT_FOUND` — No attachment with this ID exists in the
            organization.
          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:
                      - ATTACHMENT_NOT_FOUND
                    description: >-
                      Stable, machine-readable error code. Branch on this, never
                      on `message`.
                  origin:
                    type: string
                    enum:
                      - ATTACHMENT
                    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: ATTACHMENT_NOT_FOUND
                origin: ATTACHMENT
                message: Attachment not found
        '409':
          description: >-
            `ATTACHMENT_NOT_AVAILABLE` — The file hasn't been uploaded yet
            (`PENDING_UPLOAD` — retry shortly) or the attachment was deleted.
          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:
                      - ATTACHMENT_NOT_AVAILABLE
                    description: >-
                      Stable, machine-readable error code. Branch on this, never
                      on `message`.
                  origin:
                    type: string
                    enum:
                      - ATTACHMENT
                    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: ATTACHMENT_NOT_AVAILABLE
                origin: ATTACHMENT
                message: Attachment is not available for download yet
        '422':
          description: >-
            `BAD_REQUEST` — A path parameter 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:
                      - BAD_REQUEST
                    description: >-
                      Stable, machine-readable error code. Branch on this, never
                      on `message`.
                  origin:
                    type: string
                    enum:
                      - ATTACHMENT
                    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: ATTACHMENT
                message: >-
                  Bad Request: Your request is invalid or incomplete. Please
                  make sure you are requesting with the right fields.
                fields:
                  - field: attachmentId
                    message: Invalid UUID
                    code: ATTACHMENTID_UUID

````

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