×

Including sample media in your template submission allows Meta to preview exactly how your template will look to end-users. This visual reference improves the likelihood of template approval by helping Meta reviewers understand the context and quality of the content, ensuring compliance with guidelines.

This requirement is similar to the sample media upload flow in WhatsApp Manager’s Create Template dashboard, where you preview media assets or text values before submission.

How to Use the Upload Sample API

Step-by-Step Guide

  • API Access: Ensure you have permissions and the necessary access to interact with the Upload Sample API.
  • Prepare the Media File:
    • Make sure your file type and size comply with Meta’s supported formats.
    • Validate that the media content aligns with your intended template structure.
  • Upload Sample Media File:
    • Use the Upload Sample API endpoint to submit your media file.
    • Upon success, a Media ID will be generated.
  • Create Template with Media ID: Use the Media ID in the Create Template API to submit your media template with the associated media file.

This API process replicates the familiar dashboard experience, allowing developers to streamline media template submissions programmatically while adhering to Meta’s guidelines.

POST

'https://<api_key>:<api_token>@<subdomain>/v2/accounts/<accountsid>Exotel/templates/sample?file_length=<file-size-in-bytes>&file_type=<file-type>

  • Replace <your_api_key> and <your_api_token> with the API key and token created by you.
  • Replace <your_sid> with your “Account sid”
  • Replace <subdomain> with the region of your account
    1. <subdomain> of Singapore cluster is @api.exotel.com
    2. <subdomain> of Mumbai cluster is @api.in.exotel.com

<your_api_key> , <your_api_token> and <your_sid> are available in the API settings page of your Exotel Dashboard

Listed below are the parameters for the POST API.

Parameter Name

Type

Mandatory/ Optional

Value/ Description

file_length

String

Mandatory

Size of the file in bytes

file_type

String

Mandatory

Type of the file - 

  • file_type - The file's MIME type. Valid values are: application/pdfimage/jpegimage/jpgimage/png, and video/mp4

POST DATA

Binary data of the file

HTTPResponseObject

Parameter Name

Type

Mandatory/ Optional

Value/ Description

request_id

String

Mandatory

ID of the request

method

String

Mandatory

HTTP Request Method

http_code

Integer

Mandatory

HTTP Code of the request

response

ResponseObject

Mandatory

Response for the request

ResponseObject

Parameter Name

Type

Mandatory/ Optional

Values/ Description

whatsapp

ChannelResponseObject

Optional

Channel Response for Whatsapp

ChannelResponseObject

Parameter Name

Type

Mandatory/ Optional

Values/ Description

file_handle

[]FileHandleResponseObject

Mandatory

Message Response

FileHandleResponseObject

Parameter Name

Type

Mandatory/ Optional

Value/ Description

id

String

Mandatory

Id of the file_handle

 

Please refer to our working Postman collection to access the API here - Template Management - Upload Sample

curl --location 'https://:@api.exotel.com/v2/accounts//templates/sample?file_length=1024&file_type=png' \
--header 'Content-Type: image/png' \
--data '@/home/exotel/Pictures/leaf.png'
{
   "request_id": "232e2865b3d74516b1d3fcb319493260",
   "method": "POST",
   "http_code": 200,
   "response": {
       "whatsapp": {
           "file_handle": [
               {
                   "code": 200,
                   "error_data": null,
                   "status": "success",
                   "data": {
                       "id": "4::cG5n:ARbMfw_qdKVRCAscOITqcGs_hbOmQO-2iS7aWOmJRPsMNNAfgdQPt1n5iNnELKQ:e:1731231031:3157993617821787:XXXXXX:XXXXXXXX"
                   }
               }
           ]
       }
   }
}

Once you successfully generate the Media ID, copy and use it in the Create Template API under the header_handle parameter.