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
| Code | Meaning |
|---|---|
| 400 | Malformed body or unknown table |
| 401 | Missing or revoked device token |
| 410 | Cursor expired, snapshot required |
| 429 | Too many requests from this device |
Limits
- Up to 500 changes per request.
- Request body up to 2 MB.
- Recommended sync interval: 30–120 seconds while active.