Skip to content

Offline sync protocol

This is the wire side of offline operation. A device downloads datasets, works on them without connection and sends its changes back, using five reserved app-level actions on the ordinary sync endpoint. There is no new HTTP endpoint. Java, .NET and Python answer them identically (pinned by the scenario conformance/offline/sync.json).

The clients are the React Native app and the Vaadin web renderer (in the browser); both run the same engine (libs/mateu, infra/offline) and send the same requests — the web sends them through the page’s own API client, with the push’s Idempotency-Key header, from one tab of the browser at a time.

The full contract — every rule, the search semantics, the shared client engine — is design/offline/protocol.md on GitHub.

POST /mateu/v3/sync/{route}
Content-Type: application/json
{ "route": "", "consumedRoute": "_empty", "serverSideType": "io.example.FieldApp",
"actionId": "_offline-pull", "componentState": {},
"parameters": { "dataset": "work-orders", "cursor": null, "limit": 500 } }
  • Like _presence, they are app-level: aimed at the app (its serverSideType), never resolved through the menu. Each one answers against the manifest of the app the request targets.
  • The parameters go in parameters. The answer is in the first fragment’s data, under the key named below (_offline_manifest, _offline_pack…).
  • They run with the caller’s identity, like any request. An unknown dataset, one of another app, one the caller may not hold, a pull of an UP dataset and a push to a DOWN one all answer 403.
  • AppDto.offline is true when the app has at least one dataset the caller may hold. A client that sees it starts its offline session.
  • Enum values are lower camel case: down|up|both, ask|serverWins|clientWins|mergeFields, always|wifiOnly|onDemand, and create|update|delete for a change.
ActionParametersAnswer keyWhat
_offline-manifest—_offline_manifestthe datasets the caller may hold and the offline routes
_offline-packroute_offline_packthe screen templates of one offline route
_offline-pulldataset, cursor, limit_offline_pullone page of records since the cursor
_offline-pushdataset, change + header Idempotency-Key_offline_pushone change made on the device
_offline-upload-ticketdataset, field, count_offline_upload_ticketan upload ticket for a file field, asked at sync time
{ "datasets": [ { "name": "work-orders", "direction": "both", "key": "id",
"conflicts": "ask", "keepForSeconds": 604800, "refuseStale": false,
"keepAfterPush": false, "wipeOnSignOut": false, "maxRecords": 10000,
"canCreateOffline": true, "fileFields": [], "preload": "always",
"estimatedRecords": null, "versionField": "version",
"schema": "<sha256 of field names and types>" } ],
"routes": [ { "route": "/workOrders", "dataset": "work-orders" } ] }

Only the datasets the caller may hold travel. canCreateOffline is false for a dataset whose key is not a String/UUID, or that is DOWN. estimatedRecords comes from SyncSource.estimate.

{ "route": "/workOrders", "dataset": "work-orders", "build": "<X-Mateu-Build>",
"list": { "…": "the UIIncrementDto that draws the route, rows left out" },
"view": { "…": "the record page, for templateId" },
"edit": { "…": "the edit form, for templateId" },
"create": { "…": "the create form" },
"templateId": "__mateu_offline_record__",
"titleField": "title",
"searchable": ["title", "customer"], "filters": [],
"fieldTypes": { "title": "string", "priority": "enum", "dueDate": "date" },
"lookups": { "workOrderId": { "dataset": "work-orders", "labelField": "title", "searchable": ["title"] } },
"offlineActions": ["search", "create", "save", "delete", "cancel-edit", "cancel-new", "edit", "view", "new"],
"indexFields": ["status", "dueDate"] }

Each of list, view, edit and create is the answer that draws that screen, produced by the same mapping as an online load against a record whose fields are null and whose id is templateId. No real record’s value is ever in a template: the client binds a local record into the state. edit and create are null for a DOWN dataset; create also when the dataset cannot create offline or the crud’s write gates refuse it. build ties the pack to the deployment. titleField, when present, is the field the record’s own title (toString(), Named.name(), TitleSupplier.title()) returns as it is: the device titles a record page by it, as online. It is absent when the title is composed from several fields; the device then uses the first of title, name, label or description.

{ "upserts": [ { "id": "…", "title": "Fix pump", "status": "OPEN", "version": 3 } ],
"deletedKeys": ["…"], "nextCursor": "…", "more": false, "resetRequired": false,
"versionField": "version" }

cursor is what the previous page answered as nextCursor (null the first time). limit defaults to 500, capped at mateu.offline.max-page-size (1000). Records are serialised exactly as a listing row, so the fields the caller may not read never leave. resetRequired: true = drop the copy and replace it with what follows. A page beyond the dataset’s maxRecords is cut there.

{ "key": "0190a8a8-…", "op": "update", "record": { "…": "the record as the device has it" },
"changedFields": { "status": "DONE" }, "baseVersion": 3,
"madeAt": "2026-11-29T10:15:00Z", "changeId": "0190a8b0-…" }

Sent with the header Idempotency-Key: <changeId>. One of three answers:

{ "result": "accepted", "newVersion": 4, "stored": { "…": "row map" } }
{ "result": "rejected", "message": "There are validation errors", "fieldErrors": { "title": "Required" } }
{ "result": "conflict", "current": { "…": "row map" }, "currentVersion": 4 }

Before the app’s SyncSource.push runs, the server checks the direction, the bound crud’s write gates, drops the fields the caller could not write, runs bean validation (rejected, the source is never called) and checks that every file field holds a stored file (rejected with “This file has not been uploaded.”). A repeated Idempotency-Key answers the remembered result; a validation refusal is not remembered.

_offline-upload-ticket {dataset, field, count}

Section titled “_offline-upload-ticket {dataset, field, count}”
{ "uploadUrl": "/mateu/v3/upload", "ticket": "<signed>", "maxBytes": 10000000,
"accept": "image/*", "direct": false }

The ordinary upload ticket (8 hours, bound to the caller) for one of the dataset’s fileFields. count > 1 issues one ticket for several files. direct: true means the store issues pre-signed targets (uploadUrl + "/target" first, as online). 403 when the field is not a file field of a dataset the caller may push to; “Files cannot be uploaded here.” when no FileStorage matches the field.