Nightly sync of MailForge unsubscribes into HubSpot
Every night at 2am, flag anyone who unsubscribed or bounced in MailForge as email opted-out in HubSpot so sales never re-mails them.
Build me a scheduled code workflow that syncs my MailForge suppression list into HubSpot every night so anyone who unsubscribed or bounced in MailForge is also flagged as email opted-out in the CRM. This is a deterministic pipeline with no reasoning steps — fetch, iterate, look up, update — so please build it as a code workflow.
Trigger: cron, daily at 02:00 in the workspace timezone.
Steps:
1) Call the MailForge List Suppressions operation and page through every suppressed email address. Use per_page=100 and keep advancing page until the response indicates there are no more pages. Collect the full list of suppressed emails (with their reason and suppressed-at timestamp if available).
2) For each suppressed email, call the HubSpot Search Contacts operation filtered by that email address to find the matching CRM record. If no contact is returned, skip silently and continue. If a contact is returned, read its current email opt-out property.
3) If the contact's opt-out flag is already true, short-circuit and move on (do not call Update Contact). If it is not already set, call the HubSpot Update Contact operation for that contact id and set the email opt-out property (default to hs_email_optout, but let me pick a different property name at setup time) to true. Also stamp a last-synced timestamp property (default name mailforge_suppression_last_synced_at) with the current ISO-8601 datetime.
4) At the end of the run, log a compact summary: total suppressions fetched, contacts matched in HubSpot, contacts newly opted out, contacts already opted out and skipped, and emails with no HubSpot match.
Requirements: the run must be idempotent (rerunning the same day should be a no-op after the first successful pass). Respect HubSpot's Search API rate limit of 4 requests per second; add gentle spacing between search calls. On HTTP 429 from HubSpot, honor the Retry-After header. Do not create new HubSpot contacts under any circumstances — this workflow only updates records that already exist.
Connections I will provide: MailForge (API key + instance URL) and HubSpot (OAuth with crm.objects.contacts.read and crm.objects.contacts.write).
Additional information
What does this prompt do?
- Runs quietly every night at 2am and pulls every suppressed email address out of MailForge (unsubscribes, bounces, complaints, and manual adds).
- Looks up each of those addresses in HubSpot and, when it finds a matching contact, marks them as opted out of email so your sales sequences skip them.
- Stamps a last synced date on every updated contact so you can see exactly which records the sync has touched.
- Skips addresses that have no HubSpot record and contacts that are already opted out, so reruns stay clean and quota friendly.
What do I need to use this?
- A MailForge account you can log in to (you will paste a key from Settings and your instance web address).
- A HubSpot account with permission to view and update contact records.
- About five minutes to connect both accounts the first time you run the workflow.
How can I customize it?
- Change when it runs. Move the schedule earlier, later, or to a weekly cadence if daily is more than you need.
- Choose which HubSpot field gets set. The default is the standard email opt-out field, but you can point it at a custom checkbox or a status field your team already uses.
- Narrow the scope. If you only want to sync hard bounces and unsubscribes (and ignore soft bounces), filter the MailForge list before it reaches HubSpot.
Frequently asked questions
Will this delete or archive HubSpot contacts?
What happens to email addresses that are not in HubSpot?
Does it re-update contacts that are already opted out?
How long will the nightly run take?
Can I run this against a sandbox HubSpot first?
Related templates
Stop re-emailing people who already unsubscribed.
Connect MailForge and HubSpot once, and Geni keeps your CRM opt-out status in sync with your email tool every night.