Transactional WhatsApp Message File Processes

Prev Next

These file processes only work for Cloud API customers; these features are not available for OnPrem customers (TR numbers).

Uploading a file for your transactional WhatsApp messages is a two-step process:

File Upload

You can use the Application Uploads endpoint to describe your file and create an upload session.

If successful, a file handle will be returned, which you can then use with other endpoints that support file handles returned by the Resumable Upload API.

When you upload a file to Meta, the system generates a file ID. This ID can be used instead of the file URL when sending messages.

  • As of now, the validity period of Meta File Upload IDs has been reduced from 1 month to 1 week.

  • This update only affects file uploads made via API endpoints.

  • Panel usage is not affected, as it doesn’t rely on this file ID system.

Headers

Header

Sample Value

Description

X-INS-AUTH-KEY

1a2b3c4d5e6f

This key is required to authorize your request. Refer to API Authentication Tokens to generate your token.

Content-Type

application/json

This header specifies the media type of the resource.

Sample Request

curl --location 'https://whatsapp.useinsider.com/v1/media/upload' \
--header 'x-ins-auth-key: INS.1a2b3c4d5e6f' \
--header 'Content-Type: application/json' \
--form 'file=@"/Desktop/test.jpeg"' \
--form 'type="image/jpeg"' \
--form 'messaging_product="whatsapp"'

Sample Response

{
    "id": "{{FILE_ID}}"
}

To send an audio file as a voice note, upload an OGG file with the OPUS codec. Then use the returned ID as the audio id in your message and set voice to true.

For more information about sending audio messages, refer to Send Transactional WhatsApp Media Message (Audio).

Get File URL

You can use the returned upload session ID to initiate the upload process.

If successful, a file handle will be returned, which you can then use with other endpoints that support file handles returned by the Resumable Upload API.

Headers

Header

Sample Value

Description

X-INS-AUTH-KEY

1a2b3c4d5e6f

This key is required to authorize your request. Refer to API Authentication Tokens to generate your token.

Content-Type

application/json

This header specifies the media type of the resource.

Sample Request

curl --location 'https://whatsapp.useinsider.com/v1/media/{{FILE_ID}}' \
--header 'x-ins-auth-key: INS.1a2b3c4d5e6f' \
--header 'Content-Type: application/json'

Sample Response

{
   "url": "{{FILE_URL}}",
   "mime_type": "FILE_TYPE",
   "sha256": "{{SHA_CODE}}",
   "File_size": {{FILE_SIZE}},
   "id": "{{FILE_ID}}",
   "messaging_product": "whatsapp"
}

Download File

You can use this request to retrieve uploaded files via API.

Sample Request

curl --location 'https://whatsapp.useinsider.com/v1/media/download/{{file-id}}' \
--header 'x-ins-auth-key: ****' \
--header 'Content-Type: application/json' \
--data ''

As a response, you will receive the original file.