We are sunsetting On-Premises API. Refer to our On-Premises API Sunset document for details, and to learn how to migrate to our next-generation Cloud API.

Media retry download

/v1/media/{media-id}/download

Given a specific ID, use this endpoint to store inbound media in the WhatsApp Business API client.

Before You Start

When a media message is received, WhatsApp Business API client attempts to download the media. Due to an error or bad internet connection it may fail to store the media. When sent, the media is stored on the WhatsApp servers for 14 days. During the 14 day window, media files may be downloaded with no restrictions. If a request is made after 14 days, the WhatsApp servers will request the same media file from the owner. If the media has been removed, the WhatsApp Business API client will be notified that the media is unavailable.

Store

When a media message is received, WhatsApp Business API will post a notification through your Webhook. Use the media ID found in the notification to store the media in WhatsApp Business API client.

Request

GET /v1/media/media-id/download

Response

HTTP response

You should receive a response indicating the API request is being processed.

{
  "media_items": [
      {
          "id": media-id
      }
  ],
  "meta": {
      "api_status": "stable",
      "version": "3.0.0.0"
  }
}

Webhook notifications

Since the API request works asynchronously, once the store command is complete, the WhatsApp Business API client will post a notification to the callback server in the following format.

{
  "media_items": [
    {
      "image": {
        "id": media-id
        "mime_type": mime-type
        "sha256": hash
        "status": "downloaded"
      },
      "type": media-type
    }
  ]
}

Errors

Errors Returned in Response

If the API request fails to initiate storing a file, an error will be returned in the HTTP response.

{
  "meta": {
      "api_status": "stable",
      "version": "3.0.0.0"
  },
  "errors": [
      {
          "code": 1006,
          "title": "Resource not found",
          "details": "URL path not found."
      }
  ]
}

Completion Failure

If the store fails to complete, an error will be returned in the Webhook notification.

{
  "media_items": [
    {
      "errors": [
        {
          "code": 400,
          "details": "Media not found in the datastore.",
          "title": "Parameter not valid"
        }
      ],
      media-type: {
        "id": media-id
        "mime_type": mime-type
        "sha256": hash
        "status": "downloaded"
      },
      "type": media-type
    }
  ]
}