Add Contact List Variable
The Add Contact List Variable method allows you to add a variable for all contacts in the specified list.
Important! More details about all standard service variables can be found here.
Request
IMPORTANT: Do not send more than 10 concurrent API requests.
Body Example
{
"contactListId": "YOUR_CONTACT_LIST_ID",
"variables": [
{
"name": "newVariableName1",
"type": "ENUM_DATE"
},
{
"name": "newVariableName2",
"type": "ENUM_STRING"
}
]
}
Parameters
| Title | Type | Default | Description |
|---|---|---|---|
|
contactListId required
|
string |
ID of the contact list to which you want to add the new variable. |
|
|
variables required
|
array |
Details of variables |
|
|
variables.name required
|
string |
Variable name in lowerCamelCase format |
|
|
variables.type required
|
string |
Type of variable (ENUM_STRING | ENUM_DATE):
|
Response
{
"result": true
}
Parameters
| Title | Type | Description |
|---|---|---|
|
result |
boolean |
The value indicates that the variable was successfully added:
|
Method Errors
{
"errors": ["Error description text"],
"result": false
}
| Error |
|---|
|
“Maximum count of records per transaction is 100, current {n}” |
|
“Argument contactListId must be a non-empty string” |
|
“name of variable must be a string” |
|
“name of variable can not be empty” |
|
“variable \”{name}\” is reserved and can not be added as custom variable” |
|
“invalid name of variable {name}” |
|
“invalid variable type {type}” |
|
“Allowed rejectType is {allowed}, but {rejectType} given” |
|
“List with id {contactListId} not found!” |
|
“Variable {name} already exists in list {contactListId}” |
|
“Invalid authorization token!” |
|
“Internal server error” |
|
“Bad Request” |
|
“no matches found for access token {accessT oken}” |
|
“user {id} not enabled” |
|
“no data found for key {userId}” |
|
“access token check failed for key\/secret $key\/$accessToken” |
|
“Argument {argument} required” |
Code Examples
$accessToken = "YOUR_API_KEY";
$url = 'https://api.wooxy.com/v3/contact-list/variables/add';
$body = json_encode([
'contactListId' => 'YOUR_CONTACT_LIST_ID',
'variables' => [
[
"name" => "newVariableName1",
"type" => "ENUM_DATE", // ENUM_STRING or ENUM_DATE (YYYY-MM-DD)
],
[
"name" => "newVariableName2",
"type" => "ENUM_STRING", // ENUM_STRING or ENUM_DATE (YYYY-MM-DD)
],
],
]);
/**
* Request Example
*/
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
//curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_INFILESIZE, null);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Access-Token: $accessToken",
'Content-Type: application/json',
'Content-Length: ' . strlen($body),
]);
$result = curl_exec($ch);
if ($result === false) {
echo 'cURL error:' . curl_error($ch) . PHP_EOL;
} else {
echo strval($result) . PHP_EOL;
}
curl_close($ch);