Earning Rules
Award a custom action
Record a custom action completion and award points to a customer from your own systems.
POST
Custom actions let you award points for things that happen outside Shopify — a mobile app install, an in-app purchase, an event check-in, a completed survey, or any milestone your own systems track.
You create a custom action once in the Mage admin (Loyalty Program → Earning rules → Advanced → Custom Action), give it a stable action key, then call this endpoint from your backend whenever the action happens. You can also trigger it with no code using the Shopify Flow action.
Points come from the rule’s configured amount, with any applicable VIP tier and bonus campaign multipliers applied automatically. Each rule is either once per customer or unlimited, depending on how you configured it.
If the loyalty program is disabled, or test mode is filtering this customer, the request still succeeds with
Example
Custom actions are available on the Growth plan and above. The customer must already be a loyalty member — a call for someone who is not enrolled returns
404.Request body
| Field | Type | Required | Description |
|---|---|---|---|
action_key | string | Yes | The action key of the custom rule. Lowercase letters, numbers, and underscores only |
customer_id | string | Conditional | Shopify customer ID (numeric). Required if customer_email is not provided |
customer_email | string | Conditional | Customer email. Required if customer_id is not provided |
idempotency_key | string | No | A unique value for this specific completion. A repeat with the same key returns the original award instead of granting again |
metadata | object | No | Free-form context stored alongside the earning record |
Idempotency
If you pass anidempotency_key, a repeated request with the same key for the same rule returns the original award with 200 OK and replayed: true — points are never granted twice. For an unlimited rule where each completion should count once, set the key to a stable id for that completion, such as an event id or order id.
Validations
- Customer must exist and not be excluded from the loyalty program
- A custom action with the given
action_keymust exist and be active - For a once-per-customer rule, the customer must not have already been awarded this action
Response
Returns201 Created on success, or 200 OK for an idempotent replay.
When the rule has an approval delay configured,
status is pending, points_given_at is null, points_due_at reflects when the points will be approved, and points_balance excludes the pending points until then.200 OK but no points are awarded:
Errors
| Status | Scenario |
|---|---|
400 | action_key missing or invalid, neither customer_id nor customer_email provided, or invalid JSON |
403 | Customer is excluded from the loyalty program |
404 | No active custom action matches the action_key, or the customer is not a loyalty member |
409 | A once-per-customer rule has already been awarded to this customer |
429 | Rate limit exceeded (6 requests/second) |
409 response:
Trigger from Shopify Flow
If you would rather not write code, add the Award Custom Action action to any Shopify Flow workflow and set:- Action key — the same key from the rule’s setup page
- Customer — map a customer from the workflow’s trigger
- Idempotency key (optional) — leave blank to use the Flow run id automatically, so a retried run never awards twice