Run a sync
A sync copies changes from Knack into your analytics copy. Through the API you can start one on demand and find out when it finishes, for example to refresh a report right after the data lands. See the analytics overview for how syncs, clones and live sync fit together.
You need a key with the write scope to start jobs and read to check on them. Examples use <appId> from GET /apps.
Two ways to start a job
| Endpoint | Starts | Use it for |
|---|---|---|
POST /apps/<appId>/reconcile |
A reconcile job |
Catching up changes since the last sync. This is the “run a sync now” call. |
POST /apps/<appId>/clone |
A clone job |
The first copy of an app, or copying tables added to analytics later. The first clone needs the live sync snippet installed. |
Both answer 202 Accepted with the new job’s id straight away. The work runs in the background:
{ "jobId": "Jb3k2LxQ9" }
Both use the app’s Knack API budget, exactly like a sync started in the app. Check what’s left before a big job with GET /apps/<appId>/sync/status, which returns apiBudget.left and apiBudget.resetAt. See Knack API budget.
Only one sync job runs per app at a time. Starting another while one is running returns 409 JOB_ACTIVE. Other refusals you may see:
| Status and code | Why |
|---|---|
409 FAILED_PRECONDITION |
The app has no analytics destination yet, no tables are selected, or (first clone) the live sync snippet hasn’t checked in. The message says which. |
402 PLAN_REQUIRED |
The workspace’s plan doesn’t include Analytics. |
402 PLAN_LIMIT |
A clone would go over the plan’s record limit. |
Send an Idempotency-Key header with each start request. If your request times out and you retry with the same key, you get the first answer back instead of a second job. See errors and rate limits.
Option 1: poll the job
GET /jobs/<jobId> returns the job and its progress. Poll it until state is final:
state |
Meaning |
|---|---|
queued, running |
Still working. |
paused_budget |
Waiting for the app’s Knack API budget to reset. It resumes on its own. |
paused_user |
Paused by someone in the app. |
completed |
Done. |
completed_with_errors |
Done, but some records need attention in the app. |
failed |
Stopped. error says why. |
cancelled |
Cancelled by someone in the app. |
A job in progress:
{
"id": "Jb3k2LxQ9",
"appId": "6b05a32b031b09796ccc7d52",
"type": "reconcile",
"state": "running",
"createdAt": "2026-12-01T18:00:00.000Z",
"startedAt": "2026-12-01T18:00:02.000Z",
"finishedAt": null,
"apiCalls": 14,
"summary": null,
"error": null,
"progress": { "tables": 3, "tablesDone": 1, "rowsDone": 1200, "totalRecords": null },
"archive": null,
"restore": null
}
progress.totalRecords is null until VaultLens knows the size of every table. Every poll counts against the key’s rate limit, so poll every 10 to 30 seconds rather than continuously, and less often while the job is paused_budget (the budget resets at apiBudget.resetAt).
To see recent jobs instead of one, use GET /jobs?appId=<appId>&type=reconcile (newest first; type is one of clone, reconcile, reclone, schema_check, archive, restore).
curl
BASE=https://api.vaultlens.studio/v1
# Start a sync. Reuse the same Idempotency-Key if you retry this request.
JOB_ID=$(curl -s -X POST "$BASE/apps/<appId>/reconcile" \
-H "Authorization: Bearer $VAULTLENS_API_KEY" \
-H "Idempotency-Key: nightly-sync-$(date -u +%F)" | jq -r .jobId)
# Poll until the job reaches a final state.
while :; do
STATE=$(curl -s "$BASE/jobs/$JOB_ID" \
-H "Authorization: Bearer $VAULTLENS_API_KEY" | jq -r .state)
echo "$STATE"
case "$STATE" in
completed|completed_with_errors|failed|cancelled) break ;;
esac
sleep 15
done
Node
// Node 18+. Starts a sync for one app and waits for it to finish.
const BASE = 'https://api.vaultlens.studio/v1';
const headers = { Authorization: `Bearer ${process.env.VAULTLENS_API_KEY}` };
const FINAL = new Set(['completed', 'completed_with_errors', 'failed', 'cancelled']);
async function call(method, path, extraHeaders = {}) {
const res = await fetch(BASE + path, { method, headers: { ...headers, ...extraHeaders } });
const body = await res.json();
if (!res.ok)
throw new Error(`${body.error.code}: ${body.error.message} (${body.error.requestId})`);
return body;
}
const appId = '<appId>';
const { jobId } = await call('POST', `/apps/${appId}/reconcile`, {
'Idempotency-Key': `nightly-sync-${new Date().toISOString().slice(0, 10)}`,
});
let job;
do {
await new Promise((r) => setTimeout(r, 15_000));
job = await call('GET', `/jobs/${jobId}`);
console.log(job.state, job.progress);
} while (!FINAL.has(job.state));
if (job.state !== 'completed')
console.error(`Sync ended as ${job.state}: ${job.error ?? job.summary}`);
Python
import datetime
import os
import time
import requests
BASE = "https://api.vaultlens.studio/v1"
session = requests.Session()
session.headers["Authorization"] = f"Bearer {os.environ['VAULTLENS_API_KEY']}"
FINAL = {"completed", "completed_with_errors", "failed", "cancelled"}
def call(method, path, **kwargs):
res = session.request(method, BASE + path, timeout=30, **kwargs)
body = res.json()
if not res.ok:
err = body["error"]
raise RuntimeError(f"{err['code']}: {err['message']} ({err['requestId']})")
return body
app_id = "<appId>"
started = call(
"POST",
f"/apps/{app_id}/reconcile",
headers={"Idempotency-Key": f"nightly-sync-{datetime.date.today().isoformat()}"},
)
while True:
time.sleep(15)
job = call("GET", f"/jobs/{started['jobId']}")
print(job["state"], job["progress"])
if job["state"] in FINAL:
break
if job["state"] != "completed":
print(f"Sync ended as {job['state']}: {job['error'] or job['summary']}")
Option 2: listen for webhooks
Instead of polling, register an endpoint in Settings → Webhooks and let VaultLens tell you. The events that matter for syncs:
| Event | Sent when | data |
|---|---|---|
clone.completed |
A clone finished (completed or completed_with_errors). |
appId, jobId |
job.failed |
A clone or a sync (manual or scheduled) failed. Clones that are cancelled also send this. | appId, jobId, jobType (clone or reconcile) |
sync.unhealthy |
Live sync errors piled up, or the live sync snippet went quiet. | appId, reason |
There is no event for a sync that succeeds: a reconcile job only sends job.failed. To act when a sync finishes successfully, poll the job (option 1). A good pattern for clones is to wait for clone.completed or job.failed, then GET /jobs/<jobId> to see whether the state was completed or completed_with_errors.
Webhook payloads carry ids only. A job.failed delivery:
{
"id": "evt_Wm9rQ2x1c3Rlcg",
"type": "job.failed",
"createdAt": "2026-12-01T18:00:00.000Z",
"workspaceId": "Wk7dQ2mFz9LpT4xR8bN1",
"data": { "appId": "6b05a32b031b09796ccc7d52", "jobId": "Jb3k2LxQ9", "jobType": "reconcile" }
}
Setting up the endpoint and checking signatures is covered in webhooks.
Pause and resume live sync
While you do maintenance, you can hold live changes and apply them later. POST /apps/<appId>/sync:pause and POST /apps/<appId>/sync:resume (scope write) both answer { "paused": true } or { "paused": false }. Changes made in Knack while paused are held and applied on resume. GET /apps/<appId>/sync/status shows liveSync.paused, the last heartbeat and today’s event counts.
See the API reference for every field of the job and sync status responses.