Upload Template Media

Overview

Before creating a template with an Image, Document, or Video header, you must first upload the media file using this endpoint.

It uploads the file to both AWS S3 and Meta’s media upload session, and returns:

  • h — the Meta media handle (used in header_handle when creating the template)
  • s3Url — the S3 URL (used as the top-level s3Url field when creating the template)

Endpoint

POST https://client-api.wappcloud.com/api/v1/external/templates/upload/media

Headers

HeaderDescription
x-api-key(Required) Your API Key for authentication
Authorization(Required) Bearer Token
Content-Typemultipart/form-data

Request Body (form-data)

KeyTypeRequiredDescription
fileFileYesThe media file to upload (image, document, video)

Supported File Types

Template Header TypeAccepted Formats
IMAGE.jpg, .jpeg, .png
DOCUMENT.pdf
VIDEO.mp4

Setting Up in Postman

  1. Select the Body tab
  2. Choose form-data
  3. Add a key named file, set the type to File, and select your file

Response (Success)

{
  "success": true,
  "code": 200,
  "message": "Template listed created",
  "data": {
    "h": "4:abcDEF1234567890exampleMetaHandle...",
    "s3Url": "https://your-bucket.s3.amazonaws.com/12345678/templates/550e8400-e29b-uuid.jpg"
  }
}
FieldDescription
hMeta media handle — use this as the value inside header_handle array in Create Template
s3UrlS3 URL — pass this as the top-level s3Url field in the Create Template request body

How to Use the Response

Copy both values from the response and use them when calling Create Template:

{
  "name": "my_image_template",
  "category": "MARKETING",
  "language": "en_US",
  "s3Url": "<s3Url from upload response>",
  "components": [
    {
      "type": "HEADER",
      "format": "IMAGE",
      "example": {
        "header_handle": ["<h from upload response>"]
      }
    },
    {
      "type": "BODY",
      "text": "Check out our latest collection!"
    }
  ]
}

Error Responses

400 Bad Request — No file uploaded

{
  "success": false,
  "code": 400,
  "message": "No file uploaded"
}

400 Bad Request — Invalid file size

{
  "success": false,
  "code": 400,
  "message": "File size exceeds the allowed limit"
}

401 Unauthorized

{
  "error": "Missing authToken or x-api-key"
}

Notes

  • Upload the media file before calling Create Template.
  • The h handle from Meta expires — create the template promptly after uploading.
  • Only one file per request. To use different media for different templates, upload separately each time.