---
title: "Sync Connection"
method: POST
path: "/v1/graphs/{graph_id}/connections/{connection_id}/sync"
tags: ["Connections"]
---

# Sync Connection

`POST /v1/graphs/{graph_id}/connections/{connection_id}/sync`

## Request

- Base URL: `https://api.robosystems.ai` (the document declares no server; this is the origin it was published from)
- URL: `https://api.robosystems.ai/v1/graphs/{graph_id}/connections/{connection_id}/sync`
- Auth: one of:
  - API key in header `X-API-Key`
  - HTTP bearer

QuickBooks: fetches transactions, balances, and chart of accounts. Mercury: pulls the bank feed (a 60-day window by default, or from `since_date` / the full backfill on `full_rebuild`) and captures it into the inbox. Plaid: continues from the Item's stored cursor (added, modified and removed transactions), or replays its history on `full_rebuild` / `since_date`. For all three the envelope is `pending` with the run's `task_id`, and completion is reflected in the connection's `last_sync` timestamp and `last_sync_result`. External connections are push-based and have nothing to pull; the envelope is `completed` with a null `task_id` and a message saying so — there is nothing to poll. Returns an `OperationEnvelope`; supports `Idempotency-Key`.

## Path parameters

- `graph_id` string, required
- `connection_id` string, required: Connection identifier

## Headers

- `Idempotency-Key` string, nullable

## Request body

- SyncConnectionRequest: Request to sync a connection.
  - `full_rebuild` boolean: Pull complete history from the provider, ignoring lookback window. Takes precedence over since_date.
  - `since_date` string, date, nullable: Sync data from this date forward (ISO 8601). Ignored if full_rebuild=True. If neither set, provider default applies (e.g., QuickBooks: 60 days).
  - `sync_options` object, nullable: Provider-specific sync options (escape hatch for fields not exposed at the top level).

## Response `202`

Successful Response

- OperationEnvelope: Uniform response shape for every operation endpoint. Every dispatch carries an `op_<ULID>` operation_id, which is the bridge to the monitoring surface: pass it to `GET /v1/operations/{operation_id}/stream` (see `routers/operations.py`) to subscribe to SSE progress events. Sync commands complete in the envelope itself (`status: "completed"`, HTTP 200); async commands (`status: "pending"`, HTTP 202) hand off to a background worker and stream their tail through that SSE endpoint. Failed dispatches still mint an `operation_id` so the audit log and any partial SSE events stay correlatable. `TResult` parameterizes `result` so per-op response shapes surface in OpenAPI. Operations that pin `OperationSpec.result_type` get `OperationEnvelope[YourEnvelope]` as their response model; the rest keep the default `Any` shape (`result: any | null` on the wire).
  - `operation` string, required: Kebab-case operation name
  - `operationId` string, required: op_-prefixed ULID for audit and SSE correlation
  - `status` 'completed' | 'pending' | 'failed', required: Operation lifecycle state
  - `result` unknown
  - `at` string, required: ISO-8601 UTC timestamp
  - `createdBy` string, nullable: User ID that initiated the operation
  - `idempotentReplay` boolean: True when this envelope came from the idempotency cache — the underlying command did not execute again. False on fresh executions.

## Other responses

- `400`: Invalid request
- `401`: Authentication required
- `403`: Access denied
- `404`: Resource not found
- `409`: Idempotency-Key conflict — key reused with different body
- `422`: Validation error
- `429`: Rate limit exceeded
- `500`: Internal server error
- `504`: Sync request timed out

---

[API](https://skmtc.dev/robosystems/apis/robosystems-api.md) · [All operations](https://skmtc.dev/robosystems/apis/robosystems-api/llms.txt) · [OpenAPI document](https://skmtc.dev/robosystems/apis/robosystems-api/revisions/e661e2d5ca6a?raw)
