Media ID

/v1/media/{media-id}

Given a specific ID, use this endpoint to retrieve or delete your media.

Before You Start

Before you retrieve your delete, you must first upload your media via /v1/media.

Retrieving

After you have successfully upload your media, you receive a response containing a media ID. Use that ID in any requests to retrieve the media stored in the WhatsApp Business API client.

This process to retrieve media is also used when a user sends an image to you that is received by your Webhook. When a message with media is received, the WhatsApp Business API client will download the media. Once the media is downloaded, you will receive a notification through your Webhook; use the media ID found in that notification to retrieve the media.

You can enable the WhatsApp Business API client to auto-download media with the Auto-download Media Settings.

Example

GET /v1/media/media-id

For example, using the example image uploaded in the previous section:

curl -X GET \
  https://your-webapp-hostname:your-webapp-port/v1/media/4b5bf27b-8672-4d55-bc21-d096dc200d0f \
  -H 'Authorization: Bearer your-auth-token' 

To send this example media to a file, use the -o parameter, as shown below:

curl -X GET \
  https://your-webapp-hostname:your-webapp-port/v1/media/4b5bf27b-8672-4d55-bc21-d096dc200d0f \
  -H 'Authorization: Bearer your-auth-token' \
  -o path/filename

If your call is successful, you see a response containing a 200 OK status and the binary media data.

Content-Type: image/jpeg or other appropriate media type
Content-Length: content-size

binary-media-data

If you used a tool like Postman, you see the image. If you are using a command line tool, you see the binary data. If you sent the data to a file, you see the image in your file browser.

If the media is not found, a 404 Not Found response code is returned with no body.

If you receive a different error message, see Error and Status Messages for more information.

Deleting

To delete media in the WhatsApp Business API client, send a DELETE request to the media node along with the ID of the media that you want to delete. Use the ID from the response to uploading the media or the media message from a Webhook.

Example

Request:

DELETE /v1/media/media-id

A successful response shows 200 OK and either null or {}. If the media is not found, the response shows 404 Not Found and contains no body. If you receive a different error message, see Error and Status Messages for more information.