curl --request GET \
--url 'https://api.mageloyalty.com/v1/earning-rules?filter[customer_identifier]=6789012345' \
--header 'Authorization: <api-key>'
const response = await fetch(
"https://api.mageloyalty.com/v1/earning-rules?filter[customer_identifier]=6789012345",
{
method: "GET",
headers: {
Authorization: "<api-key>",
},
}
);
const data = await response.json();
import requests
response = requests.get(
"https://api.mageloyalty.com/v1/earning-rules",
headers={"Authorization": "<api-key>"},
params={"filter[customer_identifier]": "6789012345"},
)
data = response.json()
<?php
$ch = curl_init("https://api.mageloyalty.com/v1/earning-rules?filter[customer_identifier]=6789012345");
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
],
]);
$data = json_decode(curl_exec($ch), true);
{
"data": [
{
"type": "earning_rule",
"id": "rule_abc",
"attributes": {
"name": "Points for purchase",
"description": null,
"action": "purchase",
"category": "purchase",
"is_active": true,
"points_to_give": 10,
"customer_facing_label": "Earn 10 points per £1 spent",
"call_to_action_url": null,
"created_at": "2024-01-01T00:00:00.000Z",
"updated_at": "2024-01-01T00:00:00.000Z",
"points": 15,
"base_points": 10,
"tier_boost": 1.5,
"campaign_boost": null
}
},
{
"type": "earning_rule",
"id": "rule_def",
"attributes": {
"name": "Follow on Instagram",
"description": null,
"action": "follow_on_instagram",
"category": "social",
"is_active": true,
"points_to_give": 100,
"customer_facing_label": "Earn 100 points",
"call_to_action_url": "https://instagram.com/yourbrand",
"created_at": "2024-01-01T00:00:00.000Z",
"updated_at": "2024-01-01T00:00:00.000Z",
"points": 150,
"base_points": 100,
"tier_boost": 1.5,
"campaign_boost": null
}
}
],
"meta": {
"total": 5,
"page": 1,
"per_page": 20,
"total_pages": 1,
"tier_info": {
"multiplier": 1.5,
"name": "Gold",
"mode": "all"
},
"campaign_info": null
}
}
{
"errors": [
{
"status": "401",
"title": "Unauthorized",
"detail": "Invalid or revoked API key"
}
]
}
Earning Rules
List earning rules
List all earning rules for the shop.
GET
/
v1
/
earning-rules
curl --request GET \
--url 'https://api.mageloyalty.com/v1/earning-rules?filter[customer_identifier]=6789012345' \
--header 'Authorization: <api-key>'
const response = await fetch(
"https://api.mageloyalty.com/v1/earning-rules?filter[customer_identifier]=6789012345",
{
method: "GET",
headers: {
Authorization: "<api-key>",
},
}
);
const data = await response.json();
import requests
response = requests.get(
"https://api.mageloyalty.com/v1/earning-rules",
headers={"Authorization": "<api-key>"},
params={"filter[customer_identifier]": "6789012345"},
)
data = response.json()
<?php
$ch = curl_init("https://api.mageloyalty.com/v1/earning-rules?filter[customer_identifier]=6789012345");
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
],
]);
$data = json_decode(curl_exec($ch), true);
{
"data": [
{
"type": "earning_rule",
"id": "rule_abc",
"attributes": {
"name": "Points for purchase",
"description": null,
"action": "purchase",
"category": "purchase",
"is_active": true,
"points_to_give": 10,
"customer_facing_label": "Earn 10 points per £1 spent",
"call_to_action_url": null,
"created_at": "2024-01-01T00:00:00.000Z",
"updated_at": "2024-01-01T00:00:00.000Z",
"points": 15,
"base_points": 10,
"tier_boost": 1.5,
"campaign_boost": null
}
},
{
"type": "earning_rule",
"id": "rule_def",
"attributes": {
"name": "Follow on Instagram",
"description": null,
"action": "follow_on_instagram",
"category": "social",
"is_active": true,
"points_to_give": 100,
"customer_facing_label": "Earn 100 points",
"call_to_action_url": "https://instagram.com/yourbrand",
"created_at": "2024-01-01T00:00:00.000Z",
"updated_at": "2024-01-01T00:00:00.000Z",
"points": 150,
"base_points": 100,
"tier_boost": 1.5,
"campaign_boost": null
}
}
],
"meta": {
"total": 5,
"page": 1,
"per_page": 20,
"total_pages": 1,
"tier_info": {
"multiplier": 1.5,
"name": "Gold",
"mode": "all"
},
"campaign_info": null
}
}
{
"errors": [
{
"status": "401",
"title": "Unauthorized",
"detail": "Invalid or revoked API key"
}
]
}
List all earning rules for the shop.
Query parameters
| Parameter | Type | Description |
|---|---|---|
filter[is_active] | string | Filter by active status: true or false |
filter[customer_identifier] | string | A Shopify customer ID or email. When supplied, the customer’s VIP tier multiplier is applied to each rule’s calculated points, and the tier_info meta object is populated |
sort | string | Sort field. Prefix with - for descending. Options: created_at, name. Default: -created_at |
page[number] | integer | Page number (default: 1) |
page[size] | integer | Results per page (default: 20, max: 100) |
Calculated points
Each rule returns pre-calculated points fields alongside its configuration:points— final points with any applicable VIP tier and bonus campaign multipliers appliedbase_points— the rule’s base points before multiplierstier_boost— the VIP tier multiplier applied, ornullcampaign_boost— the active bonus campaign multiplier applied, ornull
filter[customer_identifier] is supplied and that customer holds a qualifying tier.
Response meta
In addition to pagination, the top-levelmeta object includes:
| Field | Type | Description |
|---|---|---|
tier_info | object | null | Present (non-null) only when filter[customer_identifier] resolves a customer with a qualifying VIP tier. Shape: { multiplier, name, mode } |
campaign_info | object | null | The active bonus campaign, or null when none is running. Shape: { name, id } |
curl --request GET \
--url 'https://api.mageloyalty.com/v1/earning-rules?filter[customer_identifier]=6789012345' \
--header 'Authorization: <api-key>'
const response = await fetch(
"https://api.mageloyalty.com/v1/earning-rules?filter[customer_identifier]=6789012345",
{
method: "GET",
headers: {
Authorization: "<api-key>",
},
}
);
const data = await response.json();
import requests
response = requests.get(
"https://api.mageloyalty.com/v1/earning-rules",
headers={"Authorization": "<api-key>"},
params={"filter[customer_identifier]": "6789012345"},
)
data = response.json()
<?php
$ch = curl_init("https://api.mageloyalty.com/v1/earning-rules?filter[customer_identifier]=6789012345");
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
],
]);
$data = json_decode(curl_exec($ch), true);
{
"data": [
{
"type": "earning_rule",
"id": "rule_abc",
"attributes": {
"name": "Points for purchase",
"description": null,
"action": "purchase",
"category": "purchase",
"is_active": true,
"points_to_give": 10,
"customer_facing_label": "Earn 10 points per £1 spent",
"call_to_action_url": null,
"created_at": "2024-01-01T00:00:00.000Z",
"updated_at": "2024-01-01T00:00:00.000Z",
"points": 15,
"base_points": 10,
"tier_boost": 1.5,
"campaign_boost": null
}
},
{
"type": "earning_rule",
"id": "rule_def",
"attributes": {
"name": "Follow on Instagram",
"description": null,
"action": "follow_on_instagram",
"category": "social",
"is_active": true,
"points_to_give": 100,
"customer_facing_label": "Earn 100 points",
"call_to_action_url": "https://instagram.com/yourbrand",
"created_at": "2024-01-01T00:00:00.000Z",
"updated_at": "2024-01-01T00:00:00.000Z",
"points": 150,
"base_points": 100,
"tier_boost": 1.5,
"campaign_boost": null
}
}
],
"meta": {
"total": 5,
"page": 1,
"per_page": 20,
"total_pages": 1,
"tier_info": {
"multiplier": 1.5,
"name": "Gold",
"mode": "all"
},
"campaign_info": null
}
}
{
"errors": [
{
"status": "401",
"title": "Unauthorized",
"detail": "Invalid or revoked API key"
}
]
}
⌘I