Media upload components
WhatsApp does not guarantee that data (such as images, videos, or documents) shared with you by your customers is non-malicious. Make sure to implement appropriate risk mitigations when processing such data (for example, using well-tested and up-to-date media and document processing libraries). Media upload components are not supported by the On-Premise API client. Please refer to the deprecation announcent and learn how to migrate to Cloud API.Flow JSON components
Two components can be used to ask users to upload media- PhotoPicker: allows uploading media from camera or gallery
- DocumentPicker: allows uploading media from files or gallery
PhotoPicker
Supported starting with Flow JSON version 4.0Example
Flow JSON { Enter to Rename, Shift+Enter to Preview Preview Run Settings Preview Flow Upload photos Please attach images about the received itemsAdd 1 to 10 photos. Max file size 10 MB. Take photo Submit Managed by the business. Learn more Learn more Note that the image selection behaviour is mocked in this preview. The actual behaviour on device will be similar to the image selection in WhatsApp chats.
Limitations and Restrictions
The table below outlines the constraints associated with the PhotoPicker component.DocumentPicker
Supported starting with Flow JSON version 4.0Example
Flow JSON { Enter to Rename, Shift+Enter to Preview Preview Run Settings Preview Flow Contract Attach the signed copy of the contractMax file size 1 MB. Upload document Submit Managed by the business. Learn more Learn more Note that the document selection behaviour is mocked in this preview. The actual behaviour on device will be similar to the document selection in WhatsApp chats.
Limitations and Restrictions
The table below outlines the constraints associated with the DocumentPicker component.Handling media
Endpoint
Media uploaded by the users are temporarily (up to 20 days) stored in WhatsApp CDN. Files are encrypted using AES256-CBC+HMAC-SHA256+pkcs7 cryptographic algorithms. In your endpoint implementation, you must download, decrypt, and validate each media file. Here’s a payload example for a photo or document.Decrypting and validating media
The files stored in WhatsApp CDN contain the encrypted media and the first 10 bytes of the HMAC-SHA256 (concatenated at the end). For reference, cdn_file = ciphertext & hmac10 Perform the following steps to decrypt the media:- Download cdn_file file from cdn_url
- Make sure SHA256(cdn_file) == enc_hash
- Validate HMAC-SHA256
- Calculate HMAC with hmac_key, initialization vector (encryption_metadata.iv) and ciphertex
- Make sure first 10 bytes == hmac10
- Decrypt media content
- Run AES with CBC mode and initialization vector (encryption_metadata.iv) on ciphertex
- Remove padding (AES256 uses blocks of 16 bytes, padding algorithm is pkcs7). We’ll call this decrypted_media
-
Validate the decrypted media
- Make sure SHA256(decrypted_media) = plaintext_hash

