How Can I Use the REST API to Trigger Manual Syncs?
Question
Rather than relying on my connection's scheduled syncs, I want to:
- Enable manual sync scheduling
- Trigger manual syncs
- Check when syncs have finished
How can I do this using the Fivetran REST API?
Environment
- All connectors
- REST API
Answer
To run manual syncs using the REST API, do the following:
Find the connection ID for your connection.
Use the Update a Connection endpoint to set your connection's
schedule_typeparameter tomanual:PATCH https://api.fivetran.com/v1/connections/{connection_id}{ "schedule_type": "manual", "run_setup_tests": false }When you enable manual sync scheduling, you must manually trigger all syncs, including syncs that are
rescheduled.Use the Sync Connection Data endpoint to trigger a sync:
POST https://api.fivetran.com/v1/connections/{connection_id}/sync{ "force": true }Using the
"force": truepayload parameter stops syncs in progress. If you don't want to stop a current sync, leave the payload empty.Use either of the following methods to determine when the sync is finished:
- Use the Retrieve Connection Details endpoint request to check the status of the connection:
GET https://api.fivetran.com/v1/connections/{your_connection_id} - Create a group webhook and configure it to send the
sync_endevent.
- Use the Retrieve Connection Details endpoint request to check the status of the connection:
Considerations
- When you enable manual sync scheduling, we ignore the connection's
sync_frequency. - You can combine this workflow with a cron job if you want to run manual syncs on a custom schedule.
- You can trigger manual syncs in Fivetran by clicking Sync on the connection overview page.
To learn how to manage a connection through its entire lifecycle using the Fivetran REST API, see our Manage Connection Using the REST API tutorial.