POST
/point-customer-level/Create customer level
You can create a new customer level.
| Attributes | Type | Required | Description |
|---|---|---|---|
| name | string | yes | A customer level name. |
| min_threshold | integer | yes | A minimum number of points to be in a specific customer level. |
| max_threshold | integer | yes | A maximum number of points to be in a specific customer level. |
| perks | object | yes | An object with additional user's benefits, e.g. coupon or a discout. |
| point_campaign | integer | yes | A unique identifier for the point campaign which is given by User.com |
| user_attribute | string | no | A standardized name for the user attribute (e.g. "My attribute" is standardized to "my_attribute"). Attribute has to be an integer type. |
Request
- CURL
- JavaScript
- PHP
- Python
curl --location --request POST 'https://<your_app_subdomain>.user.com/api/public/point-customer-level/' \
--header 'accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Token <your_64_char_api_key>' \
--header 'Accept: */*; version=2' \
--data-raw '{ "name": "string", "min_threshold": 0, "max_threshold": 0, "perks": {}, "point_campaign": 1, "user_attribute": "attr_int"}'
var data = JSON.stringify({
name: "string",
min_threshold: 0,
max_threshold: 0,
perks: {},
point_campaign: 1,
user_attribute: "attr_int",
});
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/point-customer-level/"
);
xhr.setRequestHeader("accept", "application/json");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Token <your_64_char_api_key>");
xhr.setRequestHeader("Accept", "*/*; version=2");
xhr.send(data);
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://<your_app_subdomain>.user.com/api/public/point-customer-level/',
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 =>'{ "name": "string", "min_threshold": 0, "max_threshold": 0, "perks": {}, "point_campaign": 1, "user_attribute": "attr_int"}',
CURLOPT_HTTPHEADER => array(
'accept: application/json',
'Content-Type: application/json',
'Authorization: Token <your_64_char_api_key>',
'Accept: */*; version=2'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
import requests
import json
url = "https://<your_app_subdomain>.user.com/api/public/point-customer-level/"
payload = json.dumps({
"name": "string",
"min_threshold": 0,
"max_threshold": 0,
"perks": {},
"point_campaign": 1,
"user_attribute": "attr_int"
})
headers = {
'accept': 'application/json',
'Content-Type': 'application/json',
'Authorization': 'Token <your_64_char_api_key>',
'Accept': '*/*; version=2'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
Response
{
"id": 2,
"name": "string",
"min_threshold": 0,
"max_threshold": 0,
"perks": {},
"point_campaign": 1,
"user_attribute": "attr_int"
}