PUT
/point-campaign/:id/Update or create point campaign
You can update a specific point campaign or create if it doesn't exist.
| Attributes | Type | Required | Description |
|---|---|---|---|
| id | integer | no | A unique identifier for the point campaign which is given by User.com |
| name | string | yes | A point campaign name. |
| start_date | datetime | no | A datetime when point campaign starts (in UNIX format). |
| end_date | datetime | no | A datetime when point campaign ends (in UNIX format). |
| created_at | datetime | no | A datetime of point campaign creation. |
| status | integer | no | A point campaign status: Draft = 1, Pending = 2, Active = 3, Finished = 4 |
| assigned_events | integer | no | A counted value based on events assigned to the Point Acquire Rule and Point Exchange Rule. |
| assigned_product_events | integer | no | A counted value based on product events assigned to the Point Acquire Rule and Point Exchange Rule. |
| revenue_goal | integer | no | A sum from all transactions (points) generated by users. |
| query_map | object | no | A valid JSON object with a definition of Engagement groups (filters). |
Request
- CURL
- JavaScript
- PHP
- Python
curl --location --request PUT 'https://<your_app_subdomain>.user.com/api/public/point-campaign/1/' \
--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", "start_date": "2022-03-09T13:30:58.496Z", "end_date": "2022-03-09T13:30:58.496Z", "assigned_events": [ 0 ], "assigned_product_events": [ 0 ], "revenue_goal": 0, "query_map": {}}'
var data = JSON.stringify({
name: "string",
start_date: "2022-03-09T13:30:58.496Z",
end_date: "2022-03-09T13:30:58.496Z",
assigned_events: [0],
assigned_product_events: [0],
revenue_goal: 0,
query_map: {},
});
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function() {
if (this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open(
"PUT",
"https://<your_app_subdomain>.user.com/api/public/point-campaign/1/"
);
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-campaign/1/',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_POSTFIELDS =>'{ "name": "string", "start_date": "2022-03-09T13:30:58.496Z", "end_date": "2022-03-09T13:30:58.496Z", "assigned_events": [ 0 ], "assigned_product_events": [ 0 ], "revenue_goal": 0, "query_map": {}}',
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-campaign/1/"
payload = json.dumps({
"name": "string",
"start_date": "2022-03-09T13:30:58.496Z",
"end_date": "2022-03-09T13:30:58.496Z",
"assigned_events": [
0
],
"assigned_product_events": [
0
],
"revenue_goal": 0,
"query_map": {}
})
headers = {
'accept': 'application/json',
'Content-Type': 'application/json',
'Authorization': 'Token <your_64_char_api_key>',
'Accept': '*/*; version=2'
}
response = requests.request("PUT", url, headers=headers, data=payload)
print(response.text)
Response
{
"id": 1,
"name": "string",
"start_date": "2022-03-09T13:30:58.496000Z",
"end_date": "2022-03-09T13:30:58.496000Z",
"created_at": "2022-03-09T13:56:21.520067Z",
"status": 1,
"assigned_events": [0],
"assigned_product_events": [0],
"revenue_goal": 0,
"query_map": {}
}