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

# Upload bytes to an attachment upload URL

> Upload the exact binary bytes for a previously-created attachment upload URL. This operation uses the short-lived upload token header returned by POST /emails/attachment-uploads, not a Sendmux API key.



## OpenAPI

````yaml /openapi-sending.json put /emails/attachment-uploads/{upload_id}
openapi: 3.1.0
info:
  description: >-
    Send emails programmatically via the Sendmux email infrastructure. Every
    response carries an `X-Request-Id` header; errors include a `retryable`
    flag. 429 and 503 responses include `Retry-After`. Mutating endpoints accept
    an `Idempotency-Key` header for safe retries.
  title: Sendmux Sending API
  version: 1.0.0
servers:
  - description: Production
    url: https://smtp.sendmux.ai/api/v1
security:
  - BearerAuth: []
  - OAuth2:
      - email.send
paths:
  /emails/attachment-uploads/{upload_id}:
    put:
      tags:
        - Attachments
      summary: Upload bytes to an attachment upload URL
      description: >-
        Upload the exact binary bytes for a previously-created attachment upload
        URL. This operation uses the short-lived upload token header returned by
        POST /emails/attachment-uploads, not a Sendmux API key.
      operationId: sendingCompleteAttachmentUpload
      parameters:
        - description: >-
            Short-lived upload token returned by POST
            /emails/attachment-uploads. Send this header or
            X-Sendmux-Upload-Token. If both are sent, their values must match.
          in: header
          name: X-Qubrics-Upload-Token
          required: false
          schema:
            type: string
        - description: >-
            Compatibility alias for X-Qubrics-Upload-Token, retained
            indefinitely.
          in: header
          name: X-Sendmux-Upload-Token
          required: false
          schema:
            type: string
        - description: Exact number of bytes in the binary request body.
          example: 20480
          in: header
          name: Content-Length
          required: true
          schema:
            format: int64
            minimum: 1
            type: integer
        - description: Upload intent ID returned by POST /emails/attachment-uploads.
          in: path
          name: upload_id
          required: true
          schema:
            pattern: ^upl_[a-z0-9]{24}$
            type: string
      requestBody:
        content:
          application/octet-stream:
            schema:
              format: binary
              type: string
        required: true
      responses:
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AttachmentUploadResponse'
          description: Attachment uploaded successfully
          headers:
            Location:
              description: Canonical URL for the temporary uploaded attachment metadata.
              schema:
                type: string
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Missing or invalid upload headers
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Upload token missing, invalid, or expired
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Upload intent not found or expired
        '409':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Upload already completed with different content
        '413':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Uploaded bytes do not match the expected size
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Attachment validation failed
        '503':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Attachment storage temporarily unavailable
      security:
        - UploadTokenQubrics: []
        - UploadTokenSendmux: []
components:
  schemas:
    AttachmentUploadResponse:
      allOf:
        - $ref: '#/components/schemas/SuccessEnvelope'
        - properties:
            data:
              $ref: '#/components/schemas/AttachmentUploadData'
          required:
            - data
          type: object
      unevaluatedProperties: false
    ErrorResponse:
      additionalProperties: false
      properties:
        error:
          $ref: '#/components/schemas/ErrorDetail'
        meta:
          $ref: '#/components/schemas/Meta'
        ok:
          enum:
            - false
          type: boolean
      required:
        - ok
        - error
        - meta
      type: object
    SuccessEnvelope:
      properties:
        meta:
          $ref: '#/components/schemas/Meta'
        ok:
          enum:
            - true
          type: boolean
      required:
        - ok
        - meta
      type: object
    AttachmentUploadData:
      additionalProperties: false
      properties:
        attachment_id:
          description: Temporary attachment ID to use in email attachments[].
          example: att_tz4a98xxat96iws9zmbrgj3a
          pattern: ^att_[a-z0-9]{24}$
          type: string
        content_type:
          description: Stored attachment MIME type
          example: application/pdf
          type: string
        expires_at:
          description: ISO timestamp when this temporary attachment reference expires.
          example: '2026-07-07T08:15:00.000Z'
          format: date-time
          type: string
        filename:
          description: Stored attachment filename
          example: analysis.pdf
          type: string
        size_bytes:
          description: Stored attachment byte size
          example: 20480
          type: integer
      required:
        - attachment_id
        - filename
        - content_type
        - size_bytes
        - expires_at
      type: object
    ErrorDetail:
      additionalProperties: false
      properties:
        code:
          description: Machine-readable error code
          example: validation_error
          type: string
        doc_url:
          description: Link to error documentation
          format: uri
          type: string
        errors:
          description: Accumulated per-field issues (validation errors)
          items:
            $ref: '#/components/schemas/ErrorIssue'
          type: array
        message:
          description: Human-readable error description
          type: string
        param:
          description: Parameter that caused the error
          type: string
        retryable:
          description: >-
            True when the client may safely retry the same request. 429 and 5xx
            default true; 4xx default false.
          type: boolean
      required:
        - code
        - message
        - retryable
      type: object
    Meta:
      additionalProperties: false
      properties:
        request_id:
          description: Unique request identifier
          example: req_clxxxxxxxxxxxxxxxxxxxxxxxxx
          type: string
      required:
        - request_id
      type: object
    ErrorIssue:
      additionalProperties: false
      properties:
        code:
          description: Issue code from the validator
          example: invalid_string
          type: string
        field:
          description: Dot-path to the failing field
          example: to.email
          type: string
        message:
          description: Human-readable issue message
          type: string
      required:
        - field
        - code
        - message
      type: object
  securitySchemes:
    BearerAuth:
      description: Sendmux API key (smx_...)
      scheme: bearer
      type: http
    OAuth2:
      description: >-
        Use the authorisation-code flow with S256 PKCE and
        resource=https://sendmux.ai/api. The user must grant Sending API access
        and email.send. OAuth access tokens authenticate HTTP requests; use a
        send-capable API key for SMTP.
      flows:
        authorizationCode:
          authorizationUrl: https://app.sendmux.ai/oauth/authorize
          refreshUrl: https://app.sendmux.ai/oauth/token
          scopes:
            email.send: Send email and manage temporary sending attachments
          tokenUrl: https://app.sendmux.ai/oauth/token
      type: oauth2
    UploadTokenQubrics:
      in: header
      name: X-Qubrics-Upload-Token
      type: apiKey
    UploadTokenSendmux:
      in: header
      name: X-Sendmux-Upload-Token
      type: apiKey

````

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