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:
Key | Type | Default | Description |
---|---|---|---|
apiKey | string | @mailchimp-api-key | Your Mailchimp API key |
audience | string | @mailchimp-audience | Your Mailchimp audience ID |
statusIfNew | object | subscribed | The subscriber's status (see here for available values) |
mergeFields | object | {} | 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:
Key | Type | Default | Description |
---|---|---|---|
emailAddress * | string | The contact's email address | |
mergeFields | object | {} | 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: "janedoe@example.com",mergeFields: {FNAME: "Jane",LNAME: "Doe"}});
Response
Returns a status
and the following properties when successful:
Key | Type | Description |
---|---|---|
id | string | The MD5 hash of the lowercase version of the list member's email address. |