Skip to main content

Integration model

Loyal Guru is API-first: any system with HTTPS access and a pair of credentials can call it. That makes the technical integration easy β€” and it makes the architectural decision easy to skip.

The decision is this: does every channel call Loyal Guru directly, or does the traffic pass through a mediation layer you control? Both work. What separates them is who absorbs change, and who is left holding the retries when something fails mid-sale.

This page covers that choice, how to split flows across synchronous, asynchronous, batch and event channels, and what obligations each option creates. It is written for architects and integration leads planning the connection. The module guides cover the calls themselves.

Where the integration logic lives​

Direct and mediated integration models between a retail ecosystem and the Loyal Guru Streaming API

Everything on the Loyal Guru side is a single API β€” https://streaming.loyal.guru, authenticated with X-Api-Key, X-Api-Secret and X-Api-Version. What changes between the two models is everything to the left of it: whether each system carries its own copy of the integration logic, or whether that logic lives in one place.

Direct or mediated​

Direct calls from each channelMediated through a gateway and middleware
CredentialsDistributed across every system, and often every terminalHeld once in the mediation layer
Contract changesEvery consumer is redeployedAbsorbed in one place; consumers keep their contract
Retries and queuesEach system implements its own, or does withoutCentralised, with a dead-letter queue for what cannot be delivered
Idempotency keysGenerated and persisted per systemGenerated and persisted once, at a layer that survives a terminal restart
Rate limitsEach channel consumes the quota blindlyShaped and prioritised across channels
TraceabilityFragmented across system logsOne correlation ID across the whole flow
Added latencyNoneOne extra hop

The trade-off is explicit: mediation costs you a hop and buys you every other row.

Why mediation is the default recommendation​

In a retail estate, the POS is the most expensive and slowest system to change. It is deployed across hundreds of stores, its release windows are narrow, and its vendor may not be you.

When the integration logic lives inside the POS, every schema change, every new field and every retry policy becomes a store-wide deployment. When it lives in middleware, the POS keeps calling the same internal contract and the change stops at the mediation layer.

The same reasoning applies to credentials. A key distributed to every terminal is a key you cannot rotate quickly.

When a direct call is the right call​

There is a bounded exception, and it is worth stating precisely because it is often stretched too far.

A direct call is justified when the extra hop would be perceptible to the customer standing at the checkout β€” typically reading customer data and simulating a cart, where the result is needed before the cashier can continue. Latency there is a business cost, not an architectural preference.

What is not exempt is everything downstream of that. If the confirmation of a cart is sent directly from the POS, the obligations do not disappear β€” they move to the POS:

  • generating and persisting the idempotency key so a retry after a timeout is safe
  • holding a local queue for confirmations that could not be delivered
  • retrying with back-off, and escalating what never succeeds
  • compensating when a sale is later cancelled or returned

That is a real amount of engineering to put inside a POS application. Most projects that start with "the POS will call directly, it is simpler" end up rebuilding exactly this list, one incident at a time.

The practical outcome is usually hybrid: latency-bound reads and simulations go direct; anything that must persist goes through the mediation layer.

Splitting the flows​

The question that decides which channel a flow belongs to is not technical. It is operational: does the cashier wait for it?

ChannelUse it whenDoes it block the sale?Typical flows
Synchronous request/responseThe answer is needed to continueYesIdentify the Customer, simulate a cart, validate a voucher
Asynchronous (queue and worker)The result must persist, but nobody is waiting for itNoConfirming a cart after payment, deferred effects
Batch filesVolume matters more than immediacyNoProduct catalog, stores, taxonomies, initial customer loads
WebhooksLoyal Guru has something to tell your systemsNoLoyalty events pushed to a CDP, CRM or marketing automation

Two consequences follow from that table.

Anything in the "yes" column needs a fallback. A synchronous call on the critical path of a sale is a dependency of that sale. If it cannot answer, the sale still has to complete. Reliability covers how to build that.

Simulating and confirming are different problems. The simulation is what the cashier sees and therefore has to be fast. The confirmation is what has to be true afterwards and therefore has to be durable. Designing both as one blocking synchronous call inherits the worst property of each.

What the mediation layer owns​

If you do put a mediation layer in place, these are the responsibilities that belong there rather than in each channel:

ResponsibilityWhat it means in practice
Credential custodyOne set of keys per environment, rotatable without touching the stores
Contract translationChannels keep their internal formats; the layer maps them to the API
Idempotency keysGenerated at the origin of the operation and persisted, so a retry carries the same key
Retries and back-offOne policy, applied consistently, honouring Retry-After
Queue and dead-letter queueNothing is lost silently; what cannot be delivered is visible and replayable
Rate shapingBatch traffic does not consume the quota that checkout needs
Correlation IDsOne identifier spanning channel, middleware and API, so an incident can be traced end to end
Degraded-mode policyDecided once, applied everywhere, instead of improvised per channel

Non-functional baseline​

These apply regardless of which model you choose:

ItemBaseline
TransportHTTPS to https://streaming.loyal.guru
AuthenticationX-Api-Key, X-Api-Secret and X-Api-Version headers
Rate limitsTier 1 (critical) 60 requests/second Β· Tier 2 (moderate) 25 Β· Tier 3 (low) 10
Exceeding the limitHTTP 429 Too Many Requests with a Retry-After header
Server errorsBack off from 1 second, increasing exponentially up to 32 seconds
EnvironmentsSeparate credentials per environment; never test against production data

Cart evaluation endpoints β€” POST /carts/realtime and POST /carts/simulate β€” are Tier 1. For global caps, burst limits and monthly usage, check your service agreement or contact your account manager.

Before you build​

Every flow you are going to implement should be written down before it is coded: which system starts it, whether it blocks the sale, what happens when it fails, and who owns it. The Flow mapping template gives you the fields to fill in, and the Integration checklist places that exercise in the implementation sequence.

  • API Reference β€” endpoint catalog and schemas
  • HTTP behavior β€” authentication, idempotency, rate limits and error format

Troubleshooting​

SymptomLikely causeWhat to check
429 under normal loadBatch and checkout traffic share the same quotaSeparate the credentials or shape the batch traffic in the mediation layer
Duplicate effects after a network glitchThe retry did not carry the original idempotency keyThe key must be generated where the operation starts, not where the request is sent
A key rotation requires a store deploymentCredentials live in the terminalsMove credential custody to the mediation layer
Incidents that cannot be traced past the middlewareNo correlation ID propagatedAttach one at the channel and carry it through every hop