Pular para o conteúdo principal

API Oficial Template com variável (Hub)

ℹ️ Disponibilidade na Prisme

Este recurso depende do plano contratado e pode precisar de habilitação pela equipe da Prisme. Antes de seguir os passos, confirme com o suporte se ele está ativo na sua conta.

🧩 Envia uma mensagem template COM variável pela API oficial, estando previamente aprovada.

API: Oficial

Endpoint​
https://{BACKEND_URL}/api/messages/sendOfficial
Método​
POST
Autenticação​
Bearer {seutokenaqui}
Payload​
{
"number": "5511999999999",
"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”: uma entrada por variável do template, sendo que:

◽ type: tipo da variável.

◽ parameter_name: nome da variável definido no template (key).

◽ text: valor da variável (value).

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": "5511999999999",
"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;