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
GETrequests 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
| Domain | What arrives in Tienda |
|---|---|
categories | The category tree, with translations. A category the POS drops is hidden. |
products | Products with options, prices, images, specifications and stock mutations. |
assets | A retry sweep for product images whose download failed. |
inventory_levels | The POS stock count per product. The POS count is the one that counts. |
customers | Contacts, 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. |
orders | Orders with lines, payments and delivery. |
coupons | Coupons. |
gift_cards | Gift cards, with their ledger. See below for the limit. |
loyalty_accounts | Loyalty balances and their transactions. |
loyalty_settings | The programme rules of the POS. |
register_shifts | Cash drawer sessions, as history only. |
subscriptions | Standing orders, listed under Subscriptions as read only, and counted in the subscription statistics. |
pages, menus | Website pages and menus, mirrored into the shop's website. |
site | Shop front name, logo, palette, contact details, opening hours, the webshop on/off switch, footer menu and the home page. |
deletions | Tombstones 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.
| Domains | When |
|---|---|
| Orders (with payments), stock levels | every minute |
| Categories and products | every minute |
| Customers | every 2 minutes |
| Coupons, gift cards, loyalty, register shifts, standing orders, tombstones | every 2 minutes |
| Pages, menus, site | every 5 minutes, always read whole |
| Full sweeps | nightly, 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 withdomain,external_id,action,payload,occurred_at. - It carries
X-POS-TimestampandX-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:
202with the number queued;401for a missing or wrong signature;403when the timestamp is more than 300 seconds off;404when no shop accepts pushes.
The settings page
A shop administrator opens Settings, POS sync. The fields:
| Field | Meaning |
|---|---|
| POS address | The web address of the POS. The POS picks its company from the host. |
| API key | The POS's sync key. Stored encrypted and never shown again. |
| POS company id | Sent with every call. |
| Push | Accept push messages; shows the URL and secret to enter in the POS. |
| Use the POS opening hours | On (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.