The first step is to create a Hightouch API key in your Hightouch workspace settings.
From the API keys tab on the Settings page, click Add API key.
Enter a descriptive Name for your key.
Under User group, select the group whose permissions the key should have in this workspace, or select All of the creator’s groups to give the key the same permissions as you.
Copy your API key and store it in a safe location. The key is only displayed once.
Click Create API key.
Your API key provides read/write access to sensitive Hightouch resources and should be kept secure. If you believe your API key may have been compromised, revoke it immediately.
For the Dagster 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 Dagster, 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 Dagster.You can also find the sync ID on this page, which you need for scheduling syncs in the next step.
You can schedule syncs by using the hightouch_sync_op function with the sync IDs of the syncs you want to schedule.This example creates a job to trigger two syncs—one for Salesforce account objects and one for organization objects—every thirty minutes.
# The hightouch_sync_op calls the Hightouch API to trigger a sync, and then polls the API until the sync either completes or returns an error.from dagster import ScheduleDefinition, get_dagster_logger, jobfrom dagster_hightouch.ops import hightouch_sync_opfrom .resources import ht_resource# Set sync IDs as constantsSFDC_ACCOUNTS_SYNC_ID = "23620"SFDC_ORGS_SYNC_ID = "39619"# Define configured sync opsrun_ht_sync_accounts = hightouch_sync_op.configured( {"sync_id": SFDC_ACCOUNTS_SYNC_ID}, name="hightouch_sfdc_accounts")run_ht_sync_orgs = hightouch_sync_op.configured( {"sync_id": SFDC_ORGS_SYNC_ID}, name="hightouch_sfdc_organizations")# Create a job with the defined resources, specifying the dependencies@job( resource_defs={ "hightouch": ht_resource, })def ht_sfdc_job(): ht_orgs = run_ht_sync_orgs(start_after=ht_contacts) run_ht_sync_accounts(start_after=ht_orgs)# Schedule it to run as often as you like with a cron expression# This example shows every 30 minevery_30_schedule = ScheduleDefinition(job=ht_sfdc_job, cron_schedule="*/30 * * * *")
To learn more, check out the blog post about the extension.