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

# send media message

> Send a media message (image only: PNG, JPEG, GIF, WebP). Must provide either mediaUrl or mediaBase64, but not both. Maximum file size: 10MB.



## OpenAPI

````yaml api-reference/openapi.json post /devices/{id}/messages/media
openapi: 3.1.0
info:
  title: Chatlevel API
  description: >-
    Chatlevel is a WhatsApp web API to manage any WhatsApp account
    programmatically.
  version: v1.0.0
servers:
  - url: https://api.chatlevel.io/v1
security:
  - bearerAuth: []
tags:
  - name: devices
    description: Operations related to managing devices.
  - name: messages
    description: Operations related to sending messages.
paths:
  /devices/{id}/messages/media:
    post:
      tags:
        - messages
      summary: send media message
      description: >-
        Send a media message (image only: PNG, JPEG, GIF, WebP). Must provide
        either mediaUrl or mediaBase64, but not both. Maximum file size: 10MB.
      operationId: send-media-message
      parameters:
        - name: id
          in: path
          description: Device ID
          required: true
          schema:
            type: integer
            description: Numeric device identifier
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              oneOf:
                - required:
                    - to
                - required:
                    - toNumber
              properties:
                to:
                  type: string
                  description: >-
                    Full WhatsApp JID. Use for LIDs (e.g.,
                    '138087493537914@lid'), groups (e.g.,
                    '123456789-987654@g.us'), or full phone JIDs (e.g.,
                    '31612345678@s.whatsapp.net'). Mutually exclusive with
                    toNumber.
                  example: 123456789-987654@g.us
                toNumber:
                  type: string
                  description: >-
                    WhatsApp phone number (digits only, 8-15 digits). Will be
                    formatted as phone@s.whatsapp.net. Mutually exclusive with
                    'to'.
                  example: '31620292537'
                mediaUrl:
                  type: string
                  description: URL of the media file
                mediaBase64:
                  type: string
                  description: Base64 encoded media content
                mediaCaption:
                  type: string
                  description: Optional caption for the media
      responses:
        '200':
          description: Media message sent successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: success
                  messageId:
                    type: string
              example:
                status: success
                messageId: 3EB0C1F0B2F0A1D5E8F4
        '400':
          description: >-
            Invalid request - either invalid JSON, missing required fields, or
            invalid media format
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: object
                    properties:
                      code:
                        type: integer
                        example: 400
                      message:
                        type: string
                        example: >-
                          Invalid image format (only PNG, JPEG, GIF, WebP
                          allowed)
        '401':
          $ref: '#/components/responses/401Unauthorized'
        '404':
          description: Device not found or not connected
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    $ref: '#/components/schemas/status'
              example:
                status:
                  code: 404
                  message: >-
                    Device 12345 is not connected. Please restart the device or
                    scan the QR code to connect.
        '408':
          $ref: '#/components/responses/408Timeout'
        '413':
          $ref: '#/components/responses/413PayloadTooLarge'
        '422':
          $ref: '#/components/responses/422NotAuthenticated'
        '429':
          $ref: '#/components/responses/429RateLimit'
        '500':
          description: Failed to send media message
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    $ref: '#/components/schemas/status'
              example:
                status:
                  code: 500
                  message: Failed to send media message
components:
  responses:
    401Unauthorized:
      description: Missing or invalid authorization header
      content:
        application/json:
          schema:
            type: object
            properties:
              status:
                type: string
                example: error
              error:
                type: object
                properties:
                  code:
                    type: integer
                    example: 401
                  message:
                    type: string
                    example: >-
                      Missing or invalid authorization header. Please provide a
                      Bearer token.
    408Timeout:
      description: Request timeout
      content:
        application/json:
          schema:
            type: object
            properties:
              status:
                type: object
                properties:
                  code:
                    type: integer
                    example: 408
                  message:
                    type: string
                    example: Request timeout
    413PayloadTooLarge:
      description: Request payload too large
      content:
        application/json:
          schema:
            type: object
            properties:
              status:
                type: object
                properties:
                  code:
                    type: integer
                    example: 413
                  message:
                    type: string
                    example: Request payload too large
    422NotAuthenticated:
      description: Device is not fully authenticated
      content:
        application/json:
          schema:
            type: object
            properties:
              status:
                type: object
                properties:
                  code:
                    type: integer
                    example: 422
                  message:
                    type: string
                    example: >-
                      Device is not fully authenticated. Please scan the QR code
                      to complete the connection.
    429RateLimit:
      description: Rate limit exceeded
      content:
        application/json:
          schema:
            type: object
            properties:
              status:
                type: object
                properties:
                  code:
                    type: integer
                    example: 429
                  message:
                    type: string
                    example: >-
                      Rate limit exceeded. Maximum 100 requests per minute per
                      user.
  schemas:
    status:
      type: object
      properties:
        code:
          type: integer
          description: Status code
          example: 200
        message:
          type: string
          description: Status message
          example: Success
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        API key authentication. Provide your API key as: Authorization: Bearer
        <api_key>

````