Syncing Data
Overview
When syncing data with Merge, we recommend a combination of webhooks and polling.
Save your users' account token
Get the account token from the linking process for an embedded Merge Link. Learn more in our embedded Merge Link guide.
You can also use the Linked Account linked webhook to get the account token. See the example payload below and learn how to configure Merge Webhooks in our guide.
To authenticate your API requests to Merge, save your users’ account token in your database. You will need the account token to poll for data in step 4.
Sync data when Merge emits a sync notification webhook
We recommend using the Linked Account synced webhooks to manage sync activities at scale. Whenever you receive a sync notification webhook for a Linked Account, start pulling data and kick off the logic in step 3.
Important fields:
Create functions for efficiently syncing data
Store the timestamp of when you last started pulling data from Merge as modified_after. Use this timestamp in subsequent API requests to pull updates from Merge since your last sync.
Use the expand parameter to pull multiple models that are related to each other instead of making multiple pulls for related information.
Query parameters:
GET /{endpoint}/?modified_after={timestamp}
Only pull data that has been changed or created since your last sync.
For example, you can ask for modified_after=2021-03-30T20:44:18, and only pull items that are new or changed.
GET /{endpoint}/?expand={common_model_name}
Pull related model information with a single API request.
For example, if you are querying for candidates and also want details about associated applications, you can expand=applications, and Merge will return the actual application objects instead of just the application_id.
Sync periodically and poll using /sync-status endpoint
Make sure to implement polling and don’t rely entirely on notification webhooks.
Webhooks can fail for a variety of reasons such as downtime or failed processing.
Merge does attempt to redeliver multiple times using exponential backoff, but we still recommend calling your sync functions periodically every 24 hours.
Make a request to our /sync-status endpoint, which returns an array of syncing statuses for all models in a category. See API reference to learn more.
- If status is
PARTIALLY SYNCEDorDONE, go ahead and retrieve data. If another sync has not started, since the last time you pulled data, there will not be new data. - If status is
SYNCING, continue pinging