> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stax.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Download email attachment

> Download an email attachment as binary data. Supports both GCP-stored attachments (by file ID) and email provider attachments (by source ID). The attachment ID can be either a MongoDB ObjectID (24 chars) for GCP-stored files or an email provider attachment ID. The owning message must live in the given thread and be visible to the caller under the same rules as the thread read path.



## OpenAPI

````yaml /api-reference/cx/swagger.json get /inbox/thread/{thread}/attachment/{attachment}
openapi: 3.0.0
info:
  description: CX API.
  title: CX API
  contact:
    name: API Support
    url: https://stax.ai
    email: support@stax.ai
  version: '1.0'
servers:
  - url: https://api.cx.stax.ai
security: []
paths:
  /inbox/thread/{thread}/attachment/{attachment}:
    get:
      tags:
        - Inbox
      summary: Download email attachment
      description: >-
        Download an email attachment as binary data. Supports both GCP-stored
        attachments (by file ID) and email provider attachments (by source ID).
        The attachment ID can be either a MongoDB ObjectID (24 chars) for
        GCP-stored files or an email provider attachment ID. The owning message
        must live in the given thread and be visible to the caller under the
        same rules as the thread read path.
      parameters:
        - description: Thread ID
          name: thread
          in: path
          required: true
          schema:
            type: string
        - description: >-
            Attachment ID (MongoDB ObjectID for GCP-stored) or source ID (email
            provider attachment ID)
          name: attachment
          in: path
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Attachment file data
          content:
            application/octet-stream:
              schema:
                type: string
                format: binary
        '400':
          description: Invalid attachment ID or email connection not live
          content:
            application/octet-stream:
              schema:
                type: object
                additionalProperties: true
        '401':
          description: Unauthorized
          content:
            application/octet-stream:
              schema:
                type: object
                additionalProperties: true
        '404':
          description: Attachment not found, or not visible to the caller
          content:
            application/octet-stream:
              schema:
                type: object
                additionalProperties: true
        '500':
          description: Internal server error
          content:
            application/octet-stream:
              schema:
                type: object
                additionalProperties: true
      security:
        - ApiKeyAuth: []
components:
  securitySchemes:
    ApiKeyAuth:
      description: CX API key. Create one in CX under Settings → Advanced → API Keys.
      in: header
      name: x-api-key
      type: apiKey

````

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