Automatically Add New Stripe Subscribers to a MailerLite Segment
When a customer starts a new subscription in Stripe, this workflow instantly adds them to a specific MailerLite segment so you can trigger onboarding emails automatically. No manual CSV exports or copy-pasting required.
- 1
Receive the Stripe webhook
The workflow starts with a
Webhooknode that listens for POST requests. Copy the generated webhook URL and paste it into your Stripe Dashboard under Developers > Webhooks. Set the event tocustomer.subscription.created. In n8n, set theHTTP Methodto POST and note your webhook path. - 2
Extract subscriber data with a Set node
Add a
Setnode after the webhook. Create three fields:emailmapped to{{$json.body.data.object.customer_email}}(or use{{$json.body.data.object.customer}}),namemapped to{{$json.body.data.object.metadata.name}}, andplanmapped to{{$json.body.data.object.items.data[0].price.nickname}}. This cleans up the data before sending it to MailerLite. - 3
Check the event type with an IF node
Add an
IFnode to confirm the Stripe event is exactlycustomer.subscription.created. Set the condition:{{$json.body.type}}equals the stringcustomer.subscription.created. Connect the TRUE branch to the next step. This prevents test events or other event types from creating duplicate subscribers. - 4
Create or update the subscriber in MailerLite
Add an
HTTP Requestnode connected to the TRUE branch. SetMethodto POST andURLtohttps://connect.mailerlite.com/api/subscribers. UnderHeaders, addAuthorizationwith valueBearer YOUR_MAILERLITE_API_KEYandContent-Typeasapplication/json. In theBody(JSON), send{"email": "{{$node['Set'].json['email']}}", "fields": {"name": "{{$node['Set'].json['name']}}"}, "groups": ["YOUR_SEGMENT_ID"]}. ReplaceYOUR_MAILERLITE_API_KEYandYOUR_SEGMENT_IDwith your real values from MailerLite.
Frequently asked questions
Where do I find my MailerLite Segment ID?
Log in to MailerLite, go to Subscribers > Segments, click on the segment you want to use, and look at the URL in your browser. The number at the end of the URL is your Segment ID.
What if the customer email is not in the Stripe webhook payload?
Stripe sometimes sends a customer ID instead of an email directly in the subscription object. In that case, add an extra HTTP Request node before the Set node to call the Stripe API at `https://api.stripe.com/v1/customers/{{$json.body.data.object.customer}}` using Basic Auth with your Stripe secret key to retrieve the customer email.
Will this create duplicate subscribers in MailerLite?
No. MailerLite's API automatically handles duplicates by updating an existing subscriber's record if the email already exists, and simply adds them to the new segment without creating a second entry.