tillwire Read the guide
Stock sync

Your system keeps the count. The shop sells from its copy.

A till system, a warehouse system or a file can be the source of truth for a store’s stock. The engine keeps a copy that it sells from, and gives its own sales back. An adapter that you run outside the engine moves the levels between the two. The engine has no vendor’s code: it gives general mechanisms, and the adapter maps your item codes and places to the store’s.

Each mechanism on this page is on the engine’s main branch, built from 26 to 28 November 2026. The live demo store does not run them yet. The few parts that are not built are named at the end of the page.

The adapter’s steps

From an empty store to a store in step.

This is the order in which an adapter starts and runs. Each step uses a mechanism that the sections below explain.

  1. The owner makes a sync key

    In the back office, the store’s owner makes a sync key for the locations that your system keeps. The key shows once. The adapter keeps it in its environment, never in a file.

  2. The adapter maps codes and places

    The adapter knows which of your item codes is which SKU of the store, and which of your places is which location.

  3. It reads the full levels first

    The adapter reads the engine’s levels of each location, 1,000 a page, and your system’s count. It sends a line for each item that differs, and it starts its cursor at the ledger’s head that the read gave.

  4. It sends each change

    Each change in your system goes to the engine as a level line, with the time of the change, your own version number and the cursor of the last engine movement your system has.

  5. It books the shop’s sales back

    The adapter reads the movements of its locations in order, after its cursor, and books each web sale and return into your system once, by its key.

  6. It compares full levels again

    Each night, and when the engine says that the cursor is too far behind, the adapter compares the full levels again and sends the differences.

  7. A stock take ends with a close

    The lines of a stock take carry one name for the take. At its end, a preview says what goes to 0, and the close sets each item that the take did not count to 0.

The engine’s guide has a quickstart for a developer with a sandbox store: the first 6 calls in order, each with its answer. They set a first level, book a sale and a receipt, send a line that the guard holds, end a stock take with its close, and read the movements after a cursor. A test runs the same calls against a built engine.

Three ways in

Changes as they happen. Full levels on a schedule.

A store uses one way or more. Each way sets levels by the same rules, so the engine treats a level from each of them the same.

By event · SSYNC.2 On main

Each change, through a queue in the adapter

The adapter sends new levels with stock.sync-set, up to 1,000 lines in one call, and keeps each call until the engine answers it. Each line gets its own answer: applied, unchanged, ignored_older, held or a refusal with its reason. A refused line never refuses the call.

On a schedule · SSYNC.8 On main

A comparison of full levels, each night and after a gap

stock.location-levels gives each level of a location with its mark, 1,000 a page. The adapter sends a line of kind reconcile for each item that differs, with the time of your system’s last change it sent. stock.sync-status counts the corrections of each key.

From a file · SSYNC.15 On main

One file for each location

A system that only writes files sends one CSV for each location, at most 20,000 lines: the item code, the level and the time of the count. A preview writes nothing and says what the import would do with each line. An import can be undone once, within 30 days. At most 8 imports run at once, and one caller runs at most 4. A busy engine answers 503 with the time to wait, and writes nothing.

The rules of a level

No sale lost. No count gone back in time.

These rules hold for each level that the engine receives, so a late, repeated or broken call cannot make the shop sell stock it does not have.

A key for your locations only · SSYNC.12 On main

It sets and reads stock there, and nothing else

Only the store’s owner makes a sync key, in the back office, and the key names your locations. It cannot change products, prices or orders, and it reads no figure of the whole store. A location it does not name answers as an unknown location.

Net of the web’s sales · SSYNC.3 On main

A count does not undo a sale it has not seen

The engine applies your level net of its own sales, cancels and returns that your system had not seen. A line that names the last movement your system has is exact. A line with only a time uses that time.

Newest wins · SSYNC.4 On main

An older level is ignored

A level older than the last one for that item and location changes nothing, whenever it arrives. Your own version number wins over the time.

Safe to send again · SSYNC.5, SSYNC.6 On main

The same call twice changes stock one time

Each call carries a key against repeats. The engine writes a call in parts of at most 50 lines, and a call that stops says how far it got. The same call again writes the rest.

Kinds of line · SSYNC.7 On main

A line says what kind of change it is

A line of kind count is a stock take that your system made: it sets the level net of the shop’s own changes after it. A line of kind receipt is a level after goods came in. A transfer comes as level lines of the two locations.

The end of a stock take · SSYNC.21 On main

Products the take did not count go to 0

The lines of one take carry the same count_id. When the take ends, stock.count-close sets each other tracked product at that location to 0, net of the shop’s sales after the take. A preview writes nothing and says how many products would go to 0. A take that is never closed changes nothing for the products it did not name, and a close of a take that named no product is refused.

Back to your system

The web’s sales go back. At your pace.

Your system must know what the online shop sold. The sync key reads the movements of its locations in order, and a webhook can tell the adapter of each one as it happens.

  1. A signed event for each movement · SSYNC.10 On mainOne stock.changed event for each sale, cancel, return or change, signed and sent again until it arrives. The store’s owner sets the webhook endpoint in the back office; a sync key makes none. Orders send their own events.
  2. A missed event, read again · SSYNC.10 On mainThe engine’s event feed keeps each event for 30 days by default, in order. When a reader is further behind, the feed says so with gap: true. The events, their webhook and this feed need a second key with events.read.
  3. A list you read when you are ready · SSYNC.11 On mainWith the sync key alone, read the movements of your locations after your cursor, oldest first, up to 1,000 a page. The sync key sees no movement number: each cursor is sealed for your key. When the cursor is behind the fold, and after the store is restored from a copy, the engine answers 409 ssync.cursor_behind, and the adapter compares the full levels again.
  4. A changed item code, in order · SSYNC.11a On mainWhen the store changes an item’s SKU, the list gives the change once, at its place among the movements. A level line for the old SKU is refused and names the new one, so the adapter changes its map and sends the level again.
Guard and watch

A sudden swing waits. A quiet source is seen.

The engine holds a change that looks wrong until a person decides, and it tells the store’s team when a source goes quiet or corrects too much.

A large change waits · SSYNC.13 On main

A sudden swing is held

A line that changes a level by at least 20 units and by more than half is held, and changes nothing. A line that gives an item its first level at a location is never held. A stock take is never held, nor the rise of a receipt. stock.sync-held lists the held lines.

A person decides · SSYNC.13 On main

Release or refuse a held line

Only a signed-in person releases or refuses a held line, never an API key. A team member with the right to change stock lists the held lines and decides on each one on the back office screen Stock, Held lines, or by the operator’s command. A person can also release or refuse all the held lines that a filter chooses, at most 20,000 in one decision, and a job applies it. The filter is a SKU prefix, a location, a key or the direction of the change, and the call is stock.sync-release-many. A stock take that the guard holds waits on the same screen as one item, and a person releases or refuses the whole close. A decision is refused when the held line changed since the list. Each decision is on record.

The guard off for one key · SSYNC.13 On main

Only the owner turns it off, on record

The guard is on for each new sync key. Only the store’s owner turns it off, or on again, for one key, on the key’s page in the back office. No API call changes it. Each change is on record with who and when. stock.sync-status gives each key guard_off, and the engine’s health check and the store check warn of each key with its guard off.

Its own limits · SSYNC.13 On main

One adapter does not slow the shop

A sync key has its own limits: 600 calls and 30,000 lines a minute by default. A set over the lines limit is refused whole, with 429 and the time to wait. Its sets pass a gate of their own, apart from the other API calls.

A status for each key · SSYNC.9 On main

See when a source went quiet

stock.sync-status gives each sync key’s last set, its sets, and its reconcile corrections at each location for the last 7 days. It marks a key silent when its last set is older than the store’s setting. A sync key sees its own alone.

Alarms in the back office · SSYNC.9 On main

A quiet key or a day of many corrections

A silent key, and a day of reconcile corrections above the store’s share, each become a row of “Needs you now” on Home and a notice on the Stock screen. The page Stock, Sync status shows each key’s state and nothing of the key itself.

Old movements fold · SSYNC.9 On main

One movement a day, then one opening movement

Each hour a job folds a sync key’s movements in 2 tiers. After stock.sync_fold_days, the movements of one day become one movement for each item, location and key. After stock.sync_daily_days more, those days become one opening movement. A store whose sync key sent a set folds after 2 days, and makes the opening movement after 7 more days. A store with no sync key keeps 90 days and makes no opening movement. Each value is 0 for never, else 1 to 3,650. A fold sends no stock.changed event, and it never folds a stock take or a released held line.

The adapter

Small, outside the engine. No vendor code inside.

The adapter runs as its own service and calls the engine’s API with the sync key. It maps your item codes and places to the store’s, keeps the calls the engine did not answer, and sends them again.

Reference adapter · SSYNC.18 On main

Working code to start from

The repository holds a reference adapter, a tool apart from the engine binary that names no vendor. It sets levels with stock.sync-set under a sync key, keeps its sets in a queue on disk until the engine answers, and books the engine’s movements back into the source by key. Each round it reads the movements after the last one it has, so it catches up after a gap. This read is on by default. It compares full levels at its start, each 24 hours and after a gap. It comes with a simulated source and a file source. It closes a stock take at its end, sends each known level of a renamed SKU again under its new SKU, and compares each place again after the store is restored from a copy.

Before a sync goes live, six acceptance tests run against a test copy of your system: a late store, a replay, two levels out of order, a stock take, a web sale booked back, and an outage.

A sandbox

Try the sync on a store of your own.

The engine’s team sets up a sandbox store for a team that evaluates the stock sync. It runs a build of the engine from the main branch, with invented data only, and sends no real mail.

What you get

A store and 2 secrets

A store with 300 invented locations and invented products, and 3 empty locations for your first calls. A sync key for those locations, and an access token for the gate in front of the store. Both reach you through a secrets vault, never by mail or chat.

How it is set

The defaults of a store

The guard is on, so a large change waits for a person. The sync key has the default limits. The team resets the store on request, and each sandbox has an end date.

How to start

The guide’s quickstart

Start with the guide’s quickstart: the first 6 calls in order, each with its answer. Then point the reference adapter, with its sample source, at the sandbox.

Not built yet

What the engine does not do yet

These parts are in the engine’s specification and are not built:

  • A mail to the owner when one key changes very many items in a short time, or when a stock take changes many levels past the guard.
  • An event when the store deletes a variant.
  • A webhook endpoint that receives only the movements of named locations.