MemorySync
API Reference

Sync & Jobs

Trigger a sync on a connection, read where it got to, and follow or cancel the background job doing the work.

Operations on this page

OperationMethod and pathPythonNode.js
List recent sync jobsGET /api/v2/integrations/connections/{connection_id}/syncconnections.sync_statusconnections.syncStatus
Trigger a syncPOST /api/v2/integrations/connections/{connection_id}/syncconnections.trigger_syncconnections.triggerSync
Get a sync jobGET /api/v2/integrations/sync-jobs/{job_id}sync_jobs.getsyncJobs.get
Cancel a sync jobPOST /api/v2/integrations/sync-jobs/{job_id}/cancelsync_jobs.cancelsyncJobs.cancel

Authentication and scope

RequirementContract
CredentialAn API key sent as X-API-Key. Connector operations are not end-user scoped.
Read scopeintegrations:read for every GET.
Write scopeintegrations:write for every POST, PUT, PATCH and DELETE.
TenantDerived from the authenticated key. There is no tenant parameter to pass or to get wrong.
X-End-User-IDNot used. A connection belongs to the organization, not to one end user.

1. Check before you trigger

Despite the method name, this returns a bare JSON array of recent sync jobs, newest first — not a single status object. Read the first entry to see whether one is already in flight; triggering a second sync wastes an upstream rate-limit budget you may need.

import os
from memorysync import MemorySyncClient
client = MemorySyncClient(
api_key=os.environ["MEMORYSYNC_API_KEY"],
base_url="https://api.memorysync.io",
)
jobs = client.connections.sync_status("conn_8f21a4")
if jobs and jobs[0]["status"] in {"pending", "running"}:
print("already syncing:", jobs[0]["id"])
else:
print("idle; last job:", jobs[0]["status"] if jobs else "none yet")
GET/api/v2/integrations/connections/{connection_id}/sync
200 OK
ParameterContract
limitOptional. Defaults to 20, capped at 100.

2. Trigger a sync

A sync is queued, not performed inline. The response is the job record, and the identifier to follow is id.

import os
from memorysync import MemorySyncClient
client = MemorySyncClient(
api_key=os.environ["MEMORYSYNC_API_KEY"],
base_url="https://api.memorysync.io",
)
job = client.connections.trigger_sync("conn_8f21a4", job_type="incremental")
print(job["id"], job["status"])
POST/api/v2/integrations/connections/{connection_id}/sync
202 Accepted
FieldTypeContract
job_typestringOptional. Exactly incremental (the default) or full. Any other value is a 422.

3. Follow the job

Poll the job, at a sensible interval. There is no completion webhook for sync jobs, so the job record is the source of truth.

import os
from memorysync import MemorySyncClient
client = MemorySyncClient(
api_key=os.environ["MEMORYSYNC_API_KEY"],
base_url="https://api.memorysync.io",
)
import time
TERMINAL = {"completed", "failed", "cancelled", "partial"}
while True:
job = client.sync_jobs.get(job_id)
if job["status"] in TERMINAL:
break
time.sleep(5)
progress = job["progress"]
print(job["status"], progress["processed_items"], "of", progress["total_items"],
"failed:", progress["failed_items"])
GET/api/v2/integrations/sync-jobs/{job_id}
200 OK
FieldMeaning
id, connection_idThe job and what it belongs to. Both integers.
job_typefull or incremental.
statusOne of the six values below.
progressAn object: total_items, processed_items, failed_items.
started_at, completed_at, created_atTiming. The first two are null until they happen.
error_messageWhy a failure failed.
Sync job status
pending
Waiting

Accepted and waiting for a worker.

running
In progress

Reading from the source and extracting. Objects appear as it goes.

completed
Finished cleanly

Everything selected was processed.

partial
Finished with failures

Some items could not be read. Check progress.failed_items and the per-object detail.

failed
Failed

Read error_message. A credential problem needs reconnect, not another sync.

cancelled
Cancelled

Stopped early. Objects already processed are kept.

4. Cancel a long-running sync

Cancelling stops further work. Objects already synced and memories already extracted are kept, because discarding completed work would make a cancel more destructive than the sync it stopped.

import os
from memorysync import MemorySyncClient
client = MemorySyncClient(
api_key=os.environ["MEMORYSYNC_API_KEY"],
base_url="https://api.memorysync.io",
)
job = client.sync_jobs.cancel(job_id)
print(job["status"])
POST/api/v2/integrations/sync-jobs/{job_id}/cancel
200 OK

Billing

A sync is billed for what it extracts: one add per memory created, exactly like the memory API. Reading a source object that produces no memory is not billed. A full sync of a large connection therefore costs roughly what the original import cost.

Errors and next action

StatusMeaningNext action
401Missing, malformed or inactive API key.Check server configuration without printing the key.
403The key lacks integrations:read or integrations:write.Grant the scope on the key, or use a key that has it.
404The connection, object or job is not visible to this tenant.Confirm the identifier belongs to this organization.
409The connection is in a state that forbids the operation.Read the connection status first and act on it.
429Rate limited, either by MemorySync or by the upstream provider.Back off; do not tighten a polling loop in response.
5xxService failure.Treat a write outcome as uncertain and reconcile by reading the connection back.