MegaAPI icon

MegaAPI

Interact with MegaAPI WhatsApp service

Overview

This node operation sends a media file encoded in base64 format to a specified WhatsApp contact using the MegaAPI WhatsApp service. It supports various media types such as images, audio, video, documents, and voice messages (PTT). This is useful when you want to programmatically send media content directly from base64 data without needing to upload files separately or provide URLs.

Common scenarios:

  • Sending dynamically generated images or screenshots.
  • Delivering audio clips or voice notes stored as base64 strings.
  • Sharing documents like PDFs or spreadsheets directly from encoded data.
  • Automating media sharing workflows in customer support or marketing via WhatsApp.

Example:
You have a base64-encoded PNG image generated by your application and want to send it to a client’s WhatsApp number with a caption describing the image.

Properties

Name Meaning
To (Contact) The WhatsApp contact to send the media to. Must be in the format phone_number@s.whatsapp.net (e.g., 551199999999@s.whatsapp.net).
Base64 Data The base64 encoded media data including the data URI prefix (e.g., data:image/png;base64,iVBORw0KGgo...). This contains the actual media content to send.
File Name The name of the file as it will appear in WhatsApp (e.g., image.png).
Media Type The type of media being sent. Options include: Audio, Document, Image, PTT (Voice Message), and Video.
MIME Type The MIME type of the media file. Options include common formats such as image/jpeg, image/png, application/pdf, video/mp4, audio/ogg; codecs=opus, etc.
Caption Optional text caption to accompany the media file when sending.
Information A notice explaining that the media file will be sent from base64 data to the specified WhatsApp contact, emphasizing the required data URI format.

Output

The node outputs JSON data representing the response from the MegaAPI WhatsApp service after attempting to send the media message. This typically includes confirmation details such as message ID, status, or error information if the send failed.

If the media is successfully sent, the output JSON confirms the delivery or acceptance of the media message by the WhatsApp service.

No binary data is output by this node; it only handles sending base64 media input and returns JSON responses.

Dependencies

  • Requires an active MegaAPI WhatsApp service account with valid API credentials (an API key/token).
  • The node must be configured with these credentials, including host URL and authorization token.
  • Internet connectivity to reach the MegaAPI endpoint.
  • Proper formatting of the base64 media string with the correct data URI scheme.

Troubleshooting

  • Invalid Contact Format: Ensure the "To (Contact)" property uses the exact format phone_number@s.whatsapp.net. Missing or incorrect suffix will cause errors.
  • Malformed Base64 Data: The base64 string must include the data URI prefix (data:type/subtype;base64,). Omitting this or corrupt data will result in failure to send.
  • Unsupported MIME Type: Select the correct MIME type matching the media content. Mismatched MIME types may cause the media to not display properly on WhatsApp.
  • File Name Issues: Avoid special characters or unsupported extensions in the file name to prevent rejection.
  • API Authentication Errors: Verify that the API token and host are correctly set in credentials. Authentication failures will block sending.
  • Quota or Rate Limits: If the MegaAPI service enforces limits, exceeding them may cause errors or delays.
  • Error Messages: The node throws errors indicating unknown operations or resources if misconfigured. Check that Resource is set to "Message" and Operation to "Send Media Base64".

Links and References

Discussion