{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/wasync-app/json-schema/wasync-app-send-message-request-schema.json",
  "title": "SendMessageRequest",
  "description": "Send either a `text` message or a `media` message — supply exactly one of the two. Supplying both returns 400 `text_or_media`.",
  "x-generated": "2026-11-28",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/wasync-app-openapi.json#/components/schemas/SendMessageRequest",
  "type": "object",
  "required": [
    "connectionId",
    "to"
  ],
  "properties": {
    "connectionId": {
      "type": "string",
      "description": "A connection id from `GET /connections`."
    },
    "to": {
      "type": "string",
      "description": "Recipient in international format, digits only (no `+`), e.g. `40700000000`."
    },
    "text": {
      "type": "string",
      "maxLength": 4096,
      "description": "Text message body (max 4096 chars). Mutually exclusive with `media`."
    },
    "media": {
      "$ref": "#/$defs/MediaObject",
      "description": "Media to send. Mutually exclusive with `text`."
    },
    "idempotencyKey": {
      "type": "string",
      "description": "Optional. Makes retries safe on text sends — the same key returns the original result instead of sending twice."
    }
  },
  "$defs": {
    "MediaObject": {
      "type": "object",
      "required": [
        "filename",
        "mimetype",
        "data"
      ],
      "properties": {
        "filename": {
          "type": "string",
          "description": "File name including extension (e.g. `photo.jpg`, `voice-note.ogg`, `report.pdf`)."
        },
        "mimetype": {
          "type": "string",
          "description": "MIME type of the file. Allowed: images (`image/jpeg`, `image/png`, `image/gif`, `image/webp`), video (`video/mp4`, `video/webm`), audio (`audio/mpeg`, `audio/ogg`, `audio/wav`, `audio/webm`, `audio/aac`), documents (`application/pdf`, `application/msword`, `application/vnd.openxmlformats-officedocument.wordprocessingml.document`, `application/vnd.ms-excel`, `application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`, `text/plain`, `text/csv`, `application/zip`). Executables and `image/svg+xml` are blocked."
        },
        "data": {
          "type": "string",
          "description": "Base64-encoded file contents. Maximum decoded size: **16 MB** (base64 string length ≤ 22 400 000 chars)."
        },
        "caption": {
          "type": [
            "string",
            "null"
          ],
          "description": "Optional caption shown below the media in WhatsApp."
        }
      }
    }
  }
}