API Oficial Template com variável (Hub)
Envia uma mensagem template COM variável pela API oficial, estando previamente aprovada.
API: Oficial
Verifique aqui os Pré-Requisitos para utilizar APIs
Endpoint
https://{{BACKEND_URL}}/api/messages/sendOfficial
Método
POST
Autenticação
Bearer {seutokenaqui}
Payload
{
"number": "",
"name": "vars_001",
"language": "pt_BR",
"template": [
{
"type": "text",
"parameter_name": "variavel 1",
"text": "valor 1"
},
{
"type": "text",
"parameter_name": "variavel 2",
"text": "Valor 2"
},
{
"type": "text",
"parameter_name": "variavel 3",
"text": "Valor 3"
}
]
}
“number”: telefone do destinatário no formato ddi ddd numero (somente números).
“name”: nome do template.
“language”: idioma.
“template”:– type: tipo da variável– parameter_name: nome da variável definido no template (key)– text: valor da variável (value) API Utilize o código em requisições HTTPS com ferramentas como cURL ou bibliotecas de integração.
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://{{BACKEND_URL}}/api/messages/sendOfficial',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"number": "",
"name": "vars_001",
"language": "pt_BR",
"template": [
{
"type": "text",
"parameter_name": "variavel 1",
"text": "valor 1"
},
{
"type": "text",
"parameter_name": "variavel 2",
"text": "Valor 2"
},
{
"type": "text",
"parameter_name": "variavel 3",
"text": "Valor 3"
}
]
}',
// "parameter_name": utilize o nome da variável definido no template
// "text": defina o valor da variável
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'Authorization: Bearer {seutokenaqui}' //Token cadastrado na conexão
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;