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.
| Field | What it is |
|---|---|
id | Your identifier for this event occurrence. Use one that your system can reproduce β it is what a retry has to carry |
customer_id or customer_code | Who the event belongs to. Mutually exclusive; use one |
slug | The code of the event definition in Loyal Guru β fishing_course, profile_completed. It has to exist before events referencing it are sent |
data | A free-form object with the attributes of this occurrence: {"prey_count": 25, "location": "BCN"} |
created_at | When 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 response | What it tells you |
|---|---|
ingested_at | When Loyal Guru received it, as opposed to created_at |
score, score_available | The 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 |
customer | A 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β
| Action | Endpoint | Rate limit tier |
|---|---|---|
| Create an event | POST /custom_events | Tier 2 (Moderate) |
| List events | GET /custom_events | Tier 3 (Low) |
| Get one event | GET /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.
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_atis 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
datastable 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β
| Symptom | What to check |
|---|---|
400 on create | Required fields, and whether slug matches an event definition that exists in this Company. |
| Event accepted, no points | The earning rule for that slug: status, date window, conditions against the data attributes. |
202 instead of 201 | A duplicated request with the same id. The original was already processed. |
| Rule condition never matches | Attribute names in data against what the rule references β including case and type. |
| Event attributed to the wrong customer | Whether customer_id and customer_code are being mixed across channels for the same person β see Customers. |
| Challenge progress not advancing | Whether the challenge is driven by this slug, and whether created_at falls inside the challenge window. |