PATCH/ point-exchange-rule/ :id/
Update point exchange rule
You can update a specific point exchange rule.
Attributes
Optional unless marked required
- name
- A point exchange rule name.
- amount
- An amount
- end_date
- A DateTime when point campaign ends
- max_daily_use_count
- A daily maximum number of an exchange rule usage.
- 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
- perk
- An object with additional user benefits, e.g. coupon or a discount.
- 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 standardized to "my_attribute"). An attribute has to be an integer type.
- level_threshold
- A unique identifier for the customer level which is given by User
Request
- cURL
- JavaScript
- PHP
- Python
curl -X PATCH "https://<your_app_subdomain>.user.com/api/public/point-exchange-rule/:id/" \
-H "Authorization: Token <your_64_char_api_key>" \
-H "Accept: */*; version=2" \
-H "Content-Type: application/json" \
-d '{
"name": "10 EUR voucher",
"point_campaign": 13,
"amount": 40,
"perk": {
"name": "10 EUR voucher"
}
}'
const response = await fetch(
"https://<your_app_subdomain>.user.com/api/public/point-exchange-rule/:id/",
{
method: "PATCH",
headers: {
Authorization: "Token <your_64_char_api_key>",
Accept: "*/*; version=2",
"Content-Type": "application/json",
},
body: JSON.stringify({
name: "10 EUR voucher",
point_campaign: 13,
amount: 40,
perk: {
name: "10 EUR voucher",
},
}),
},
);
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-exchange-rule/:id/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_HTTPHEADER => [
"Authorization: Token <your_64_char_api_key>",
"Accept: */*; version=2",
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode([
"name" => "10 EUR voucher",
"point_campaign" => 13,
"amount" => 40,
"perk" => [
"name" => "10 EUR voucher",
],
]),
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;
import requests
response = requests.patch(
"https://<your_app_subdomain>.user.com/api/public/point-exchange-rule/:id/",
headers={
"Authorization": "Token <your_64_char_api_key>",
"Accept": "*/*; version=2",
},
json={
"name": "10 EUR voucher",
"point_campaign": 13,
"amount": 40,
"perk": {
"name": "10 EUR voucher",
},
},
)
print(response.json())
Response examples
- 200 OK
- 404 Not Found
{"id": 6,"name": "10 EUR voucher","amount": 40,"end_date": null,"max_daily_use_count": null,"max_trigger_count_interval": null,"max_trigger_count_value": null,"product_event": null,"point_campaign": 12,"user_attribute": null,"event": null,"level_thresholds": [],"reward": {"type": "10 EUR voucher"}}{
"detail": "No PointExchangeRule matches the given query."
}
Response fields
Fields returned in the 200 OK response body.
- id
- ID of the point exchange rule.
- name
- A point exchange rule name.
- amount
- An amount
- end_date
- A DateTime when point campaign ends
- max_daily_use_count
- A daily maximum number of an exchange rule usage.
- 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
- product_event
- Product event type that spends the points automatically when the contact triggers it, for example
2(purchase);nullif none. - 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 standardized to "my_attribute"). An attribute has to be an integer type.
- event
- ID of the event that spends the points automatically when the contact triggers it;
nullif none. - level_thresholds
- IDs of the customer levels a contact needs to use this rule; empty for everyone.
- reward
- What the contact gets for the points.
- reward.
type - Reward type:
0amount discount,1percentage off,2free shipping,3free product,4coupon code,5create event or6API.
- reward.
note
Errors that can come from any endpoint (401, 429, 500, 502, 504) are described in HTTP response codes.