How is your experience with the OutSystems Community?
mailchimp-connector
Service icon

Mailchimp Connector

Stable version 2.0.0 (Compatible with OutSystems 11)
Uploaded
 on 24 Nov (3 days ago)
 by 
5.0
 (2 ratings)
mailchimp-connector

Mailchimp Connector

Documentation
2.0.0

1. Overview

Mailchimp Connector wraps the Mailchimp Marketing API 3.0 (https://.api.mailchimp.com/3.0) in 87 server actions for OutSystems 11.

  • Module: MailchimpConnector (Service module).
  • Authentication: a Mailchimp API key, sent as a Bearer token. The key lives in a Secret site property and never reaches the browser.
  • Data center: taken from the suffix of the key (for example, -us7), or from the ServerPrefix site property.
  • Every action returns the same outputs, so error handling looks the same everywhere.


2. Installation

  1. Install the component from the Forge into your environment (OutSystems 11.8 or later).
  2. In Mailchimp, open your profile > Extras > API keys > Create A Key. Copy the key: Mailchimp shows it only once.
  3. In Service Center, open Factory > Modules > MailchimpConnector > Site Properties and set ApiKey.
  4. Call Ping from any server action. Success = True means the setup is correct.

Repeat step 3 in every environment (Development, Test, Production), each with its own key if possible.

3. Configuration

  • ApiKey (Text, Secret): the Mailchimp API key, for example 0123456789abcdef0123456789abcdef-us7.
  • ServerPrefix (Text, optional): the data center, for example us7.

The key has the role of the Mailchimp user who created it. GetAccount returns that role. A 403 usually means the role is too limited.


4. Using the connector in your module

  1. Open Manage Dependencies, select MailchimpConnector, and pick the actions and structures you need.
  2. Call the actions from server-side logic: a server action, a data action, or a timer. Do not expose them to the browser without your own role checks: anyone who can call them can change your Mailchimp account.
  3. After each call, check Success. When it is False, read ErrorCode, ErrorMessage, and Errors.

5. Common outputs

Every public action returns:

  • Success (Boolean): True when Mailchimp answered with a 2xx status.
  • ErrorCode (Integer): the HTTP status returned by Mailchimp, -1 for an unexpected error (for example, a timeout or an empty ApiKey), 0 on success.
  • ErrorMessage (Text): the Mailchimp error title and detail, or the exception message for -1.
  • Errors (ErrorField List): validation errors per field (Field, Message), when Mailchimp returns them.
  • ResponseJSON (Text): the raw response body. Useful for debugging and for fields without a typed output.

Depending on the action, there is also:

  • Response: the typed record (Audience, Member, Campaign, Template, CampaignReport, Batch, ...).
  • Items and TotalItems: for List actions.


6. Identifying members

MemberKey accepts any of these:

  • the email address, for example ana@example.com;
  • the subscriber hash: the MD5 hash of the lowercase email address (Member.Id);
  • the contact id (Member.ContactId).


7. Pagination

List actions use offset pagination (ListWebhooks, ListAutomationEmails and SearchTags return everything in one call):

  1. Call the action with Count (1 to 1000; 0 = 100) and Offset = 0.
  2. Call it again with Offset = Offset + Count while Offset < TotalItems.

Prefer large pages (Count = 1000) and filters (Status, SinceLastChanged) over many small calls.

8. Request bodies

  • Typed inputs cover the common fields: Audience, Member, MemberTags, MemberEvent, MergeField, Segment, InterestCategory, Interest, Webhook, Campaign, CampaignContent, CampaignTest, CampaignSchedule, Template, BatchSubscribe and Batch.
  • Empty and False values are not sent, so Mailchimp keeps its defaults.
  • AdditionalJSON adds raw JSON members to the body, for options without a typed input or to send an explicit false. Write members without braces, for example:
    • "interests":{"9143cf3bd1":true,"3a2a927344":false}
    • "double_optin":false
    • "options":{"match":"any","conditions":[{"condition_type":"TextMerge","field":"FNAME","op":"is","value":"Ana"}]}
  • Members also accept MergeFieldsJSON: merge fields as a JSON object by tag, for example {"COMPANY":"Acme","PLAN":"pro"}. It is merged with Member.MergeFields.
  • Batch operations: BatchOperation.Body is a JSON string, for example {"email_address":"ana@example.com","status":"subscribed"}.


9. Common tasks

Add or update a contact (upsert):

  1. Call CreateOrUpdateMember with AudienceId and MemberKey = the email address.
  2. Fill Member.EmailAddress and Member.StatusIfNew (subscribed, or pending to send a confirmation email).
  3. Member.Status changes the status of a member that already exists.

Unsubscribe a contact:

  • Call UpdateMember with Member.Status = "unsubscribed".

Remove a contact:

  • ArchiveMember: the contact can be added again later.
  • DeleteMemberPermanently: deletes the personal data (GDPR). The email address cannot be added again through the API.

Tag contacts:

  • UpdateMemberTags with a list of TagUpdate (Name, Status = active or inactive).
  • Or, for a known tag id, AddSegmentMember and RemoveSegmentMember.

Send a campaign:

  1. CreateCampaign with Campaign.Type = "regular", Campaign.Recipients.ListId and Campaign.Settings (SubjectLine, FromName, ReplyTo).
  2. SetCampaignContent with CampaignContent.Html (or Url, or Template.Id).
  3. GetSendChecklist and check Response.IsReady.
  4. SendTestEmail with CampaignTest.TestEmails.
  5. SendCampaign, or ScheduleCampaign with CampaignSchedule.ScheduleTime in UTC on a quarter hour, for example 2026-12-01T09:00:00+00:00.

Start a customer journey for a contact:

  • In Mailchimp, add an API starting point to the journey. Its URL has the journey id and the step id.
  • Call TriggerJourneyStep with JourneyId, StepId and EmailAddress.

Import many contacts:

  • Up to 500 per call: BatchSubscribeMembers. Check Response.Errors.
  • More, or mixed operations: CreateBatch. Then call GetBatch until Status = finished and download ResponseBodyUrl (a .tar.gz with one result per operation).


10. Errors and rate limits

  • 400: invalid data, or a rule was broken (for example Member Exists, Invalid Resource). Errors has the details per field.
  • 401: API key missing, invalid or revoked. Check ApiKey.
  • 403: the user of the key cannot do this operation, or the account is disabled.
  • 404: the record does not exist.
  • 405: the method is not allowed for this resource (for example deleting a sent campaign).
  • 429: too many requests. Mailchimp allows 10 simultaneous connections per key. Wait a few seconds and try again. Do not call the connector inside a big loop: use BatchSubscribeMembers or CreateBatch.
  • 5xx: Mailchimp error. Try again later.
  • -1: unexpected error (timeout, network, empty ApiKey, data center not found). The error is logged in Service Center.

Timeouts: 30 seconds per call, 60 seconds for BatchSubscribeMembers and CreateBatch.

11. Security

  • The API key is a Secret site property. It is not stored in the module, in logs of the module, or in client-side code.
  • Every call uses https. The base URL is built from the data center of the key and never from an input.
  • The connector does not check who calls it. Add your own role checks in the module that consumes it.
  • Mailchimp webhooks have no signature. Use a secret in the webhook URL (for example ?key=...) and check it in your exposed REST API.


12. How it works

  • REST API Mailchimp: one Rest_ method per action. Request and response bodies are Text (JSON).
  • OnBeforeRequest: checks ApiKey, finds the data center, sets the base URL and adds the Authorization: Bearer header.
  • OnAfterResponse: for 4xx and 5xx answers, sets the status to 200 and adds the original status in the X-MC-Status header. The wrapper reads it and maps the problem+json body to ErrorCode, ErrorMessage and Errors.
  • Each public action: serializes the body, calls the REST method, deserializes the response and catches every exception.


13. Upgrading from 1.0.0

  1. Create an API key in Mailchimp and set ApiKey in Service Center. The old key was stored in the module: revoke it in Mailchimp.
  2. Refresh the dependency in every consumer module.
  3. Rename the calls:
    • GetLists > ListAudiences; GetListById > GetAudience; CreateUpdateList > CreateAudience or UpdateAudience; DeleteList > DeleteAudience;
    • GetMembersByListId > ListMembers; AddMemberToList > AddMember (or CreateOrUpdateMember); ChangeMemberStatus, SubscribeMember and UnsubscribeMember > UpdateMember with Member.Status;
    • RemoveListMember > ArchiveMember (FullDelete = False) or DeleteMemberPermanently (FullDelete = True);
    • GetCampaigns > ListCampaigns; GetCampaignById > GetCampaign; ReSendCampaign > CreateResendCampaign;
    • CreateCampaign with content > CreateCampaign, then SetCampaignContent, then SendCampaign.
  4. Replace exception handlers with checks on Success and ErrorCode.
  5. Lists now return 100 records by default (1000 at most). Use Offset for the next pages.

14. Demo app

  • Module: MailchimpConnectorDemo (Reactive). Start on Setup and click Test connection.
  • Screens: Setup, Audiences, Audience, Members, Member, Campaigns, Campaign, Templates, Automations, Advanced.
  • Every screen shows the last call (operation, HTTP status, error message, errors per field, raw JSON).
  • It acts on your real Mailchimp account: use a test audience and test email addresses.


15. Known limitations

  • Campaign type absplit is deprecated by Mailchimp: use variate.
  • The member activity feed returns no total and its events have different shapes per type: use ResponseJSON for the full events.
  • Dates are Text (ISO 8601), as Mailchimp returns them.
  • Merge fields other than FNAME, LNAME, PHONE and BIRTHDAY, interests and other dynamic objects are only in ResponseJSON.
  • E-commerce (stores, products, orders), signup forms, landing pages, file manager and the Audiences endpoints (BETA) are not wrapped. Use CreateBatch with the path you need, or ask for them in the Forge discussions.
  • Mailchimp Transactional (Mandrill) is a separate API and is not included.