How to Run a Manual Sync and Poll for Completion Using the REST API or Webhooks
Use Case
You want to use the REST API to manually sync a connector and understand when that sync has completed from the command line. You may want this to run your connector on a custom schedule with cron.
Fivetran Recommendation:
We recommend that you use the scripting language of your choice to call the Fivetran REST API to manually sync the connector and then poll our API for a completion status.
Find the connector ID for your connector.
Use the Sync Connector Data endpoint request to force a sync of your connector:
POST https://api.fivetran.com/v1/connectors/{connector_id}/sync
{ "force": true }
NOTE: Using the
"force": true
payload parameter in the request stops a sync that is in progress. If you don't want to stop a current sync, leave the payload empty.Do either of the following:
Use the Retrieve Connector Details endpoint request to check the status of the connector:
GET https://api.fivetran.com/v1/connectors/{your_connector_id}
Create a group webhook and configure it to send the
sync_end
event.
Considerations:
Using polling, you will know whether a sync has completed but not necessarily get an accurate estimate of how long the sync actually took. Polling adds some time value, which may be as large as your polling frequency interval, to that estimate.
IMPORTANT: If you set the sync scheduling for your connector to
manual
, you need to manually trigger your syncs after you make this change. If a manually-triggered sync wasrescheduled
, you need to manually re-trigger that sync, since sync rescheduling only works with automatic sync scheduling.