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

# Delete an attachment

> Deletes an attachment.

Only admins of the organization (or of the realm) can delete one. Deleting is permanent — there is no undo — and no new download link is issued for the file afterwards; a link issued before stays valid until it expires, at most 10 minutes later. The attachment itself stays readable, with `status: DELETED`.

Deleting an attachment that is already deleted succeeds again (`204`), so a retry is safe.


## OpenAPI

````yaml /api-reference/attachment.openapi.json delete /realms/{realmId}/organizations/{organizationId}/attachments/{attachmentId}
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}:
    delete:
      tags:
        - Attachments
      summary: Delete an attachment
      description: Deletes an attachment.
      operationId: >-
        deleteRealmsByRealmIdOrganizationsByOrganizationIdAttachmentsByAttachmentId
      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:
        '204':
          description: No Content. The operation succeeded and the response has no body.
        '403':
          description: >-
            `ATTACHMENT_ADMIN_REQUIRED` — Only admins of the organization or of
            the realm can delete attachments.
          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_ADMIN_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_ADMIN_REQUIRED
                origin: ATTACHMENT
                message: Organization admin 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
        '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.