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

# Upload media to WhatsApp

> Uploads a file to WhatsApp Cloud API. Use the returned id as document.id when calling POST /messages/document.



## OpenAPI

````yaml POST /messages/upload-media
openapi: 3.1.0
info:
  title: Cogfy Messenger Public API
  version: 1.0.0
  description: API for interacting with the Cogfy Messenger platform
servers:
  - url: https://messenger-public-api.cogfy.com
    description: Production server
  - url: http://localhost:3100
    description: Local server
security:
  - ApiKeyAuth: []
paths:
  /messages/upload-media:
    post:
      tags:
        - Messages
      summary: Upload media to WhatsApp
      description: >-
        Uploads a file to WhatsApp Cloud API. Use the returned id as document.id
        when calling POST /messages/document.
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
                - from
                - file
              properties:
                from:
                  type: string
                  description: WhatsApp phone number ID (sender)
                file:
                  type: string
                  format: binary
          application/json:
            schema:
              type: object
              required:
                - from
                - media
              properties:
                from:
                  type: string
                  description: WhatsApp phone number ID (sender)
                media:
                  type: object
                  required:
                    - mimeType
                    - base64
                  properties:
                    mimeType:
                      type: string
                      description: MIME type of the file (e.g. application/pdf)
                    base64:
                      type: string
                      description: >-
                        File bytes as base64 (optional data URL prefix
                        supported)
                    name:
                      type: string
                      description: Filename hint for upload
      responses:
        '200':
          description: Media uploaded successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    description: WhatsApp media id (use as document.id for send document)
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: api-key

````