API
View as Markdown

Auto-Sync

Inspect broker auto-sync connections, read sync history, and trigger a manual sync.

GET /autosync/connections

Scope: read:autosync

List your auto-sync connections. No token material is ever exposed.

GET /autosync/connections/{id}

Scope: read:autosync

Single connection.

GET /autosync/log

Scope: read:autosync

Sync history.


POST /autosync/connections/{id}/sync

Scope: write:autosync · Plan gate: Pro

Trigger an immediate sync on a broker connection. Routes through the same dupe-detection + import pipeline the settings UI uses, so a manual sync from the API is byte-identical to one triggered from the dashboard.

No request body. The connection’s configured Tradavity account_id is the import target.

StatusCodeMeaning
200(no error code)Sync ran. Body data contains connection_id, log_id, imported, skipped, total_fetched, total_trades, total_pnl, errors[], and a human-readable message.
400validation_errorConnection inactive or no broker account selected.
401token_expiredBroker token expired or could not be refreshed. The user needs to reconnect via the settings UI.
404not_foundNo connection with that id, or it doesn’t belong to you.
429limit_reachedPro plan required for sync.
429connection_sync_cooldownPer-connection cooldown — manual syncs are capped to once every 20 seconds per connection to protect the upstream broker API from amplification. Distinct from the key-level rate limit. Headers: X-RateLimit-Scope: connection-sync, Retry-After: <seconds>. error.details.retry_after_seconds mirrors the header. Cron-triggered syncs (the 15-minute auto-sync schedule) bypass this gate.
502broker_api_errorUpstream broker API returned an error. Retry later.
500sync_failedSync pipeline raised an unexpected error (parser crash, DB transaction abort, etc.). Retrying is safe — the operation is idempotent on the broker side.
# Replace 12 with one of your connection_ids from GET /autosync/connections
curl -X POST "https://app.tradavity.com/api/v1/autosync/connections/12/sync" \
  -H "Authorization: Bearer tvty_YOUR_KEY_HERE" \
  -H "Idempotency-Key: $(uuidgen)"

The Idempotency-Key cache returns the same imported/skipped numbers on replay without hitting the broker again. Useful when a flaky network kills the response but the sync already ran.