Skip to main content
RapidDev - Software Development Agency
flutterflow-tutorials

How to Integrate FlutterFlow with Mailchimp

Connect FlutterFlow to Mailchimp by deploying a Cloud Function that calls the Mailchimp Marketing API with your API key. The Cloud Function handles subscriber creation (POST /lists/{listId}/members), updates (PATCH with subscriber hash), and preference management. FlutterFlow calls the Cloud Function URL via the API Manager — never call Mailchimp directly from the app because it would expose your API key. Use cases include adding users to a list on signup, tagging purchasers as customers, and updating email preferences.

What you'll learn

  • How to deploy a Cloud Function that calls the Mailchimp Marketing API securely
  • How to add a subscriber to a Mailchimp audience list from a FlutterFlow form
  • How to use merge fields and tags to personalize subscriber data
  • How to update subscriber preferences and handle already-subscribed errors gracefully
Book a free consultation
4.9Clutch rating
600+Happy partners
17+Countries served
190+Team members
Beginner10 min read30-45 minFlutterFlow Free+March 2026RapidDev Engineering Team
TL;DR

Connect FlutterFlow to Mailchimp by deploying a Cloud Function that calls the Mailchimp Marketing API with your API key. The Cloud Function handles subscriber creation (POST /lists/{listId}/members), updates (PATCH with subscriber hash), and preference management. FlutterFlow calls the Cloud Function URL via the API Manager — never call Mailchimp directly from the app because it would expose your API key. Use cases include adding users to a list on signup, tagging purchasers as customers, and updating email preferences.

Add Mailchimp subscriber management to your FlutterFlow app

Mailchimp is the most widely used email marketing platform, and integrating it with your FlutterFlow app lets you grow your mailing list automatically as users sign up, tag subscribers based on in-app actions (purchases, plan upgrades, feature usage), and keep Mailchimp contact data in sync with your app's user data. The integration uses Mailchimp's Marketing API v3, which requires an API key and audience list ID. All API calls go through a Cloud Function to keep the key server-side. This tutorial covers adding subscribers, updating existing contacts, and managing email preference toggles in your FlutterFlow app.

Prerequisites

  • A Mailchimp account with at least one Audience (list) created
  • A Firebase project with Cloud Functions enabled (Blaze billing plan required for outbound HTTP calls)
  • Your Mailchimp API key (Mailchimp Account → Profile → Extras → API keys → Create A Key) and Audience List ID (Mailchimp → Audience → Audience dashboard → Settings → Audience name and defaults → Audience ID)

Step-by-step guide

1

Deploy the Mailchimp subscriber Cloud Function

In your Firebase project, create a Cloud Function named addToMailchimp. Install the dependency: npm install @mailchimp/mailchimp_marketing in your functions directory. The function receives email, firstName, lastName, and optional tags array from FlutterFlow. It constructs the subscriber hash by MD5-hashing the lowercase email (required by Mailchimp for upserts). It calls mailchimp.lists.setListMember (a PUT that creates OR updates) with status: 'subscribed', merge_fields: {FNAME, LNAME}, and tags. Set MAILCHIMP_API_KEY and MAILCHIMP_LIST_ID as environment variables in your Cloud Function (in Firebase Console → Functions → your function → Edit → Environment variables — never hardcode them). Return {success: true, id: subscriber.id} to FlutterFlow.

add_to_mailchimp.js
1const functions = require('firebase-functions');
2const mailchimp = require('@mailchimp/mailchimp_marketing');
3const crypto = require('crypto');
4
5mailchimp.setConfig({
6 apiKey: process.env.MAILCHIMP_API_KEY,
7 server: process.env.MAILCHIMP_SERVER_PREFIX // e.g. 'us21'
8});
9
10exports.addToMailchimp = functions.https.onCall(async (data, context) => {
11 const { email, firstName, lastName, tags = [] } = data;
12 if (!email) throw new functions.https.HttpsError('invalid-argument', 'Email required');
13
14 const listId = process.env.MAILCHIMP_LIST_ID;
15 // Mailchimp subscriber hash = MD5 of lowercase email
16 const subscriberHash = crypto
17 .createHash('md5')
18 .update(email.toLowerCase())
19 .digest('hex');
20
21 try {
22 const response = await mailchimp.lists.setListMember(listId, subscriberHash, {
23 email_address: email.toLowerCase(),
24 status_if_new: 'subscribed',
25 merge_fields: {
26 FNAME: firstName || '',
27 LNAME: lastName || ''
28 }
29 });
30
31 // Add tags separately if provided
32 if (tags.length > 0) {
33 await mailchimp.lists.updateListMemberTags(listId, subscriberHash, {
34 tags: tags.map(tag => ({ name: tag, status: 'active' }))
35 });
36 }
37
38 return { success: true, id: response.id };
39 } catch (err) {
40 throw new functions.https.HttpsError('internal', err.message);
41 }
42});

Expected result: Deploying this Cloud Function gives you a callable endpoint that adds or updates Mailchimp subscribers with name fields and tags.

2

Add the Cloud Function as an API Call in FlutterFlow

In FlutterFlow, open the API Manager (plug icon in the left sidebar). Click Add API Group. Name it MailchimpFunctions. Set the Base URL to your Cloud Function base URL: https://us-central1-{your-project-id}.cloudfunctions.net. Under Headers, add Content-Type: application/json. Add an API Call named addSubscriber. Set the method to POST and path to /addToMailchimp. Under the Request Body tab, add variables: email (String), firstName (String), lastName (String), tags (List). The body JSON should look like: {"data": {"email": [email], "firstName": [firstName], "lastName": [lastName], "tags": [tags]}}. Note: Firebase callable functions require the body wrapped in a data key. Click Test and verify you get {result: {success: true}} back with a test email address.

Expected result: The API Manager shows a passing test for the addSubscriber API Call with a real Mailchimp subscriber appearing in your Mailchimp audience dashboard.

3

Add a subscribe form to your app

Create a subscribe form on your signup page or a dedicated newsletter widget. Add a TextField for email (hint: 'Your email address'), a TextField for first name, and a Button labeled 'Subscribe'. In the Button's Action Flow: (1) validate that the email TextField is not empty — show a Snackbar 'Please enter your email' if empty. (2) API Call → MailchimpFunctions → addSubscriber, passing the email and name TextFields as the variable values. (3) If the response status is 200 and success is true: update a Page State variable subscribeSuccess to true and show a Container with 'You are subscribed!' message. (4) If the response returns an error: show a Snackbar with the error message. Hide the form and show a success message using the subscribeSuccess Page State variable with conditional visibility.

Expected result: Users who submit the form are added to your Mailchimp audience, and the form transitions to a success message confirming the subscription.

4

Tag subscribers based on in-app events

To tag a subscriber when they complete a purchase or upgrade their plan, add an API Call to the same MailchimpFunctions group named updateSubscriberTags. This calls the same addToMailchimp Cloud Function but passes a tags array. For example, when a user completes a purchase, the Action Flow after the payment confirmation calls: API Call → updateSubscriberTags with email: currentUser.email and tags: ['customer', 'paid-plan']. The Cloud Function's setListMember upserts the contact and updateListMemberTags adds the tags. If the contact does not exist yet in Mailchimp, it will be created. Use Mailchimp tags to segment your email campaigns: send onboarding tips only to 'free-plan' tagged users, promotional offers only to 'customer' tagged users.

Expected result: Subscribers in Mailchimp show appropriate tags based on actions taken in your FlutterFlow app, enabling segmented email campaigns.

Complete working example

mailchimp_integration.txt
1MAILCHIMP + FLUTTERFLOW INTEGRATION MAP
2
3CONFIGURATION:
4 Mailchimp API Key Cloud Function env var MAILCHIMP_API_KEY
5 Mailchimp Server Prefix MAILCHIMP_SERVER_PREFIX (e.g. us21)
6 Find in API key: xxxx-us21 server = us21
7 Mailchimp List ID MAILCHIMP_LIST_ID
8 Mailchimp Audience Settings Audience ID
9
10CLOUD FUNCTION: addToMailchimp
11 Input: { email, firstName, lastName, tags[] }
12 subscriberHash = MD5(email.toLowerCase())
13 lists.setListMember() creates OR updates subscriber
14 lists.updateListMemberTags() adds/removes tags
15 Output: { success: true, id: subscriber.id }
16
17FLUTTERFLOW API MANAGER:
18 API Group: MailchimpFunctions
19 Base URL: https://us-central1-{project}.cloudfunctions.net
20 API Call: addSubscriber (POST /addToMailchimp)
21 Body: { data: { email, firstName, lastName, tags } }
22 Variables: email, firstName, lastName, tags
23
24USE CASES:
25 Signup addSubscriber(email, name, tags: ['signup'])
26 Purchase updateTags(email, tags: ['customer'])
27 Plan upgrade updateTags(email, tags: ['pro-plan'])
28 Unsubscribe PATCH status: 'unsubscribed'
29
30ERROR HANDLING:
31 'Member Exists' setListMember handles this (upsert)
32 Invalid email validate before API call
33 API key wrong check MAILCHIMP_SERVER_PREFIX matches key
34 Rate limit Mailchimp: 10 requests/second per account

Common mistakes

Why it's a problem: Using the Mailchimp API key directly in FlutterFlow API headers instead of a Cloud Function

How to avoid: Store the API key in Cloud Function environment variables. FlutterFlow calls your Cloud Function URL, and the Cloud Function handles all Mailchimp API calls server-side.

Why it's a problem: Using the wrong authentication format for Mailchimp's Basic Auth scheme

How to avoid: The @mailchimp/mailchimp_marketing npm package handles authentication automatically when you call mailchimp.setConfig({apiKey, server}). If you are making raw HTTP calls, set the Authorization header to Basic base64('anystring:YOUR_API_KEY').

Why it's a problem: Not specifying the Mailchimp server prefix, causing all API calls to fail with 'Invalid server' error

How to avoid: Extract the server prefix from the end of your API key (after the last dash) and store it as the MAILCHIMP_SERVER_PREFIX environment variable. Pass it to mailchimp.setConfig({apiKey, server: serverPrefix}).

Best practices

  • Store MAILCHIMP_API_KEY, MAILCHIMP_LIST_ID, and MAILCHIMP_SERVER_PREFIX as Cloud Function environment variables — never in FlutterFlow or app code
  • Use setListMember (PUT) instead of createListMember (POST) — the PUT version is an upsert that creates new subscribers and updates existing ones without throwing a 'Member Exists' error
  • Collect explicit opt-in consent before adding anyone to your Mailchimp list — GDPR and CAN-SPAM require proof of consent for marketing emails
  • Use Mailchimp tags for segmentation rather than creating multiple separate audience lists — tags are easier to manage and avoid duplicate billing for contacts in multiple lists
  • Add an unsubscribe option in your app's notification settings that calls PATCH /lists/{listId}/members/{hash} with status: 'unsubscribed' — do not rely solely on Mailchimp's unsubscribe link
  • Validate email format with a regex before calling the Cloud Function to avoid unnecessary API calls for obviously invalid addresses
  • Test the full subscribe flow end-to-end in your Mailchimp test audience before connecting to your production list

Still stuck?

Copy one of these prompts to get a personalized, step-by-step explanation.

ChatGPT Prompt

I am building a FlutterFlow app and want to integrate Mailchimp to add users to my email list when they sign up. Write me a Firebase Cloud Function using the @mailchimp/mailchimp_marketing npm package that accepts email, firstName, lastName, and an optional tags array, creates or updates the Mailchimp subscriber using setListMember (so existing subscribers are updated rather than throwing an error), and adds the tags. Show me how to configure the API key and list ID as environment variables.

FlutterFlow Prompt

Add a newsletter signup section to my FlutterFlow app. Create a Container with a TextField for email, a TextField for first name, and a Subscribe button. The button should call my MailchimpFunctions API Group's addSubscriber endpoint, passing the TextField values. On success, replace the form with a 'You are subscribed!' confirmation message using a Page State boolean variable.

Frequently asked questions

How do I integrate FlutterFlow with Mailchimp?

Deploy a Firebase Cloud Function with the @mailchimp/mailchimp_marketing npm package and your Mailchimp API key stored as an environment variable. The Cloud Function exposes an endpoint that FlutterFlow calls via the API Manager. It uses lists.setListMember to add or update subscribers. Never call Mailchimp's API directly from FlutterFlow — the API key would be exposed in the app.

Can I add subscribers to Mailchimp without a Cloud Function?

Not safely. Mailchimp does not support CORS for browser or app requests, so direct calls from Flutter fail with CORS errors. Even if you worked around this, the API key would be visible in the app. Using Zapier is a code-free alternative: configure a Zapier webhook trigger, add a Zapier action to add a Mailchimp subscriber, and call the Zapier webhook URL from FlutterFlow's API Manager. The webhook URL does not expose your Mailchimp key.

How do I find my Mailchimp List ID and server prefix?

List ID (Audience ID): log in to Mailchimp → Audience → select your audience → Manage Audience → Settings → scroll to Audience name and defaults → copy the Audience ID shown there. Server prefix: look at your API key — it ends with a dash and the server code, for example xxxx-us21. The server prefix is the part after the last dash (us21 in this example).

What happens if the user is already subscribed to my Mailchimp list?

Using lists.setListMember (a PUT/upsert operation) handles this gracefully — it updates the existing subscriber's merge fields and tags without throwing an error. If you use lists.addListMember (a POST), it throws a 400 error with 'Member Exists' for already-subscribed contacts. Always use setListMember in your Cloud Function to avoid this error.

Can I also send Mailchimp campaigns from my FlutterFlow app?

You can trigger Mailchimp campaign sending via a Cloud Function using mailchimp.campaigns.send(campaignId), but this is typically done from a backend admin panel rather than a user-facing app. Designing campaigns (templates, subject lines, content) must be done in the Mailchimp dashboard. What you can automate from FlutterFlow: adding subscribers, applying tags (which trigger automated email sequences in Mailchimp), and updating subscriber preferences.

Is there a limit to how many subscribers I can add via the Mailchimp API?

The Mailchimp free plan allows up to 500 contacts and 1,000 email sends per month. Paid plans start at $13/month for larger audiences. The API rate limit is 10 requests per second per account regardless of plan. For bulk imports (hundreds of subscribers at once), use Mailchimp's batch subscribe endpoint lists.batchListMembers which accepts up to 500 members per request and counts as fewer API calls.

Can RapidDev help build a full email marketing integration for my FlutterFlow app?

Yes. A complete email marketing setup typically includes subscriber management, tag-based segmentation, preference centers, automated welcome sequences, and compliance with email marketing laws (GDPR, CAN-SPAM). RapidDev can build the Cloud Functions, FlutterFlow UI components, and Mailchimp automation sequences for your specific use case.

RapidDev

Talk to an Expert

Our team has built 600+ apps. Get personalized help with your project.

Book a free consultation

Need help with your project?

Our experts have built 600+ apps and can accelerate your development. Book a free consultation — no strings attached.

Book a free consultation

We put the rapid in RapidDev

Need a dedicated strategic tech and growth partner? Discover what RapidDev can do for your business! Book a call with our team to schedule a free, no-obligation consultation. We'll discuss your project and provide a custom quote at no cost.