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

# Create an attachment upload URL

> Create a short-lived upload URL and token that lets a remote client PUT one binary attachment without exposing the API key on the upload request. Requires `email.send` permission.



## OpenAPI

````yaml /openapi-sending.json post /emails/attachment-uploads
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:
    post:
      tags:
        - Attachments
      summary: Create an attachment upload URL
      description: >-
        Create a short-lived upload URL and token that lets a remote client PUT
        one binary attachment without exposing the API key on the upload
        request. Requires `email.send` permission.
      operationId: sendingCreateAttachmentUpload
      parameters:
        - description: >-
            Optional client-generated key to make the request idempotent for 24
            hours. Replays under the same key return the cached response; a
            reused key with a different body returns 409 idempotency_conflict.
          example: order-12345-2026-04-24
          in: header
          name: Idempotency-Key
          required: false
          schema:
            maxLength: 255
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AttachmentUploadIntentRequest'
        required: true
      responses:
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AttachmentUploadIntentResponse'
          description: Attachment upload URL created
          headers:
            Location:
              description: Canonical URL for the temporary attachment upload intent.
              schema:
                type: string
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Malformed request
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Authentication required
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Insufficient permissions
        '409':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Idempotency conflict
        '413':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Attachment exceeds the upload size cap
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Attachment upload validation failed
        '429':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Rate limit exceeded
        '503':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Attachment upload service temporarily unavailable
      security:
        - BearerAuth: []
        - OAuth2:
            - email.send
components:
  schemas:
    AttachmentUploadIntentRequest:
      additionalProperties: false
      properties:
        content_type:
          description: MIME type expected for the upload.
          example: application/pdf
          maxLength: 255
          type: string
        filename:
          description: Filename to associate with the uploaded attachment.
          example: analysis.pdf
          maxLength: 255
          minLength: 1
          type: string
        sha256:
          description: Optional SHA-256 hex digest for the upload bytes.
          example: '0000000000000000000000000000000000000000000000000000000000000000'
          pattern: ^[a-f0-9]{64}$
          type: string
        size_bytes:
          description: Exact byte size that will be uploaded.
          example: 20480
          exclusiveMinimum: 0
          type: integer
      required:
        - filename
        - size_bytes
      type: object
    AttachmentUploadIntentResponse:
      allOf:
        - $ref: '#/components/schemas/SuccessEnvelope'
        - properties:
            data:
              $ref: '#/components/schemas/AttachmentUploadIntentData'
          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
    AttachmentUploadIntentData:
      additionalProperties: false
      properties:
        expires_at:
          description: ISO timestamp when the upload URL expires.
          example: '2026-07-07T08:15:00.000Z'
          format: date-time
          type: string
        headers:
          additionalProperties:
            type: string
          description: Headers that must be sent with the PUT upload request.
          example:
            Content-Length: '20480'
            Content-Type: application/pdf
            X-Qubrics-Upload-Token: smx_upload_...
            X-Sendmux-Upload-Token: smx_upload_...
          type: object
        max_size_bytes:
          description: Maximum upload size in bytes
          example: 18874368
          type: integer
        method:
          description: HTTP method for upload_url
          enum:
            - PUT
          type: string
        upload_id:
          description: Temporary upload intent ID.
          example: upl_tz4a98xxat96iws9zmbrgj3a
          pattern: ^upl_[a-z0-9]{24}$
          type: string
        upload_url:
          description: Short-lived URL that accepts a binary PUT with the returned headers.
          example: >-
            https://smtp.sendmux.ai/api/v1/emails/attachment-uploads/upl_tz4a98xxat96iws9zmbrgj3a
          format: uri
          type: string
      required:
        - upload_id
        - upload_url
        - method
        - expires_at
        - max_size_bytes
        - headers
      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

````

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