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

# Upload an attachment to R2 storage (tiered auth)

> Upload a single message attachment to R2 storage. Accepts authenticated agent uploads or unauthenticated webchat uploads gated by a valid `webchatConfigId`. Returns the storage key plus content metadata for inclusion in a subsequent send-message call.



## OpenAPI

````yaml /api-reference/openapi.yaml post /api/messages/upload-attachment
openapi: 3.0.3
info:
  title: Tether Relay and Tether API
  version: 1.0.0
  description: >-
    Route-derived OpenAPI contract generated from tether-relay backend sources.
    Regenerate with scripts/sync-openapi-from-backend.mjs.
servers:
  - url: https://your-instance.example.com
    description: Production
  - url: http://localhost:2212
    description: Local API service
security: []
tags:
  - name: AI
  - name: Applications
  - name: Approval
  - name: Auth
  - name: Automations
  - name: Calls
  - name: Campaigns
  - name: Contact Analytics
  - name: Contact Metrics
  - name: Contact Notes
  - name: Contacts
  - name: Conversation Monitor
  - name: Conversations
  - name: Departments
  - name: Email
  - name: Escalation Dashboard
  - name: Event Logs
  - name: Google Sheets
  - name: Marketplace
  - name: Messages
  - name: Notification Sounds
  - name: Notifications
  - name: Org Snapshots
  - name: Organizations
  - name: Outreach
  - name: Outreach Metrics
  - name: Outreach Sources
  - name: Pipelines
  - name: Processes
  - name: Prompts
  - name: Reminders
  - name: Sms
  - name: Templates
  - name: Traces
  - name: Training
  - name: Upload
  - name: User Snapshots
  - name: Users
  - name: Vertical
  - name: Webchats
  - name: Webhook
paths:
  /api/messages/upload-attachment:
    post:
      tags:
        - Messages
      summary: Upload an attachment to R2 storage (tiered auth)
      description: >-
        Upload a single message attachment to R2 storage. Accepts authenticated
        agent uploads or unauthenticated webchat uploads gated by a valid
        `webchatConfigId`. Returns the storage key plus content metadata for
        inclusion in a subsequent send-message call.
      operationId: post_messages_upload_attachment
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                file:
                  type: string
                  format: binary
                  description: A single binary attachment (image, video, PDF). Max 50 MB.
                webchatConfigId:
                  type: string
                  description: >-
                    Required when the caller is the webchat widget (no
                    JWT/API-key). Validated against the org's active webchat
                    configurations to gate unauthenticated uploads.
              required:
                - file
              description: >-
                Multipart form. Send the file as a `file` part; for
                unauthenticated webchat uploads also include `webchatConfigId`.
                Example with curl: `curl -F "file=@receipt.png" -H
                "Authorization: Bearer $TOKEN" /api/messages/upload-attachment`.
              example:
                file: '<binary: receipt.png>'
                webchatConfigId: 64a1b2c3d4e5f60012345678
      responses:
        '200':
          description: Attachment uploaded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UploadAttachmentResponse'
        '400':
          description: No file uploaded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LegacyErrorResponse'
        '401':
          description: Authentication required
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LegacyErrorResponse'
        '429':
          description: Rate limit exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RateLimitResponse'
        '503':
          description: Storage not configured
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LegacyErrorResponse'
components:
  schemas:
    UploadAttachmentResponse:
      type: object
      properties:
        success:
          type: boolean
        attachment:
          type: object
          properties:
            storageKey:
              type: string
            filename:
              type: string
            contentType:
              type: string
            size:
              type: integer
          additionalProperties: false
      additionalProperties: true
      example:
        success: true
        attachment:
          storageKey: messages/65a0e0e0e0e0e0e0e0e0e0e0/msg_67b0/photo.jpg
          filename: photo.jpg
          contentType: image/jpeg
          size: 184221
    LegacyErrorResponse:
      type: object
      properties:
        error:
          type: string
        message:
          type: string
        data: {}
      additionalProperties: true
      example:
        error: Attachment not found
        message: Attachment not found
    RateLimitResponse:
      type: object
      properties:
        error:
          type: string
        limit:
          type: integer
        currentCount:
          type: integer
        resetIn:
          type: integer
          description: Seconds until rate limit resets
        message:
          type: string
      additionalProperties: true
      example:
        error: Too many requests
        limit: 20
        currentCount: 21
        resetIn: 42
        message: Please wait before uploading more attachments

````