> ## 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 a new document for a contact (multipart)

> Accepts a multipart/form-data upload (max 25 MB) and stores it in R2 under a deterministic per-contact key, then attaches the resulting document record to the contact. documentType must match an entry in the organization's configured documentTypes.



## OpenAPI

````yaml /api-reference/openapi.yaml post /api/contacts/{contactId}/documents/upload
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/contacts/{contactId}/documents/upload:
    post:
      tags:
        - Contacts
      summary: Upload a new document for a contact (multipart)
      description: >-
        Accepts a multipart/form-data upload (max 25 MB) and stores it in R2
        under a deterministic per-contact key, then attaches the resulting
        document record to the contact. documentType must match an entry in the
        organization's configured documentTypes.
      operationId: post_contact_document_upload
      parameters:
        - in: path
          name: contactId
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/UploadContactDocumentForm'
            encoding:
              file:
                contentType: application/octet-stream
      responses:
        '201':
          description: Document uploaded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContactDocumentMutationResponse'
        '400':
          description: Missing file or invalid documentType
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LegacyErrorResponse'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LegacyErrorResponse'
        '404':
          description: Contact or organization not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LegacyErrorResponse'
        '500':
          description: Upload failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LegacyErrorResponse'
      security:
        - bearerAuth: []
components:
  schemas:
    UploadContactDocumentForm:
      type: object
      properties:
        file:
          type: string
          format: binary
          description: Document file (max 25 MB).
        documentType:
          type: string
          description: Must match a name in the organization's configured documentTypes.
        notes:
          type: string
      required:
        - file
        - documentType
      example:
        documentType: ID Proof
        notes: Driver license front + back
    ContactDocumentMutationResponse:
      type: object
      properties:
        success:
          type: boolean
          enum:
            - true
        document:
          $ref: '#/components/schemas/ContactDocumentDto'
      required:
        - success
        - document
      additionalProperties: true
      example:
        success: true
        document:
          _id: 64f0a1b2c3d4e5f6a7b8ca40
          storageKey: >-
            org/64f0a1b2c3d4e5f6a7b8c9d3/contact/64f0a1b2c3d4e5f6a7b8c9d0/2026/id-proof.pdf
          filename: id-proof.pdf
          contentType: application/pdf
          documentType: ID Proof
    LegacyErrorResponse:
      type: object
      properties:
        error:
          type: string
        message:
          type: string
        data: {}
      additionalProperties: true
      example:
        error: Attachment not found
        message: Attachment not found
    ContactDocumentDto:
      type: object
      properties:
        _id:
          type: string
        storageKey:
          type: string
        filename:
          type: string
        contentType:
          type: string
        size:
          type: integer
        documentType:
          type: string
        sourceMessageId:
          type: string
          nullable: true
        uploadedAt:
          type: string
          format: date-time
          nullable: true
        uploadedBy:
          type: string
          nullable: true
        notes:
          type: string
          nullable: true
        signedUrl:
          type: string
          nullable: true
          description: Short-lived signed GET URL for the underlying R2 object.
      required:
        - storageKey
        - filename
        - contentType
        - documentType
      additionalProperties: true
      example:
        _id: 64f0a1b2c3d4e5f6a7b8ca40
        storageKey: >-
          org/64f0a1b2c3d4e5f6a7b8c9d3/contact/64f0a1b2c3d4e5f6a7b8c9d0/2026/id-proof.pdf
        filename: id-proof.pdf
        contentType: application/pdf
        size: 184320
        documentType: ID Proof
        uploadedAt: '2026-05-12T10:00:00.000Z'
        uploadedBy: 64f0a1b2c3d4e5f6a7b8c9d4
        notes: Driver license, front + back
        signedUrl: https://example-r2.signed/.../id-proof.pdf?X-Amz-Expires=600
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````