Mage provides a native
HightouchClient to trigger Hightouch syncs. Check out the Mage's integration documentation for usage details.
To use Mage to trigger syncs, you need a Hightouch API key.
The first step is to create a Hightouch API key in your Hightouch workspace settings.
- From the API keys tab on the Settings page, select Add API key.
- Enter a descriptive Name for your key.
- Copy your API key and store it in a safe location. The key will only be displayed once.
- Click Create API key.
For the Mage extension to trigger syncs via the Hightouch API, you must set the syncs' schedules to Manual.
You can do this by going to the Syncs overview page, selecting the particular sync you want to trigger with Mage, and opening the Schedule tab. Here, make sure the Schedule type is set to Manual. You should do this for each sync you want to trigger with Mage.
You can also find the sync ID on this page, which you need for scheduling syncs in the next step.
You can then trigger a sync with Mage's
from mage_ai.services.hightouch.hightouch import HightouchClient client = HightouchClient(config=dict(api_key='api_key')) syncs = client.list_syncs() # Get all the syncs sync_id = syncs['data']['id'] # Get sync id client.sync_and_poll(sync_id) # Trigger sync and poll status
If successful, the output looks like this:
Polling Hightouch Sync [id]. Current status: querying. 0% completed. Polling Hightouch Sync [id]. Current status: success. 100% completed. Sync request status: success. Polling complete