POST
/global-variables/Create global variable
You can create a global variable. It’s possible to use it as a snippet tag across many email templates, chat messages, etc.
| Attributes | Type | Required | Description |
|---|---|---|---|
| author | integer | no | A unique identifier of an agent who created a global variable. A visible author. |
| integer_content | integer | no | An integer value of a global variable. |
| name | string | yes | A global variable name. |
| text_content | string | no | A text value of a global variable. Can be used to store HTML code, string, or JSON. |
| language | string | no | ISO 639-1 code of the language. |
| parent | integer | no | An id of the parent global variable. |
| custom_id | string | no | The unique identifier for the global variable which is provided by the client. |
Request
- CURL
- JavaScript
- PHP
- Python
curl -X POST -H "Authorization: Token <your_64_char_api_key>"
-H "Accept: */*; version=2" -H "Content-Type: application/json" -d '{
"name": "Some global variable"
"text_content": "January Promotions"
"author": 1
}' "https://<your_app_subdomain>.user.com/api/public/global-variables/"
var data = JSON.stringify({
"name": "Some global variable"
"text_content": "January Promotions"
});
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://<your_app_subdomain>.user.com/api/public/global-variables/");
xhr.setRequestHeader("authorization", "Token <your_64_char_api_key>");
xhr.setRequestHeader("accept", "*/*; version=2");
xhr.setRequestHeader("content-type", "application/json");
xhr.send(data);
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://<your_app_subdomain>.user.com/api/public/global-variables/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\n \"name\": \"Some global variable\"\n \"text_content\": \"January Promotions\"\n}",
CURLOPT_HTTPHEADER => array(
"Accept: */*; version=2",
"authorization: Token <your_64_char_api_key>",
"content-type: application/json"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
import requests
url = "https://<your_app_subdomain>.user.com/api/public/global-variables/"
payload = {
"name": "Some global variable",
"text_content": "January Promotions"
}
headers = {
"authorization": "Token <your_64_char_api_key>",
"content-type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.json)
Response
{
"id": 1,
"name": "Promotion Title",
"name_std": "promotion_title",
"language": null,
"integer_content": "",
"text_content": "January Promotions",
"author": 116,
"created_at":"2019-01-24T09:00:15.800900Z",
"updated_at":"2019-01-24T09:00:15.801042Z",
"author": 1,
"parent": null
},