Skip to content

Instantly share code, notes, and snippets.

Last active October 4, 2018 08:34
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Add mailchimp subscriber on Firebase user signup (firebase function)
const functions = require('firebase-functions');
const Mailchimp = require('mailchimp-api-v3');
// Listens for new firebase signups
exports.addMailchimpSubscriber = functions.auth.user().onCreate((user) => {
const mailchimp = new Mailchimp('{API-KEY}');'/lists/{listID}/members', {
status: 'subscribed'
}).then(function(results) {
console.log('added new firebase user',, 'to mailchimp list');
.catch(function(err) {
return null
"name": "functions",
"description": "Cloud Functions for Firebase",
"scripts": {
"serve": "firebase serve --only functions",
"shell": "firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
"dependencies": {
"firebase-admin": "~6.0.0",
"firebase-functions": "^2.0.3",
"mailchimp-api-v3": "^1.12.0"
"private": true
Copy link

In case the log of the Firebase Function says:

Billing account not configured. External network is not accessible and quotas are severely limited. Configure billing account to remove these restrictions

You need to switch to the Blaze plan (pay-as-go) to make outbound network requests to work. This plan can stay free, if you do not exceed the free usage limits.

The Firebase Blaze plan is a "pay as you go" plan, as indicated on the Firebase pricing page. It is a post-billing service, meaning that you get billed for your usage at the end of the month.

During the month, you can track your usage (and thus pricing) for the service in the Firebase Console.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment