POST/ point-acquire-rule/
Create point acquisition rules
You can create a new point acquisition rule.
Attributes
Optional unless marked required
- name
- A point acquire rule name.
- product_event
- A unique identifier for the product event type which is given by User
- end_date
- A DateTime when a point acquires rule to stop working.
- earning_type
- A unique identifier for an earning type.
- earning_value
- A point amount that the user receives if the rule requirements will be fulfilled.
- max_points_daily
- A daily maximum number of points that the user can get.
- max_points_per_transaction
- A maximum number of points that user can get per transaction.
- max_trigger_count_interval
- A maximum number of interval days in between triggering this rule for a user.
- max_trigger_count_value
- A maximum number of times that rule triggers for this specific user
- products
- A list of product segment ids which are given by User.
- points_expiration_time
- A datetime of how long the earned points are valid.
- event
- A unique identifier for the event which is given by User
- point_campaign
- A unique identifier for the point campaign which is given by User
- user_attribute
- 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
- A unique identifier for the user's customer level which is given by User
Request
- cURL
- JavaScript
- PHP
- Python
curl -X POST "https://<your_app_subdomain>.user.com/api/public/point-acquire-rule/" \
-H "Authorization: Token <your_64_char_api_key>" \
-H "Accept: */*; version=2" \
-H "Content-Type: application/json" \
-d '{
"name": "Points for a newsletter signup",
"point_campaign": 13,
"earning_type": 1,
"earning_value": 50
}'
const response = await fetch(
"https://<your_app_subdomain>.user.com/api/public/point-acquire-rule/",
{
method: "POST",
headers: {
Authorization: "Token <your_64_char_api_key>",
Accept: "*/*; version=2",
"Content-Type": "application/json",
},
body: JSON.stringify({
name: "Points for a newsletter signup",
point_campaign: 13,
earning_type: 1,
earning_value: 50,
}),
},
);
const data = await response.json();
console.log(data);
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://<your_app_subdomain>.user.com/api/public/point-acquire-rule/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Token <your_64_char_api_key>",
"Accept: */*; version=2",
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode([
"name" => "Points for a newsletter signup",
"point_campaign" => 13,
"earning_type" => 1,
"earning_value" => 50,
]),
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
import requests
response = requests.post(
"https://<your_app_subdomain>.user.com/api/public/point-acquire-rule/",
headers={
"Authorization": "Token <your_64_char_api_key>",
"Accept": "*/*; version=2",
},
json={
"name": "Points for a newsletter signup",
"point_campaign": 13,
"earning_type": 1,
"earning_value": 50,
},
)
print(response.json())
Response examples
- 201 Created
- 400 Bad Request
{"id": 3,"name": "Points for a newsletter signup","points_expiration_relative_time": null,"points_expiration_time": null,"earning_type": 1,"earning_value": "50.00","count_points_from": null,"count_points_to": null,"max_points_daily": null,"max_points_per_transaction": null,"max_trigger_count_interval": null,"max_trigger_count_value": null,"end_date": null,"product_event": null,"products": null,"point_campaign": 12,"user_attribute": null,"event": null,"event_attribute": null,"product_attribute": null,"level_thresholds": []}{"earning_type": ["This field is required."],"earning_value": ["This field is required."],"point_campaign": ["This field is required."]}Response fields
Fields returned in the 201 Created response body.
- id
- ID of the point acquisition rule.
- name
- A point acquire rule name.
- points_expiration_relative_time
- Number of hours after which points earned through this rule expire;
nullif they don't. - points_expiration_time
- A datetime of how long the earned points are valid.
- earning_type
- A unique identifier for an earning type.
- earning_value
- A point amount that the user receives if the rule requirements will be fulfilled.
- count_points_from
- Lowest price or order value that earns points with dynamic earning;
nullfor no minimum. - count_points_to
- Highest price or order value that earns points with dynamic earning;
nullfor no maximum. - max_points_daily
- A daily maximum number of points that the user can get.
- max_points_per_transaction
- A maximum number of points that user can get per transaction.
- max_trigger_count_interval
- A maximum number of interval days in between triggering this rule for a user.
- max_trigger_count_value
- A maximum number of times that rule triggers for this specific user
- end_date
- A DateTime when a point acquires rule to stop working.
- product_event
- A unique identifier for the product event type which is given by User
- products
- A list of product segment ids which are given by User.
- point_campaign
- A unique identifier for the point campaign which is given by User
- user_attribute
- A standardized name for the user attribute (e.g. "My attribute" is standarized to "my_attribute"). An attribute has to be an integer type.
- event
- A unique identifier for the event which is given by User
- event_attribute
- ID of the event attribute that holds the order value for dynamic earning;
nullif not used. - product_attribute
- ID of the product attribute that holds the price for dynamic earning;
nullif not used. - level_thresholds
- IDs of the customer levels a contact needs to earn points from this rule; empty for everyone.
note
Errors that can come from any endpoint (401, 429, 500, 502, 504) are described in HTTP response codes.