All Docs
FeaturesAgentOS WorkUpdated March 12, 2026

Mailchimp Email Marketing Integration

Mailchimp Email Marketing Integration

The Mailchimp integration allows your organisation to sync employee and vendor contacts into Mailchimp audiences, create targeted contact segments, and monitor campaign performance — all from within the platform dashboard. Email preferences are managed per-contact with full GDPR compliance.


Prerequisites

  • A Mailchimp account with at least one Audience (list) created.
  • A Mailchimp API key. Format: <key>-<datacenter> e.g. abc123def456-us6.
    • Generate one in Mailchimp → Account → Extras → API keys.
  • No global environment variable is required. Each organisation provides its own API key through the dashboard UI.

Connecting Mailchimp

  1. Navigate to Dashboard → Integrations → Mailchimp.
  2. In the Connect Mailchimp panel, paste your API key into the field.
  3. Click Connect Mailchimp.

The platform validates the key format (must end in -usN) and immediately verifies it against the Mailchimp API. On success, the connection panel displays your Mailchimp account name, detected data centre, and sync status.

Note: API keys are stored encrypted (base64-encoded JSON) on a per-organisation basis. No key is shared across organisations.

Disconnecting

Click Disconnect in the connection panel. The connection is soft-deleted; all previously synced segment and campaign data is retained in the platform.


Contact Segments

Segments are logical groups of contacts mapped to a Mailchimp audience list. When a segment syncs, the platform pushes matching contacts to the corresponding Mailchimp list using the batch subscribe API (up to 500 contacts per call).

Creating a Segment

  1. Open the Segments tab on the Mailchimp dashboard page.
  2. Click New Segment.
  3. Fill in:
    • Name — a human-readable label (e.g. All Active Employees).
    • Description — optional context.
    • Segment typeemployee, vendor, or mixed.
    • Mailchimp Audience — select from the audiences fetched from your connected account.
  4. Optionally apply filter criteria:
    • Department
    • Location
    • Employment type
    • Employment status
  5. Click Create.

Syncing a Segment

  • Manual sync: Click the sync icon next to a segment in the list. An event-driven Inngest job (mailchimp-segment-sync) is triggered immediately.
  • Automatic sync: A scheduled job (mailchimp-scheduled-sync) runs every day at 05:00 UTC and fans out to all segments across all connected organisations.

Segment Statuses

StatusMeaning
pendingCreated but not yet synced
syncingSync job currently running
syncedLast sync completed successfully
errorLast sync encountered an error

Campaign Tracking

The platform imports Mailchimp campaign metadata and tracks key performance metrics.

Importing a Campaign

Use the Campaigns tab to import a campaign by its Mailchimp campaign ID (trackCampaign). Once imported, the following stats are tracked:

  • Open rate
  • Click rate
  • Campaign status (draft, scheduled, sending, sent, paused, cancelled)

Automatic Stats Refresh

A background job (mailchimp-campaign-stats-refresh) runs every 6 hours and refreshes stats for all campaigns that are not yet in a terminal state (sent or cancelled).


GDPR & Email Preferences

The integration includes per-contact opt-in/out management to support GDPR requirements.

How Consent Is Tracked

Every preference change records:

  • consentGivenAt — timestamp when the contact opted in.
  • consentWithdrawnAt — timestamp when the contact opted out.
  • Consent source — the channel or mechanism through which the preference was set.

Updating Opt Status

Use mailchimp.preferences.updateOptStatus (tRPC) to record an opt-in or opt-out for a given contact. All changes are written to the email_preferences table and emitted as audit log entries.

Right to Erasure

To fulfil a GDPR erasure request for a contact:

await trpc.mailchimp.preferences.gdprDelete.mutate({ entityId, entityType });

This removes the contact's preference records and removes them from Mailchimp audiences in accordance with their erasure request.


Background Jobs Reference

Inngest FunctionTriggerDescription
mailchimp-scheduled-syncCron — daily at 05:00 UTCIterates all connected orgs and dispatches segment sync events
mailchimp-segment-syncEvent-drivenSyncs a single segment to its mapped Mailchimp audience
mailchimp-campaign-stats-refreshCron — every 6 hoursRefreshes open/click rates for active campaigns

tRPC API Reference

All procedures are under the mailchimp namespace.

mailchimp.connection

ProcedureTypeDescription
getQueryReturns the current org's Mailchimp connection or null
connectMutationValidates and stores the API key; input: { apiKey: string }
disconnectMutationSoft-deletes the connection
listAudiencesQueryReturns all Mailchimp audiences for the connected account

mailchimp.segments

ProcedureTypeDescription
listQueryReturns paginated segments; input: { limit?: number }
getQueryReturns a single segment by ID
createMutationCreates a new segment
updateMutationUpdates segment name, description, or filter criteria
deleteMutationSoft-deletes a segment
syncMutationTriggers an immediate sync for a segment

mailchimp.campaigns

ProcedureTypeDescription
listQueryReturns tracked campaigns
getQueryReturns a single campaign by ID
trackCampaignMutationImports a Mailchimp campaign for tracking
refreshStatsMutationManually refreshes stats for a campaign

mailchimp.preferences

ProcedureTypeDescription
getForEntityQueryReturns preferences for a specific contact
listQueryReturns all preferences for the org
updateOptStatusMutationRecords an opt-in or opt-out for a contact
gdprDeleteMutationErases all preference data for a contact (right to erasure)

Database Tables

TablePurpose
mailchimp_connectionsStores one API connection per org
contact_segmentsSegment definitions with filter criteria and Mailchimp list mapping
campaign_trackingCampaign metadata and performance statistics
email_preferencesPer-contact GDPR consent records

All connections and segments use softDeletedAt for non-destructive removal. All state-changing operations are written to the platform audit log.