Actions
The ballerinax/mailchimp.marketing package exposes the following clients:
| Client | Purpose |
|---|---|
Client | Mailchimp Marketing API: audiences, members, campaigns, automations, templates, reports, and more. |
Client
Mailchimp Marketing API: audiences, members, campaigns, automations, templates, reports, and more.
Configuration
| Field | Type | Default | Description |
|---|---|---|---|
auth | http:CredentialsConfig | Required | HTTP Basic Auth credentials. Use any string for username and your Mailchimp API key for password. |
httpVersion | HttpVersion | HTTP_2_0 | HTTP protocol version. |
timeout | decimal | 60 | Request timeout in seconds. |
retryConfig | RetryConfig | () | Retry configuration for failed requests. |
secureSocket | ClientSecureSocket | () | SSL/TLS configuration. |
proxy | ProxyConfig | () | Proxy server configuration. |
circuitBreaker | CircuitBreakerConfig | () | Circuit breaker configuration. |
compression | Compression | () | Compression configuration. |
cache | CacheConfig | () | HTTP caching configuration. |
followRedirects | FollowRedirects | () | Redirect configuration. |
poolConfig | PoolConfiguration | () | Connection pool settings. |
validation | boolean | true | Enable or disable schema validation. |
Initializing the client
import ballerinax/mailchimp.marketing as mailchimp;
configurable string mailchimpApiKey = ?;
configurable string serviceUrl = ?;
mailchimp:Client mailchimpClient = check new ({
auth: {
username: "anystring",
password: mailchimpApiKey
}
}, serviceUrl);
Operations
API root & health
List API root resources
Returns the top-level resources available in the Mailchimp Marketing API.
Returns: APIRoot|error
Sample code:
mailchimp:APIRoot root = check mailchimpClient->/.get();
Sample response:
{"account_id": "abc123", "login_id": "[email protected]", "account_name": "My Company", "email": "[email protected]", "role": "owner", "industry_stats": {"open_rate": 0.17, "bounce_rate": 0.006, "click_rate": 0.028}}
Ping the API
Tests the API connection and authentication. Returns a health status.
Returns: APIHealthStatus|error
Sample code:
mailchimp:APIHealthStatus status = check mailchimpClient->/ping.get();
Sample response:
{"health_status": "Everything's Chimpy!"}
Audiences (lists)
Get all lists info
Retrieves information about all audiences (lists) in the account.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
queries | GetListsQueries | No | Optional query parameters for filtering, pagination, and field selection. |
Returns: SubscriberLists|error
Sample code:
mailchimp:SubscriberLists lists = check mailchimpClient->/lists.get();
Sample response:
{"lists": [{"id": "abc123def", "name": "My Newsletter", "contact": {"company": "My Company"}, "stats": {"member_count": 1500, "unsubscribe_count": 20, "open_rate": 35.5}}], "total_items": 1}
Add list
Creates a new audience (list) in the account.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
payload | SubscriberList3 | Yes | The audience configuration including name, contact info, and permission reminder. |
Returns: SubscriberList1|error
Sample code:
mailchimp:SubscriberList1 newList = check mailchimpClient->/lists.post({
name: "Product Updates",
contact: {
company: "My Company",
address1: "123 Main St",
city: "Atlanta",
state: "GA",
zip: "30301",
country: "US"
},
permission_reminder: "You signed up for product updates on our website.",
campaign_defaults: {
from_name: "My Company",
from_email: "[email protected]",
subject: "",
language: "en"
},
email_type_option: false
});
Sample response:
{"id": "def456ghi", "name": "Product Updates", "contact": {"company": "My Company"}, "stats": {"member_count": 0}, "date_created": "2025-01-15T10:30:00+00:00"}
Get list info
Retrieves information about a specific audience (list).
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
listId | string | Yes | The unique ID of the list. |
queries | GetListsIdQueries | No | Optional query parameters for field selection. |
Returns: SubscriberList1|error
Sample code:
mailchimp:SubscriberList1 list = check mailchimpClient->/lists/["abc123def"].get();
Sample response:
{"id": "abc123def", "name": "My Newsletter", "stats": {"member_count": 1500, "unsubscribe_count": 20, "open_rate": 35.5}, "date_created": "2024-06-01T08:00:00+00:00"}
Update list
Updates the settings for an existing audience (list).
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
listId | string | Yes | The unique ID of the list. |
payload | SubscriberList3 | Yes | The updated list configuration. |
Returns: SubscriberList1|error
Sample code:
mailchimp:SubscriberList1 updated = check mailchimpClient->/lists/["abc123def"].patch({
name: "Updated Newsletter Name",
contact: {
company: "My Company",
address1: "123 Main St",
city: "Atlanta",
state: "GA",
zip: "30301",
country: "US"
},
permission_reminder: "You signed up on our website.",
campaign_defaults: {
from_name: "My Company",
from_email: "[email protected]",
subject: "",
language: "en"
},
email_type_option: false
});
Sample response:
{"id": "abc123def", "name": "Updated Newsletter Name", "stats": {"member_count": 1500}}
Delete list
Deletes an audience (list) from the account.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
listId | string | Yes | The unique ID of the list. |
Returns: error?
Sample code:
check mailchimpClient->/lists/["abc123def"].delete();
Batch subscribe or unsubscribe
Batch subscribes or unsubscribes list members.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
listId | string | Yes | The unique ID of the list. |
payload | MembersToSubscribeUnsubscribeTofromAListInBatch | Yes | Batch member subscribe/unsubscribe payload. |
Returns: BatchUpdateListMembers|error
Sample code:
mailchimp:BatchUpdateListMembers result = check mailchimpClient->/lists/["abc123def"].post({
members: [
{ email_address: "[email protected]", status: "subscribed" },
{ email_address: "[email protected]", status: "subscribed" }
]
});
Sample response:
{"new_members": [{"id": "hash1", "email_address": "[email protected]", "status": "subscribed"}], "updated_members": [], "errors": [], "total_created": 2, "total_updated": 0, "error_count": 0}
List members
List members
Retrieves information about members in a specific audience list.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
listId | string | Yes | The unique ID of the list. |
queries | GetListsIdMembersQueries | No | Optional query parameters for filtering, pagination, and field selection. |
Returns: ListMembers1|error
Sample code:
mailchimp:ListMembers1 members = check mailchimpClient->/lists/["abc123def"]/members.get();
Sample response:
{"members": [{"id": "a1b2c3", "email_address": "[email protected]", "status": "subscribed", "merge_fields": {"FNAME": "John", "LNAME": "Doe"}, "stats": {"avg_open_rate": 0.42, "avg_click_rate": 0.12}}], "total_items": 1}
Add member
Adds a new member (subscriber) to an audience list.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
listId | string | Yes | The unique ID of the list. |
payload | AddListMembers1 | Yes | The member data including email address and subscription status. |
Returns: ListMembers2|error
Sample code:
mailchimp:ListMembers2 member = check mailchimpClient->/lists/["abc123def"]/members.post({
email_address: "[email protected]",
status: "subscribed",
merge_fields: {
"FNAME": "Jane",
"LNAME": "Smith"
}
});
Sample response:
{"id": "d4e5f6", "email_address": "[email protected]", "status": "subscribed", "merge_fields": {"FNAME": "Jane", "LNAME": "Smith"}, "timestamp_signup": "2025-03-15T14:30:00+00:00"}
Get member info
Retrieves information about a specific list member by their subscriber hash (MD5 hash of lowercase email).
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
listId | string | Yes | The unique ID of the list. |
subscriberHash | string | Yes | The MD5 hash of the lowercase email address or the email address itself. |
queries | GetListsIdMembersIdQueries | No | Optional query parameters for field selection. |
Returns: ListMembers2|error
Sample code:
mailchimp:ListMembers2 member = check mailchimpClient->/lists/["abc123def"]/members/["[email protected]"].get();
Sample response:
{"id": "a1b2c3", "email_address": "[email protected]", "status": "subscribed", "merge_fields": {"FNAME": "John", "LNAME": "Doe"}, "stats": {"avg_open_rate": 0.42, "avg_click_rate": 0.12}, "last_changed": "2025-02-20T09:15:00+00:00"}
Update member
Updates an existing list member's information.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
listId | string | Yes | The unique ID of the list. |
subscriberHash | string | Yes | The MD5 hash of the lowercase email address or the email address itself. |
payload | AddListMembers1 | Yes | The updated member data. |
Returns: ListMembers2|error
Sample code:
mailchimp:ListMembers2 updated = check mailchimpClient->/lists/["abc123def"]/members/["[email protected]"].patch({
merge_fields: {
"FNAME": "Jonathan"
}
});
Sample response:
{"id": "a1b2c3", "email_address": "[email protected]", "status": "subscribed", "merge_fields": {"FNAME": "Jonathan", "LNAME": "Doe"}}
Add or update member
Adds a new member or updates an existing member in the list (upsert).
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
listId | string | Yes | The unique ID of the list. |
subscriberHash | string | Yes | The MD5 hash of the lowercase email address or the email address itself. |
payload | AddListMembers2 | Yes | The member data to add or update. |
Returns: ListMembers2|error
Sample code:
mailchimp:ListMembers2 member = check mailchimpClient->/lists/["abc123def"]/members/["[email protected]"].put({
email_address: "[email protected]",
status_if_new: "subscribed",
merge_fields: {
"FNAME": "John",
"LNAME": "Doe"
}
});
Sample response:
{"id": "a1b2c3", "email_address": "[email protected]", "status": "subscribed", "merge_fields": {"FNAME": "John", "LNAME": "Doe"}}
Archive member
Archives a list member (soft delete). The member can be re-added later.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
listId | string | Yes | The unique ID of the list. |
subscriberHash | string | Yes | The MD5 hash of the lowercase email address or the email address itself. |
Returns: error?
Sample code:
check mailchimpClient->/lists/["abc123def"]/members/["[email protected]"].delete();
Permanently delete member
Permanently deletes a list member. This action cannot be undone.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
listId | string | Yes | The unique ID of the list. |
subscriberHash | string | Yes | The MD5 hash of the lowercase email address or the email address itself. |
Returns: error?
Sample code:
check mailchimpClient->/lists/["abc123def"]/members/["[email protected]"]/actions/'delete\-permanent.post();
Member tags & events
List member tags
Retrieves the tags assigned to a specific list member.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
listId | string | Yes | The unique ID of the list. |
subscriberHash | string | Yes | The MD5 hash of the lowercase email address or the email address itself. |
Returns: CollectionOfTags|error
Sample code:
mailchimp:CollectionOfTags tags = check mailchimpClient->/lists/["abc123def"]/members/["[email protected]"]/tags.get();
Sample response:
{"tags": [{"id": 1, "name": "VIP"}, {"id": 2, "name": "Early Adopter"}], "total_items": 2}
Add or remove member tags
Adds or removes tags from a specific list member.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
listId | string | Yes | The unique ID of the list. |
subscriberHash | string | Yes | The MD5 hash of the lowercase email address or the email address itself. |
payload | MemberTags | Yes | Tags to add or remove with their status. |
Returns: error?
Sample code:
check mailchimpClient->/lists/["abc123def"]/members/["[email protected]"]/tags.post({
tags: [
{ name: "VIP", status: "active" },
{ name: "OldTag", status: "inactive" }
]
});
Add event for member
Adds a custom event for a specific list member, which can trigger automations.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
listId | string | Yes | The unique ID of the list. |
subscriberHash | string | Yes | The MD5 hash of the lowercase email address or the email address itself. |
payload | Events | Yes | Event name and optional properties. |
Returns: error?
Sample code:
check mailchimpClient->/lists/["abc123def"]/members/["[email protected]"]/events.post({
name: "purchased_product",
properties: {
"product": "Widget Pro",
"price": "29.99"
}
});
List member events
Retrieves events for a specific list member.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
listId | string | Yes | The unique ID of the list. |
subscriberHash | string | Yes | The MD5 hash of the lowercase email address or the email address itself. |
Returns: CollectionOfEvents|error
Sample code:
mailchimp:CollectionOfEvents events = check mailchimpClient->/lists/["abc123def"]/members/["[email protected]"]/events.get();
Sample response:
{"events": [{"occurred_at": "2025-03-10T12:00:00+00:00", "name": "purchased_product", "properties": {"product": "Widget Pro"}}], "total_items": 1}
Segments
List segments
Retrieves all segments for a specific list.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
listId | string | Yes | The unique ID of the list. |
Returns: CollectionOfSegments|error
Sample code:
mailchimp:CollectionOfSegments segments = check mailchimpClient->/lists/["abc123def"]/segments.get();
Sample response:
{"segments": [{"id": 12345, "name": "Active Subscribers", "member_count": 500, "type": "saved", "created_at": "2025-01-10T08:00:00+00:00"}], "total_items": 1}
Add segment
Creates a new segment for a list.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
listId | string | Yes | The unique ID of the list. |
payload | List3 | Yes | Segment configuration including name and conditions. |
Returns: List4|error
Sample code:
mailchimp:List4 segment = check mailchimpClient->/lists/["abc123def"]/segments.post({
name: "High Engagement",
static_segment: ["[email protected]", "[email protected]"]
});
Sample response:
{"id": 12346, "name": "High Engagement", "member_count": 2, "type": "static", "created_at": "2025-03-15T10:00:00+00:00"}
Delete segment
Deletes a specific segment from a list.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
listId | string | Yes | The unique ID of the list. |
segmentId | string | Yes | The unique ID of the segment. |
Returns: error?
Sample code:
check mailchimpClient->/lists/["abc123def"]/segments/["12345"].delete();
Campaigns
List campaigns
Retrieves all campaigns in the account.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
queries | GetCampaignsQueries | No | Optional query parameters for filtering, pagination, and field selection. |
Returns: InlineResponse2007|error
Sample code:
mailchimp:InlineResponse2007 campaigns = check mailchimpClient->/campaigns.get();
Sample response:
{"campaigns": [{"id": "cam123", "type": "regular", "status": "sent", "settings": {"subject_line": "March Newsletter", "from_name": "My Company"}, "send_time": "2025-03-01T09:00:00+00:00", "report_summary": {"opens": 450, "clicks": 120}}], "total_items": 1}
Add campaign
Creates a new campaign.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
payload | Campaign | Yes | Campaign configuration including type, recipients, and settings. |
Returns: Campaign1|error
Sample code:
mailchimp:Campaign1 campaign = check mailchimpClient->/campaigns.post({
'type: "regular",
recipients: {
list_id: "abc123def"
},
settings: {
subject_line: "March Newsletter",
from_name: "My Company",
reply_to: "[email protected]"
}
});
Sample response:
{"id": "cam456", "type": "regular", "status": "save", "settings": {"subject_line": "March Newsletter", "from_name": "My Company"}, "create_time": "2025-03-15T10:30:00+00:00"}
Get campaign info
Retrieves information about a specific campaign.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
campaignId | string | Yes | The unique ID of the campaign. |
Returns: Campaign1|error
Sample code:
mailchimp:Campaign1 campaign = check mailchimpClient->/campaigns/["cam456"].get();
Sample response:
{"id": "cam456", "type": "regular", "status": "save", "settings": {"subject_line": "March Newsletter", "from_name": "My Company"}, "recipients": {"list_id": "abc123def"}}
Update campaign settings
Updates the settings of an existing campaign.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
campaignId | string | Yes | The unique ID of the campaign. |
payload | Campaign2 | Yes | The updated campaign settings. |
Returns: Campaign1|error
Sample code:
mailchimp:Campaign1 updated = check mailchimpClient->/campaigns/["cam456"].patch({
settings: {
subject_line: "Updated: March Newsletter",
from_name: "My Company",
reply_to: "[email protected]"
}
});
Sample response:
{"id": "cam456", "type": "regular", "status": "save", "settings": {"subject_line": "Updated: March Newsletter", "from_name": "My Company"}}
Delete campaign
Permanently deletes a campaign.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
campaignId | string | Yes | The unique ID of the campaign. |
Returns: error?
Sample code:
check mailchimpClient->/campaigns/["cam456"].delete();
Send campaign
Sends a campaign to the recipients.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
campaignId | string | Yes | The unique ID of the campaign. |
Returns: error?
Sample code:
check mailchimpClient->/campaigns/["cam456"]/actions/send.post();
Schedule campaign
Schedules a campaign for delivery at a specified time.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
campaignId | string | Yes | The unique ID of the campaign. |
payload | Body1 | Yes | Schedule configuration with send time. |
Returns: error?
Sample code:
check mailchimpClient->/campaigns/["cam456"]/actions/schedule.post({
schedule_time: "2025-04-01T09:00:00+00:00"
});
Unschedule campaign
Unschedules a previously scheduled campaign.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
campaignId | string | Yes | The unique ID of the campaign. |
Returns: error?
Sample code:
check mailchimpClient->/campaigns/["cam456"]/actions/unschedule.post();
Replicate campaign
Creates a copy of an existing campaign.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
campaignId | string | Yes | The unique ID of the campaign to copy. |
Returns: Campaign3|error
Sample code:
mailchimp:Campaign3 copy = check mailchimpClient->/campaigns/["cam456"]/actions/replicate.post();
Sample response:
{"id": "cam789", "type": "regular", "status": "save", "settings": {"subject_line": "March Newsletter"}, "create_time": "2025-03-15T11:00:00+00:00"}
Send test email
Sends a test email to specified email addresses.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
campaignId | string | Yes | The unique ID of the campaign. |
payload | Body2 | Yes | Test email configuration with recipient addresses and email type. |
Returns: error?
Sample code:
check mailchimpClient->/campaigns/["cam456"]/actions/test.post({
test_emails: ["[email protected]"],
send_type: "html"
});
Get send checklist
Reviews the send checklist for a campaign and resolves any issues before sending.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
campaignId | string | Yes | The unique ID of the campaign. |
Returns: SendChecklist|error
Sample code:
mailchimp:SendChecklist checklist = check mailchimpClient->/campaigns/["cam456"]/send\-checklist.get();
Sample response:
{"is_ready": true, "items": [{"type": "success", "id": "list", "heading": "List", "details": "My Newsletter (1500 recipients)"}]}
Campaign content
Get campaign content
Retrieves the HTML and plain-text content for a campaign.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
campaignId | string | Yes | The unique ID of the campaign. |
Returns: CampaignContent|error
Sample code:
mailchimp:CampaignContent content = check mailchimpClient->/campaigns/["cam456"]/content.get();
Sample response:
{"plain_text": "Hello, welcome to our newsletter!", "html": "<html><body><h1>Welcome!</h1></body></html>"}
Set campaign content
Sets the content (HTML, plain text, or template) for a campaign.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
campaignId | string | Yes | The unique ID of the campaign. |
payload | CampaignContent1 | Yes | The campaign content configuration. |
Returns: CampaignContent|error
Sample code:
mailchimp:CampaignContent content = check mailchimpClient->/campaigns/["cam456"]/content.put({
html: "<html><body><h1>March Newsletter</h1><p>Hello *|FNAME|*!</p></body></html>"
});
Sample response:
{"plain_text": "March Newsletter\nHello *|FNAME|*!", "html": "<html><body><h1>March Newsletter</h1><p>Hello *|FNAME|*!</p></body></html>"}
Automations
List automations
Retrieves a summary of all automations in the account.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
queries | GetAutomationsQueries | No | Optional query parameters for filtering and pagination. |
Returns: InlineResponse2005|error
Sample code:
mailchimp:InlineResponse2005 automations = check mailchimpClient->/automations.get();
Sample response:
{"automations": [{"id": "auto123", "status": "sending", "settings": {"title": "Welcome Series"}, "emails_sent": 350, "create_time": "2025-01-01T08:00:00+00:00"}], "total_items": 1}
Add automation
Creates a new automation workflow.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
payload | AutomationWorkflow | Yes | Automation configuration including recipients and settings. |
Returns: AutomationWorkflow1|error
Sample code:
mailchimp:AutomationWorkflow1 automation = check mailchimpClient->/automations.post({
recipients: {
list_id: "abc123def"
},
settings: {
title: "Welcome Series"
},
trigger_settings: {
workflow_type: "welcomeSeries"
}
});
Sample response:
{"id": "auto456", "status": "save", "settings": {"title": "Welcome Series"}, "create_time": "2025-03-15T12:00:00+00:00"}
Pause automation emails
Pauses all emails in an automation workflow.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
workflowId | string | Yes | The unique ID of the automation workflow. |
Returns: error?
Sample code:
check mailchimpClient->/automations/["auto123"]/actions/'pause\-all\-emails.post();
Start automation emails
Starts all emails in a paused automation workflow.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
workflowId | string | Yes | The unique ID of the automation workflow. |
Returns: error?
Sample code:
check mailchimpClient->/automations/["auto123"]/actions/'start\-all\-emails.post();
Templates
List templates
Retrieves all templates in the account.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
queries | GetTemplatesQueries | No | Optional query parameters for filtering and pagination. |
Returns: Templates|error
Sample code:
mailchimp:Templates templates = check mailchimpClient->/templates.get();
Sample response:
{"templates": [{"id": 10001, "type": "user", "name": "Monthly Newsletter", "active": true, "date_created": "2025-01-05T08:00:00+00:00"}], "total_items": 1}
Add template
Creates a new template with custom HTML.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
payload | TemplateInstance | Yes | Template configuration with name and HTML content. |
Returns: TemplateInstance1|error
Sample code:
mailchimp:TemplateInstance1 template = check mailchimpClient->/templates.post({
name: "Product Launch",
html: "<html><body><h1>New Product!</h1><p>Check it out.</p></body></html>"
});
Sample response:
{"id": 10002, "type": "user", "name": "Product Launch", "active": true, "date_created": "2025-03-15T14:00:00+00:00"}
Delete template
Deletes a specific template.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
templateId | string | Yes | The unique ID of the template. |
Returns: error?
Sample code:
check mailchimpClient->/templates/["10001"].delete();
Template folders
List template folders
Retrieves all template folders in the account.
Returns: TemplateFolders|error
Sample code:
mailchimp:TemplateFolders folders = check mailchimpClient->/template\-folders.get();
Sample response:
{"folders": [{"id": "tf001", "name": "Marketing Templates", "count": 5}], "total_items": 1}
Add template folder
Creates a new template folder.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
payload | TemplateFolder | Yes | Folder configuration with a name. |
Returns: TemplateFolder1|error
Sample code:
mailchimp:TemplateFolder1 folder = check mailchimpClient->/template\-folders.post({
name: "Seasonal Campaigns"
});
Sample response:
{"id": "tf002", "name": "Seasonal Campaigns", "count": 0}
Campaign folders
List campaign folders
Retrieves all campaign folders in the account.
Returns: CampaignFolders|error
Sample code:
mailchimp:CampaignFolders folders = check mailchimpClient->/campaign\-folders.get();
Sample response:
{"folders": [{"id": "cf001", "name": "Q1 Campaigns", "count": 3}], "total_items": 1}
Add campaign folder
Creates a new campaign folder.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
payload | CampaignFolder | Yes | Folder configuration with a name. |
Returns: CampaignFolder1|error
Sample code:
mailchimp:CampaignFolder1 folder = check mailchimpClient->/campaign\-folders.post({
name: "Q2 Campaigns"
});
Sample response:
{"id": "cf002", "name": "Q2 Campaigns", "count": 0}
Batch operations
List batch requests
Retrieves a list of batch operation requests.
Returns: BatchOperations|error
Sample code:
mailchimp:BatchOperations batches = check mailchimpClient->/batches.get();
Sample response:
{"batches": [{"id": "batch001", "status": "finished", "total_operations": 100, "finished_operations": 100, "submitted_at": "2025-03-10T08:00:00+00:00"}], "total_items": 1}
Start batch operation
Starts a new batch operation with multiple API calls.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
payload | Body7 | Yes | Batch request configuration with an array of operations. |
Returns: Batch|error
Sample code:
mailchimp:Batch batch = check mailchimpClient->/batches.post({
operations: [
{
method: "GET",
path: "/lists/abc123def/members",
operation_id: "get-members"
}
]
});
Sample response:
{"id": "batch002", "status": "pending", "total_operations": 1, "submitted_at": "2025-03-15T15:00:00+00:00"}
Get batch operation status
Retrieves the status of a specific batch operation.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
batchId | string | Yes | The unique ID of the batch operation. |
Returns: Batch|error
Sample code:
mailchimp:Batch batch = check mailchimpClient->/batches/["batch002"].get();
Sample response:
{"id": "batch002", "status": "finished", "total_operations": 1, "finished_operations": 1, "errored_operations": 0, "submitted_at": "2025-03-15T15:00:00+00:00", "completed_at": "2025-03-15T15:01:00+00:00"}
File manager
List stored files
Retrieves a list of all files in the file manager.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
queries | GetFileManagerFilesQueries | No | Optional query parameters for filtering and pagination. |
Returns: FileManager|error
Sample code:
mailchimp:FileManager files = check mailchimpClient->/file\-manager/files.get();
Sample response:
{"files": [{"id": 1001, "name": "logo.png", "type": "image", "size": 24680, "full_size_url": "https://gallery.mailchimp.com/logo.png"}], "total_items": 1, "total_file_size": 24680}
Add file
Uploads a new file to the file manager.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
payload | GalleryFile | Yes | File upload payload with name and base64-encoded file data. |
Returns: GalleryFile1|error
Sample code:
mailchimp:GalleryFile1 file = check mailchimpClient->/file\-manager/files.post({
name: "banner.png",
file_data: "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk..."
});
Sample response:
{"id": 1002, "name": "banner.png", "type": "image", "size": 15360, "full_size_url": "https://gallery.mailchimp.com/banner.png", "created_at": "2025-03-15T16:00:00+00:00"}
Search
Search campaigns
Searches all campaigns for the specified query terms.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
queries | GetSearchCampaignsQueries | Yes | Query parameters including the search query string. |
Returns: InlineResponse20014|error
Sample code:
mailchimp:InlineResponse20014 results = check mailchimpClient->/search\-campaigns.get(queries = { query: "newsletter" });
Sample response:
{"results": [{"campaign": {"id": "cam123", "settings": {"subject_line": "March Newsletter"}}}], "total_items": 1}
Search members
Searches for list members across all lists matching the query.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
queries | GetSearchMembersQueries | Yes | Query parameters including the search query string. |
Returns: Members|error
Sample code:
mailchimp:Members results = check mailchimpClient->/search\-members.get(queries = { query: "[email protected]" });
Sample response:
{"exact_matches": {"members": [{"id": "a1b2c3", "email_address": "[email protected]", "status": "subscribed", "list_id": "abc123def"}], "total_items": 1}, "full_search": {"members": [], "total_items": 0}}
Connected sites
List connected sites
Retrieves all connected sites in the account.
Returns: ConnectedSites|error
Sample code:
mailchimp:ConnectedSites sites = check mailchimpClient->/connected\-sites.get();
Sample response:
{"sites": [{"foreign_id": "site001", "store_id": "store001", "platform": "shopify", "domain": "mystore.example.com", "site_script": {"url": "https://chimpstatic.com/mcjs-connected/js/users/abc123.js"}}], "total_items": 1}
Account exports
List account exports
Retrieves a list of account data exports.
Returns: InlineResponse2001|error
Sample code:
mailchimp:InlineResponse2001 exports = check mailchimpClient->/account\-exports.get();
Sample response:
{"exports": [{"export_id": "exp001", "started": "2025-03-10T08:00:00+00:00", "finished": "2025-03-10T08:05:00+00:00", "size_in_bytes": 1048576}], "total_items": 1}
Add export
Creates a new account export.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
payload | CreateAnAccountExport | Yes | Export configuration with included data types. |
Returns: InlineResponse2002|error
Sample code:
mailchimp:InlineResponse2002 export = check mailchimpClient->/account\-exports.post({
include_stages: ["audiences", "campaigns"]
});
Sample response:
{"export_id": "exp002", "started": "2025-03-15T17:00:00+00:00", "finished": null, "size_in_bytes": 0}
Customer journeys
Trigger customer journey step
Triggers a specific step in a customer journey for one or more contacts.
Parameters:
| Name | Type | Required | Description |
|---|---|---|---|
journeyId | int | Yes | The unique ID of the customer journey. |
stepId | int | Yes | The unique ID of the journey step. |
payload | Body11 | Yes | Trigger payload with email address to trigger the journey step for. |
Returns: record {}|error
Sample code:
record {} result = check mailchimpClient->/customer\-journeys/journeys/[1234]/steps/[5678]/actions/trigger.post({
email_address: "[email protected]"
});
Sample response:
{}