addOrUpdateListMember

Adds or updates a contact in a Mailchimp audience. Under the hood, this action calls the add or update a list member API endpoint.

Configuration

This function type accepts the following parameters:

KeyTypeDefaultDescription
apiKeystring@mailchimp-api-keyYour Mailchimp API key
audiencestring@mailchimp-audienceYour Mailchimp audience ID
statusIfNewobjectsubscribedThe subscriber's status (see here for available values)
mergeFieldsobject{}Static merge fields to set on the contact

Example

{
"functions": {
"addToMailchimp": {
"app": "mailchimp",
"type": "addOrUpdateListMember",
"audience": "5ca598e7e8",
"mergeFields": {
"PLAN": "pro"
}
}
}
}

Arguments

This function type accepts the following client-side arguments when called:

KeyTypeDefaultDescription
emailAddress *stringThe contact's email address
mergeFieldsobject{}Dynamic merge fields to set on the contact

Example

import { createClient, addToMailchimp } from '@statickit/functions';
let client = createClient({ site: '{your-site-id}' });
let { status } = await addToMailchimp(client, {
emailAddress: "[email protected]",
mergeFields: {
FNAME: "Jane",
LNAME: "Doe"
}
});

Response

Returns a status and the following properties when successful:

KeyTypeDescription
idstringThe MD5 hash of the lowercase version of the list member's email address.