Skip to main content

Custom Events

A custom event is something a customer did that is not a purchase, sent to Loyal Guru so the program can react to it: completing a profile, attending a store event, finishing a course, taking a test drive, recycling a package, scanning a code. Purchases have their own entity β€” see Carts.

They exist because loyalty programs are rarely only about spend. Earning rules, challenges and audiences can all be driven by events, which means anything the retailer can observe about a customer becomes something the program can score.

Custom events are the one entity in the data connection with no initial load. There is no historical import: they start flowing when the flow that produces them goes live, through the API, as they happen.

The model​

Each event carries an identifier, the customer it belongs to, the definition it instantiates, and a free-form payload.

FieldWhat it is
idYour identifier for this event occurrence. Use one that your system can reproduce β€” it is what a retry has to carry
customer_id or customer_codeWho the event belongs to. Mutually exclusive; use one
slugThe code of the event definition in Loyal Guru β€” fishing_course, profile_completed. It has to exist before events referencing it are sent
dataA free-form object with the attributes of this occurrence: {"prey_count": 25, "location": "BCN"}
created_atWhen the event happened, ISO 8601. Not when you sent it

The slug is the contract. It is configured in Loyal Guru, and it is what campaign and earning-rule configuration references β€” which makes it worth agreeing the list of slugs and the shape of each data payload with the loyalty team before building the producer. A slug that arrives with inconsistent attribute names cannot be used in a condition.

curl --request POST 'https://streaming.loyal.guru/custom_events' \
--header 'X-Api-Key: YOUR_API_KEY' \
--header 'X-Api-Secret: YOUR_API_SECRET' \
--header 'X-Api-Version: 1' \
--header 'Content-Type: application/json' \
--data-raw '{
"id": "fc12345",
"customer_id": 123456789,
"slug": "fishing_course",
"data": {
"prey_count": 25,
"location": "BCN"
},
"created_at": "2026-01-01T12:00:00Z"
}'

Events can award points​

The create response is not just an acknowledgement. It carries the customer's resulting loyalty state, which is how you can tell an event was scored:

Field in the responseWhat it tells you
ingested_atWhen Loyal Guru received it, as opposed to created_at
score, score_availableThe customer's total and available points after this event
scores[]The individual point grants attached to the event, each with its loyalty_score_id and availability window
customerA summary of the customer the event was attributed to

Whether an event awards points, and how many, is campaign configuration β€” not part of the payload. If the events arrive and no points appear, the rule is where to look, not the integration. See Earning rules.

A 202 response means the event already existed from a duplicated request and the original response is still cached. Treat it as a success, not as a conflict.

Endpoints​

ActionEndpointRate limit tier
Create an eventPOST /custom_eventsTier 2 (Moderate)
List eventsGET /custom_eventsTier 3 (Low)
Get one eventGET /custom_events/{id}Tier 3 (Low)

GET /custom_events filters by id, customer_id, customer_code, slug and created_at_gt, and paginates with starting_after using the next_token_starts_after token returned on each response.

note

Legacy endpoint

/custom_entities is still available as a legacy version of the same API, and older integrations may be calling it. New work should use /custom_events.

Markdown endpoint catalog: Custom Events Β· HTTP API

Design notes​

  • Send them as they happen. An event batched overnight is behaviour the program could not react to. Custom events are the entity where the API is not just recommended but the point.
  • created_at is the business timestamp. Keep it accurate even when the delivery is delayed by a retry or an outage β€” rules and challenge windows evaluate on it.
  • Keep data stable per slug. Attribute names in the payload are what conditions reference. Adding a field is safe; renaming one silently breaks the rules built on it.
  • Don't route purchases through here. A sale is a cart. Modelling it as a custom event loses the lines, the products and everything derived from them.
  • Rate limits are per tier, and event producers are the flows most likely to burst. Check the tier table in HTTP API before wiring a high-volume source.

Troubleshooting​

SymptomWhat to check
400 on createRequired fields, and whether slug matches an event definition that exists in this Company.
Event accepted, no pointsThe earning rule for that slug: status, date window, conditions against the data attributes.
202 instead of 201A duplicated request with the same id. The original was already processed.
Rule condition never matchesAttribute names in data against what the rule references β€” including case and type.
Event attributed to the wrong customerWhether customer_id and customer_code are being mixed across channels for the same person β€” see Customers.
Challenge progress not advancingWhether the challenge is driven by this slug, and whether created_at falls inside the challenge window.