POST
/point-acquire-rule/Create point acquisition rules
You can create a new point acquisition rule.
| Attributes | Type | Required | Description |
|---|---|---|---|
| name | string | yes | A point acquire rule name. |
| product_event | integer | no | A unique identifier for the product event type which is given by User.com |
| end_date | datetime | no | A DateTime when a point acquires rule to stop working. |
| earning_type | integer | yes | A unique identifier for an earning type. |
| earning_value | integer | yes | A point amount that the user receives if the rule requirements will be fulfilled. |
| max_points_daily | integer | no | A daily maximum number of points that the user can get. |
| max_points_per_transaction | integer | no | A maximum number of points that user can get per transaction. |
| max_trigger_count_interval | integer | no | A maximum number of interval days in between triggering this rule for a user. |
| max_trigger_count_value | integer | no | A maximum number of times that rule triggers for this specific user |
| products | object | no | A list of product segment ids which are given by User.com. |
| points_expiration_time | string | no | A datetime of how long the earned points are valid. |
| event | integer | no | A unique identifier for the event which is given by User.com |
| 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 standarized to "my_attribute"). An attribute has to be an integer type. |
| level_threshold | integer | no | A unique identifier for the user's customer level which is given by User.com |
Request
- CURL
- JavaScript
- PHP
- Python
curl --location --request POST 'https://<your_app_subdomain>.user.com/api/public/point-acquire-rule/' \
--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", "product_event": 1, "end_date": "2022-03-09T11:12:04.814Z", "earning_type": 0, "earning_value": 0, "max_points_daily": 0, "max_points_per_transaction": 0, "max_trigger_count_interval": 0, "max_trigger_count_value": 0, "products": {}, "points_expiration_time": "2022-03-09T11:12:04.814Z", "event": 0, "point_campaign": 0, "user_attribute": 0, "level_threshold": 0}'
var data = JSON.stringify({
name: "string",
product_event: 1,
end_date: "2022-03-09T11:12:04.814Z",
earning_type: 0,
earning_value: 0,
max_points_daily: 0,
max_points_per_transaction: 0,
max_trigger_count_interval: 0,
max_trigger_count_value: 0,
products: {},
points_expiration_time: "2022-03-09T11:12:04.814Z",
event: 0,
point_campaign: 0,
user_attribute: 0,
level_threshold: 0,
});
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-acquire-rule/"
);
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-acquire-rule/',
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", "product_event": 1, "end_date": "2022-03-09T11:12:04.814Z", "earning_type": 0, "earning_value": 0, "max_points_daily": 0, "max_points_per_transaction": 0, "max_trigger_count_interval": 0, "max_trigger_count_value": 0, "products": {}, "points_expiration_time": "2022-03-09T11:12:04.814Z", "event": 0, "point_campaign": 0, "user_attribute": 0, "level_threshold": 0}',
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-acquire-rule/"
payload = json.dumps({
"name": "string",
"product_event": 1,
"end_date": "2022-03-09T11:12:04.814Z",
"earning_type": 0,
"earning_value": 0,
"max_points_daily": 0,
"max_points_per_transaction": 0,
"max_trigger_count_interval": 0,
"max_trigger_count_value": 0,
"products": {},
"points_expiration_time": "2022-03-09T11:12:04.814Z",
"event": 0,
"point_campaign": 0,
"user_attribute": 0,
"level_threshold": 0
})
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",
"product_event": 1,
"end_date": "2022-03-09T11:12:04.814000Z",
"earning_type": 0,
"earning_value": 0,
"max_points_daily": 0,
"max_points_per_transaction": 0,
"max_trigger_count_interval": 0,
"max_trigger_count_value": 0,
"products": {},
"points_expiration_time": "2022-03-09T11:12:04.814000Z",
"event": 1,
"point_campaign": 1,
"user_attribute": 1,
"level_threshold": 1
}