$data = [
'phone' => '79995253422', // Receivers phone
'template' => 'template_name', // Template name
'namespace' => 'namespace_of_template', // Namespace of template
'language' => ['code' => 'en', 'policy' => 'deterministic'], // Language parameters
];
$json = json_encode($data); // Encode data to JSON
// URL for request POST /message
$token = '83763g87x';
$instanceId = '777';
$url = "https://api.chat-api.com/instance{$instanceId}/sendTemplate?token={$token}";
// Make a POST request
$options = stream_context_create(['http' => [
'method' => 'POST',
'header' => 'Content-type: application/json',
'content' => $json
]
]);
// Send a request
$result = file_get_contents($url, false, $options);
var request = require('request'); //bash: npm install request
// URL for request POST /message
const token = '83763g87x';
const instanceId = '777';
const url = `https://api.chat-api.com/instance${instanceId}/sendTemplate?token=${token}`;
var data = {
phone: '79995253422', // Receivers phone
template: "template_name",
namespace : "namespace_of_template",
language: {
code: "en",
policy: "deterministic"}
};
// Send a request
request({
url: url,
method: "POST",
json: data
});
// URL for request POST /message
const token = '83763g87x';
const instanceId = '777';
const url = `https://api.chat-api.com/instance${instanceId}/sendTemplate?token=${token}`;
let data = {
phone: '79995253422', // Receivers phone
template: "template_name",
namespace : "namespace_of_template",
language: {
code: "en",
policy: "deterministic"}
};
// Send a request
$.ajax(url, {
data : JSON.stringify(data),
contentType : 'application/json',
type : 'POST'
});
curl \
-d '{"phone": "79995253422","template": "template_name", "namespace" : "namespace_of_template", "language": { "code": "en", "policy": "deterministic"}}' \ # Phone and template parameters
-H "Content-Type: application/json" \ # Headers
-X POST \ # Type = POST
"https://api.chat-api.com/sendTemplate?token=83763g87x" # URL for request POST /message