Customer Delta synchronization
Maintain an authorized company customer mirror with a full catalog baseline and subsequent current customer snapshots.
GET /api/v1/companies/{companyId}/customers/changes requires customers.read, company access and a configured ordinary company contract. Complete parameters, response fields and examples. Use the same client and company throughout synchronization. The company boundary applies to both the catalog and Delta; supplier/store contract lists do not narrow the customer catalog.
Initial full synchronization
- Call changes with no since. It returns HTTP 200 with fullSyncRequired=true, reason=initial_sync_required, baselineSince and revision. Save these values before starting the catalog export.
- Read every page of
/customers?page=1&pageSize=200, increasing page until totalPages is exhausted. Apply or stage the full company catalog. Never infer removals from an incomplete or failed export. - After a complete export, request changes with since equal to the captured baselineSince and revision equal to the captured revision. Omit through and afterCustomerId on this first incremental request.
- Apply all incremental pages. If another fullSyncRequired response arrives, discard that incomplete synchronization attempt and repeat the full procedure with the new baseline and revision.
Parameters and cursor rules
sinceandthrough: ISO timestamps with offsets. Omit since for the initial handshake. The server supplies a safe through when it is omitted. Keep through fixed for continuation. Both change-time bounds are inclusive.revision: int64 catalog revision; required whenever since is supplied. Treat it as a server value, not a version inferred from a date.afterCustomerId: optional nonnegative int64 key; continuation requires since, through and revision. Results have customer ID greater than this key, ordered by ID.pageSize: default 200, range 1–1000. There is no page-number cursor.
Incremental rows have exactly the customer catalog fields. These are current customer snapshots, not historical events or field patches. Upsert idempotently by (companyId, id), preserving null values. The API does not emit deletion tombstones; obey every full-sync instruction and reconcile only from a complete catalog export.
Hypothetical multi-page sequence
All timestamps and IDs below are fictional. Use the actual returned values in an integration.
- At 10:00 the initial changes request returns baselineSince=2026-10-01T10:00:00Z, revision=4. Save both and export all customer pages.
- Request
changes?since=2026-10-01T10%3A00%3A00Z&revision=4&pageSize=1. The response selects through=10:05, returns customer 10001, hasMore=true, nextAfterCustomerId=10001 and nextSince=10:00. - Apply that row, then request
changes?since=2026-10-01T10%3A00%3A00Z&through=2026-10-01T10%3A05%3A00Z&revision=4&afterCustomerId=10001&pageSize=1. - The final page returns customer 10002, hasMore=false, nextAfterCustomerId=null and nextSince=10:05. After applying it, durably save 10:05 and revision 4; clear the page key.
- For the next poll use since=10:05, revision=4 and no through or afterCustomerId. Boundary rows may repeat because the time interval is inclusive; replacement/upsert avoids duplication.
If a page or local write fails, keep the previous durable window cursor and replay safely. Persist an in-window key only together with the exact since, through and revision and after the associated rows are durably applied. Advance since only after hasMore=false and the entire window is applied, including an empty final window.
Envelope field dictionary
| Field | Type / nullability | Meaning and shape |
|---|---|---|
| companyId | integer, nonnull | Authorized company; both shapes. |
| fullSyncRequired | boolean, nonnull | Selects the full-sync or incremental shape. |
| reason | string, nonnull; full-sync only | initial_sync_required, history_not_available or catalog_revision_changed. |
| baselineSince | offset timestamp, nonnull; full-sync only | Safe server baseline to capture before exporting. |
| revision | int64, nonnull | Catalog revision for this synchronization. |
| companyCode | string, nonnull; incremental only | Company code; no companyName in Delta. |
| since / through | offset timestamps, nonnull; incremental only | Accepted fixed window boundaries. |
| count | integer, nonnull | Number of rows in data; zero on a full-sync instruction. |
| hasMore | boolean, nonnull; incremental only | Whether another keyset page is available. |
| nextAfterCustomerId | int64 or null; incremental only | Last returned ID when hasMore=true; otherwise null. |
| nextSince | offset timestamp, nonnull; incremental only | since while hasMore; through on completion. |
| data | array, nonnull | Customer rows, or an empty array on full-sync instruction. |
Revision changes and recovery
A supplied revision different from the current revision produces fullSyncRequired=true with reason=catalog_revision_changed. A since older than available history produces history_not_available. Capture the new baselineSince and revision, export all customers again and reconcile stale records only after the full export succeeds. Do not respond by merely replacing revision on an old cursor.
Missing revision with since returns 400 delta_revision_required. An incomplete continuation or negative ID returns 400; future or inverted time windows return invalid_delta_window. 503 customer_delta_not_installed requires administrator assistance. Keep the last known cursor on every failed request. See error recovery.
Privacy and synchronization boundaries
Customer names, phone numbers, birth dates and email addresses are personal data. Restrict the mirror to the approved purpose and authorized personnel, protect stored data, and keep real customer payloads and API keys out of logs, examples and support tickets. Customer IDs are loyalty identifiers and do not replace ERP customer IDs on sales.
Full-catalog pages do not share one export-wide snapshot; Delta rows are latest state rather than historical snapshots frozen at through. Use the server watermark, idempotent application and explicit full-sync instructions. Hourly Footfall is an independent aggregate traffic resource, not a customer-event feed.