MegaAPI icon

MegaAPI

Interact with MegaAPI WhatsApp service

Message → Send Media Base64

AI-generated

Overview

This node operation sends a media file encoded in base64 format to a specified WhatsApp contact. It supports various media types such as audio, document, image, voice message (PTT), and video. The media is sent with an optional caption and requires specifying the MIME type and file name. This operation is useful for automating the sending of media files directly from base64 data, for example, sending images, videos, or documents to WhatsApp contacts without needing to upload files separately.

Use Case Examples

  1. Sending a base64 encoded image to a WhatsApp contact with a caption.
  2. Sending a PDF document encoded in base64 to a contact as a document file.
  3. Sending a voice message encoded in base64 as a PTT (Push-to-Talk) message.

Properties

Name Meaning
To (Contact) The WhatsApp contact to send the media to, formatted as phone_number@s.whatsapp.net (e.g., 551199999999@s.whatsapp.net). This is a required field.
Base64 Data The base64 encoded media data including the data URI format (e.g., data:image/png;base64,iVBORw0KGgo...). This is required to provide the media content to send.
File Name The name of the file as it will appear in WhatsApp. This is required to identify the media file.
Media Type The type of media to send, such as audio, document, image, PTT (voice message), or video. This determines how the media is handled and displayed in WhatsApp.
MIME Type The MIME type of the media file, specifying the format such as image/jpeg, application/pdf, video/mp4, etc. This is required to correctly identify the media format.
Caption Optional caption text to accompany the media file when sent to the WhatsApp contact.

Output

JSON

  • messageId - The unique identifier of the sent message
  • status - The status of the message sending operation (e.g., sent, failed)
  • to - The WhatsApp contact to whom the media was sent
  • fileName - The name of the media file sent
  • type - The type of media sent (audio, document, image, ptt, video)
  • mimeType - The MIME type of the media file sent
  • caption - The caption text sent with the media file, if any

Dependencies

  • Requires an API key credential for MegaAPI WhatsApp service authentication.

Troubleshooting

  • Ensure the 'To (Contact)' field is correctly formatted as phone_number@s.whatsapp.net.
  • Verify that the base64 data includes the correct data URI prefix and is properly encoded.
  • Check that the MIME type matches the actual media content to avoid sending errors.
  • If the message fails to send, verify the API credentials and network connectivity.
  • Common error messages may include invalid contact format, unsupported media type, or authentication failures. Resolving these involves correcting input formats and ensuring valid credentials.

Discussion