Search code examples
facebookfacebook-graph-apipostmanwhatsapp

When creating a template in whatsapp cloud api it is always rejected


I am trying to create a template from postman by sending this object:

{
    "name": "listado_productos",
    "language": "es",
    "category": "TRANSACTIONAL",
    "components": [
        {
            "type" : "HEADER",
            "format": "document",
            "example": {
                "header_handle": [
                    "https://drive.google.com/file/d/1CcTpDZL3p0ltMFhIKU9Vhz1LWG0bQFpN/view?usp=share_link"
                ]}
        },
        {
            "type": "BODY",
            "text": "Buenas tardes, acá le enviamos el nuevo listado de precios. Muchas gracias"
        },
        {
            "type": "FOOTER",
            "text": "ABS."
        }
    ]
}

If I try an example from the official business-management-api guide, it also rejects it for non-compliance with terms and conditions.

"name": "promotional_message",
  "language": "en_US",
  "category": "TRANSACTIONAL",
  "components": [{
           "type":"BODY",
           "text":"Hi {{1}}, get an extra 10% off every order above $300.",
           "example":{"body_text":[["Sonia"]]}
         },
         {
           "type":"HEADER",
           "format":"TEXT",
           "text": "Bonus Tuesday starts now!"
         },
         {
           "type":"FOOTER",
           "text":"Not interested? Tap Stop promotions"
         },
         {
           "type":"BUTTONS",
           "buttons":[{"type":"QUICK_REPLY", "text": "Shop now"},
            {"type":"QUICK_REPLY", "text": "Stop promotions"}]
         }]  

The response is that it is rejected for being duplicate or not complying with WhatsApp Busiess Api terms and services but it is not true, I read the terms and conditions and the file / message format complies. Does anyone identify the problem?


Solution

  • example.header_handle has to be a handle generated using Facebook Resumable Upload API:

    (Pseudo-code follows)

    uploadSessionId = POST https://graph.facebook.com/v16.0/535136398713733/uploads?
        file_length={fileSize}&
        file_type={fileMimeType}&
        access_token={accessToken}
    
    handle = POST https://graph.facebook.com/v16.0/{uploadSessionId} 
        with header["Authorization"] = "OAuth {accessToken}"
        with body = {fileContent}
    
    ...
    {
        "type" : "HEADER",
        "format": "document",
        "example": {
            "header_handle": ["{handle}"]}
        }
    }
    

    (As a side note, using the documented example.header_url (instead of example.header_handle) causes Internal Server Error on Facebook side).