curl --request GET \
--url https://api.mageloyalty.com/v1/customers/6789012345/earning-history \
--header 'Authorization: <api-key>'
curl --request GET \
--url 'https://api.mageloyalty.com/v1/customers/6789012345/earning-history?filter[status]=approved&sort=-points_given_at&page[number]=1&page[size]=20' \
--header 'Authorization: <api-key>'
const params = new URLSearchParams({
"filter[status]": "approved",
sort: "-points_given_at",
"page[number]": "1",
"page[size]": "20",
});
const response = await fetch(
`https://api.mageloyalty.com/v1/customers/6789012345/earning-history?${params}`,
{
method: "GET",
headers: { Authorization: "<api-key>" },
}
);
const data = await response.json();
import requests
response = requests.get(
"https://api.mageloyalty.com/v1/customers/6789012345/earning-history",
headers={"Authorization": "<api-key>"},
params={
"filter[status]": "approved",
"sort": "-points_given_at",
"page[number]": 1,
"page[size]": 20,
},
)
data = response.json()
<?php
$query = http_build_query([
"filter[status]" => "approved",
"sort" => "-points_given_at",
"page[number]" => 1,
"page[size]" => 20,
]);
$ch = curl_init("https://api.mageloyalty.com/v1/customers/6789012345/earning-history?$query");
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["Authorization: <api-key>"],
]);
$data = json_decode(curl_exec($ch), true);
{
"data": [
{
"type": "earning_history_entry",
"id": "entry_abc",
"attributes": {
"earning_rule_id": "rule_abc",
"action": "purchase",
"points": 150,
"base_points": 100,
"points_multiplier": 1.5,
"status": "approved",
"order_id": "5678901234",
"order_number": "#1042",
"points_due_at": null,
"points_given_at": "2024-06-01T12:05:00.000Z",
"points_expiry_at": null,
"created_at": "2024-06-01T12:00:00.000Z",
"updated_at": "2024-06-01T12:05:00.000Z"
}
}
],
"meta": {
"total": 12,
"page": 1,
"per_page": 20,
"total_pages": 1
}
}
{
"errors": [
{
"status": "404",
"title": "Not Found",
"detail": "Customer '6789012345' not found"
}
]
}
Customers
List earning history
List a customer’s point earning history.
GET
/
v1
/
customers
/
{identifier}
/
earning-history
curl --request GET \
--url https://api.mageloyalty.com/v1/customers/6789012345/earning-history \
--header 'Authorization: <api-key>'
curl --request GET \
--url 'https://api.mageloyalty.com/v1/customers/6789012345/earning-history?filter[status]=approved&sort=-points_given_at&page[number]=1&page[size]=20' \
--header 'Authorization: <api-key>'
const params = new URLSearchParams({
"filter[status]": "approved",
sort: "-points_given_at",
"page[number]": "1",
"page[size]": "20",
});
const response = await fetch(
`https://api.mageloyalty.com/v1/customers/6789012345/earning-history?${params}`,
{
method: "GET",
headers: { Authorization: "<api-key>" },
}
);
const data = await response.json();
import requests
response = requests.get(
"https://api.mageloyalty.com/v1/customers/6789012345/earning-history",
headers={"Authorization": "<api-key>"},
params={
"filter[status]": "approved",
"sort": "-points_given_at",
"page[number]": 1,
"page[size]": 20,
},
)
data = response.json()
<?php
$query = http_build_query([
"filter[status]" => "approved",
"sort" => "-points_given_at",
"page[number]" => 1,
"page[size]" => 20,
]);
$ch = curl_init("https://api.mageloyalty.com/v1/customers/6789012345/earning-history?$query");
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["Authorization: <api-key>"],
]);
$data = json_decode(curl_exec($ch), true);
{
"data": [
{
"type": "earning_history_entry",
"id": "entry_abc",
"attributes": {
"earning_rule_id": "rule_abc",
"action": "purchase",
"points": 150,
"base_points": 100,
"points_multiplier": 1.5,
"status": "approved",
"order_id": "5678901234",
"order_number": "#1042",
"points_due_at": null,
"points_given_at": "2024-06-01T12:05:00.000Z",
"points_expiry_at": null,
"created_at": "2024-06-01T12:00:00.000Z",
"updated_at": "2024-06-01T12:05:00.000Z"
}
}
],
"meta": {
"total": 12,
"page": 1,
"per_page": 20,
"total_pages": 1
}
}
{
"errors": [
{
"status": "404",
"title": "Not Found",
"detail": "Customer '6789012345' not found"
}
]
}
List a customer’s point earning history. The
identifier can be a Shopify customer ID or email.
Query parameters
| Parameter | Type | Description |
|---|---|---|
filter[status] | string | Filter by status: pending, approved, rejected |
sort | string | Sort field. Prefix with - for descending. Options: created_at, points, points_given_at. Default: -created_at |
page[number] | integer | Page number (default: 1) |
page[size] | integer | Results per page (default: 20, max: 100) |
Response
Errors
| Status | Scenario |
|---|---|
404 | Customer not found |
429 | Rate limit exceeded (6 requests/second) |
curl --request GET \
--url https://api.mageloyalty.com/v1/customers/6789012345/earning-history \
--header 'Authorization: <api-key>'
curl --request GET \
--url 'https://api.mageloyalty.com/v1/customers/6789012345/earning-history?filter[status]=approved&sort=-points_given_at&page[number]=1&page[size]=20' \
--header 'Authorization: <api-key>'
const params = new URLSearchParams({
"filter[status]": "approved",
sort: "-points_given_at",
"page[number]": "1",
"page[size]": "20",
});
const response = await fetch(
`https://api.mageloyalty.com/v1/customers/6789012345/earning-history?${params}`,
{
method: "GET",
headers: { Authorization: "<api-key>" },
}
);
const data = await response.json();
import requests
response = requests.get(
"https://api.mageloyalty.com/v1/customers/6789012345/earning-history",
headers={"Authorization": "<api-key>"},
params={
"filter[status]": "approved",
"sort": "-points_given_at",
"page[number]": 1,
"page[size]": 20,
},
)
data = response.json()
<?php
$query = http_build_query([
"filter[status]" => "approved",
"sort" => "-points_given_at",
"page[number]" => 1,
"page[size]" => 20,
]);
$ch = curl_init("https://api.mageloyalty.com/v1/customers/6789012345/earning-history?$query");
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ["Authorization: <api-key>"],
]);
$data = json_decode(curl_exec($ch), true);
{
"data": [
{
"type": "earning_history_entry",
"id": "entry_abc",
"attributes": {
"earning_rule_id": "rule_abc",
"action": "purchase",
"points": 150,
"base_points": 100,
"points_multiplier": 1.5,
"status": "approved",
"order_id": "5678901234",
"order_number": "#1042",
"points_due_at": null,
"points_given_at": "2024-06-01T12:05:00.000Z",
"points_expiry_at": null,
"created_at": "2024-06-01T12:00:00.000Z",
"updated_at": "2024-06-01T12:05:00.000Z"
}
}
],
"meta": {
"total": 12,
"page": 1,
"per_page": 20,
"total_pages": 1
}
}
{
"errors": [
{
"status": "404",
"title": "Not Found",
"detail": "Customer '6789012345' not found"
}
]
}
⌘I