General Information
Variables and Their Types
One of the basic capabilities of Sailplay is working with client variables.
A variable is a key phrase that is replaced with a stored value when a message is sent.
For example, the variable $[first_name] will be automatically replaced with the recipient's name.
For any variable, a default value can be specified, which will be used if the variable is missing or its value is not set.
Also, the substitution mechanism can be implemented through conditional constructs.
Variables are supported in:
- mass Email, Push, and SMS mailings;
- trigger Email, Push, and SMS messages;
- message bodies, headers, and URLs.
Two types of variables exist in Sailplay:
- System Variables — contain general information about the client and the action being performed;
- User Variables — contain additional information about the client and are stored separately for each user.
Methods for Working with Variables
The methods in this section are intended for working with user (non-system) variables of clients.
When calling the methods, it is necessary to pass:
- application authorization data;
- the identifier of the client for whom the operation is being performed (creation / retrieval / deletion of a variable).
Creating a User Variable
Adding a new user variable is performed using the method:
/api/v2/users/custom-vars/add/
The list of variables is passed in the vars parameter in the format
key (variable name) → value (variable data)
as a JSON string.
&vars={"var_name1":"value1","var_name2":"value2"}
When passing long values (e.g., HTML code), it is recommended to pass the vars parameter in the body of a POST request.
Retrieving and Deleting Variables
Retrieving the value and deleting a variable is performed by its key (name), which is passed in the name parameter.
Methods Used
/api/v2/users/custom-vars/get/— retrieving the value of a single variable;/api/v2/users/custom-vars/get/batch/— retrieving the values of multiple variables;/api/v2/users/custom-vars/delete/— deleting a user variable.
Retrieving a List of Variables
Method:
/api/v2/users/custom-vars/list/
returns a list of all created user variables, regardless of their binding to a specific client.