Sync API

Version 2. This guide is for integrators connecting terminals and scanners to an existing Tenmark Sync deployment.

Overview

Each device keeps a local store and a cursor. On every sync it sends its pending local changes and the last cursor it received; the server applies the changes and answers with everything newer than that cursor plus a new cursor.

Device tokens

Tokens are issued per device from the admin console and can be revoked at any time. Send the token in the Authorization header.

Authorization: Device <token>

Tokens are bound to one device. Copying a token to another device invalidates it on next use.

Sync request

POST /api/v2/sync
Content-Type: application/json

{
  "cursor": "c_8f21a0",
  "changes": [
    { "table": "stock", "id": 4412, "qty": 18, "ts": 1761980000 }
  ]
}

The response contains applied (ids of accepted changes), remote (changes from other devices) and cursor.

Cursors

Cursors are opaque strings. Store the latest one only after the local store has committed the remote changes. Sending an expired cursor returns 410; the device should request a full snapshot.

Conflicts

By default the most recent write wins per field, using the device timestamp ts. Tables can be switched to server-side resolvers in the admin console.

Errors

CodeMeaning
400Malformed body or unknown table
401Missing or revoked device token
410Cursor expired, snapshot required
429Too many requests from this device

Limits