Amba

Sync

Two-way checkpoint sync for local → server + server → local deltas.

Client SDK uses these endpoints for background delta sync. Conflicts are resolved server-wins — if the server has a newer last_synced_at than the incoming change's client_timestamp, the client gets a conflict record and keeps the server value.

Source: apps/api/src/routes/client/sync.ts.

Endpoints

MethodPathDescription
POST/client/syncPush local changes.
GET/client/syncPull remote changes since a checkpoint.

POST /client/sync

Request (SyncPushInput)

{
  "changes": [
    {
      "entity_type": "todo",
      "entity_id": "…",
      "action": "update",
      "data": { "title": "…" },
      "client_timestamp": "…"
    }
  ]
}

Response 200

{
  "data": {
    "applied": 1,
    "conflicts": [
      {
        "entity_type": "todo",
        "entity_id": "…",
        "resolution": "server_wins",
        "server_data": { "last_synced_at": "…" }
      }
    ],
    "checkpoint_token": "…"
  }
}

Errors

  • 500 SYNC_FAILED.

Try it:

POST/client/sync
client auth
curl -X POST 'https://api.amba.dev/client/sync'
Loading auth… Configure auth in the settings drawer (top-right) to run this request.

Curl:

curl -X POST '${BASE_URL}/client/sync' \
  -H 'X-Api-Key: ${CLIENT_API_KEY}' \
  -H 'Authorization: Bearer ${SESSION_TOKEN}' \
  -H 'Content-Type: application/json' \
  -d '{}'

GET /client/sync

Pull up to 100 changes newer than the supplied checkpoint.

Query

ParamRequiredDescription
entity_typeyesThe entity kind to sync (must be a simple identifier; LIKE metacharacters are escaped).
checkpoint_tokennoOpaque token from a prior response. Omitting = full sync from epoch.

Response 200

{
  "data": {
    "changes": [
      {
        "entity_type": "todo",
        "entity_id": "…",
        "action": "update",
        "data": {},
        "client_timestamp": "…"
      }
    ],
    "checkpoint_token": "…",
    "has_more": false
  }
}

Errors

  • 400 INVALID_INPUTentity_type missing.
  • 500 SYNC_FAILED.

Try it:

GET/client/sync
client auth
curl -X GET 'https://api.amba.dev/client/sync'
Loading auth… Configure auth in the settings drawer (top-right) to run this request.

Curl:

curl -X GET '${BASE_URL}/client/sync' \
  -H 'X-Api-Key: ${CLIENT_API_KEY}' \
  -H 'Authorization: Bearer ${SESSION_TOKEN}'

On this page