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
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
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. The points and points_balance fields are minor currency units on store-credit shops, and the response carries loyalty_mode and currency. On store-credit shops it also includes credit_earned and credit_balance companions (major-unit decimal strings), which are absent in points mode. See Loyalty modes.
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
Example
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