Connect a POS

A shop can mirror the data of a Shiloh point of sale (POS) into Tienda: the catalogue, stock, customers, orders, coupons, gift cards, loyalty, register shifts, standing orders and the website content. The POS stays the system of record. Tienda keeps a copy that is updated all the time.

This page is for the person who connects a POS and for developers who need to know what the mirror does. The screen is described in the manual: Integrations, your Shiloh POS.

Where this was checked

The mirror was built and tested by the automated pipeline. It has run for one real shop by pull. Running it with the push switched on has not been tried. See Status and known limits.

What the mirror is

  • One way: from the POS to Tienda. Tienda only sends GET requests to the POS. Nothing in Tienda writes to the POS.
  • Read only on the POS side. The POS keeps running as before.
  • Repeatable. Every mirrored record is stored with the POS id as its external id, once per shop. Reading a record twice changes nothing, so a full resync can be run at any time and gives the same result.
  • A record changed in Tienda that the POS also owns (a mirrored page, a product name) is overwritten by the next pull. Records made in Tienda itself are not touched.

How Tienda asks

For each domain Tienda calls GET <POS address>/api/sync/<domain> with the header X-Api-Key. The shop's POS company id is sent along. Parameters: cursor, since, limit. The answer holds data (a list), next_cursor, schema_version and generated_at. Tienda follows next_cursor until it is empty. The POS contract is at schema version 2.

Defined by the POS side, and not checked in this repository: the change stamp sync_changed_at (it moves when child rows such as order lines change), the has_more flag, and the wire types (money as decimal strings, dates as YYYY-MM-DD, timestamps in UTC ISO 8601, and the shop-local time). Tienda reads data and next_cursor.

An incremental run asks for everything changed since the start of the last successful run, minus two minutes, so that a row changed during a run is not missed. Rows deleted on the POS come as tombstones from /api/sync/deletions. A domain the POS does not serve (HTTP 404) is not an error; it stays idle.

Domains

DomainWhat arrives in Tienda
categoriesThe category tree, with translations. A category the POS drops is hidden.
productsProducts with options, prices, images, specifications and stock mutations.
assetsA retry sweep for product images whose download failed.
inventory_levelsThe POS stock count per product. The POS count is the one that counts.
customersContacts, tagged as coming from the POS. A customer merged on the POS is not imported on its own; what Tienda holds for it moves to the one it was merged into.
ordersOrders with lines, payments and delivery.
couponsCoupons.
gift_cardsGift cards, with their ledger. See below for the limit.
loyalty_accountsLoyalty balances and their transactions.
loyalty_settingsThe programme rules of the POS.
register_shiftsCash drawer sessions, as history only.
subscriptionsStanding orders, listed under Subscriptions as read only, and counted in the subscription statistics.
pages, menusWebsite pages and menus, mirrored into the shop's website.
siteShop front name, logo, palette, contact details, opening hours, the webshop on/off switch, footer menu and the home page.
deletionsTombstones of rows destroyed on the POS.

Behaviour worth knowing:

  • Mirrored orders never send e-mail, print or notify. They are history.
  • Stock of a mirrored product follows the POS count. Do not let Tienda sell or reserve stock of a mirrored product on its own; the next reconcile levels it out to the POS count.
  • A deleted product is taken out of sale; a deleted order is removed; a deleted customer is removed, or kept and tagged when orders point at it.
  • The shop's opening hours can become its store hours (setting below).

What is not sent

The POS does not send its secrets (mail server, payment providers, bookkeeping and printer settings), and Tienda does not ask for them. Full gift card codes are sent only if the POS is told to send them. Without the code, Tienda keeps the raw record and skips the card.

Mirrored gift cards cannot be redeemed

Because the POS does not send full codes by default, a mirrored gift card cannot be used in Tienda. This is a known limit of release 1.1.0.

How often Tienda asks

The schedule below runs only in the production setup. Every job serves every shop that has a connection.

DomainsWhen
Orders (with payments), stock levelsevery minute
Categories and productsevery minute
Customersevery 2 minutes
Coupons, gift cards, loyalty, register shifts, standing orders, tombstonesevery 2 minutes
Pages, menus, siteevery 5 minutes, always read whole
Full sweepsnightly, between 03:00 and 04:30 server time: products, stock levels, customers, orders, then the extras

A run that finds the previous run of the same shop and domain still going is skipped. A run stuck for 15 minutes is taken over. A failing domain is recorded and does not stop the other domains or shops.

Push, optional

The POS can also push changes to POST /webhooks/pos_sync, so they show in seconds. The poll above stays on as the safety net, so a lost push costs a minute, not a record.

  • The body is {"events": [...]}, at most 500 events, each with domain, external_id, action, payload, occurred_at.
  • It carries X-POS-Timestamp and X-POS-Signature: sha256=<hex>, the HMAC-SHA256 of <timestamp>.<raw body> with the shared secret.
  • The shop is the one whose secret verifies the signature. Nothing in the request names a shop.
  • Answers: 202 with the number queued; 401 for a missing or wrong signature; 403 when the timestamp is more than 300 seconds off; 404 when no shop accepts pushes.

The settings page

A shop administrator opens Settings, POS sync. The fields:

FieldMeaning
POS addressThe web address of the POS. The POS picks its company from the host.
API keyThe POS's sync key. Stored encrypted and never shown again.
POS company idSent with every call.
PushAccept push messages; shows the URL and secret to enter in the POS.
Use the POS opening hoursOn (the default): the POS hours become the shop's store hours. Off: they are only shown in the shop. Service hours are never touched.

Buttons: Test connection, Sync now (all domains or chosen ones) and Full resync (reads everything again, which can take a while). The page shows the state of every domain, with the last success and the last error.

The same is available over the API under /api/v1/connections/pos_sync (administrators only). A POS deploy can interrupt a running pull; the pull can be repeated.