Skip to content

Commit 7f40f8c

Browse files
Merge pull request #663 from kinde-oss/tamal/feat/kinde-and-loops-integration
feat: new guide - Connect Loops to Kinde
2 parents f9bac83 + 6273ea8 commit 7f40f8c

File tree

3 files changed

+331
-7
lines changed

3 files changed

+331
-7
lines changed
Lines changed: 321 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,321 @@
1+
---
2+
page_id: 5e97601f-3b77-4034-ae12-31737020b254
3+
title: Connect Loops to Kinde (via Zapier)
4+
description: Step-by-step guide to connecting Kinde webhooks with Loops via Zapier for email automation and marketing campaigns using webhooks and event hooks
5+
sidebar:
6+
order: 14
7+
relatedArticles:
8+
- 55350C9F-88FA-4996-B648-A4B5C11C8FFF
9+
- 5d958ce9-27ee-420a-9e20-09a2ed7fb179
10+
- 84581694-59d6-4a02-ab8b-c7a2889713d5
11+
next: false
12+
topics:
13+
- integrate
14+
- third-party-tools
15+
sdk: []
16+
languages: []
17+
audience:
18+
- developers
19+
- business owners
20+
complexity: beginner
21+
keywords:
22+
- loops
23+
- email marketing
24+
- automation
25+
- integration
26+
- webhooks
27+
- zapier
28+
- email campaigns
29+
updated: 2026-02-04
30+
featured: false
31+
deprecated: false
32+
ai_summary: Step-by-step guide to connecting Kinde webhooks with Loops via Zapier for email automation and marketing campaigns using webhooks and event hooks.
33+
---
34+
35+
This guide will walk you through connecting Kinde webhooks to Loops via Zapier, allowing you to automatically sync your Kinde users to Loops for email marketing and automation. When events like user creation or authentication happen in Kinde, they can trigger automated actions to add or update contacts in Loops.
36+
37+
### What you need
38+
39+
- A [Kinde](https://www.kinde.com/register) account with an available webhook slot (Sign up for free)
40+
- A [Loops](https://loops.so/) account (Sign up for free)
41+
- A [Zapier](https://zapier.com/) account (Professional plan or higher required for webhook triggers)
42+
43+
## Step 1: Generate a Loops API key
44+
45+
1. Sign in to your Loops account and go to **Settings > API**
46+
2. Select **Generate key**
47+
3. Select the newly generated key to copy it. You will need this in the next step.
48+
4. If you want to add the contacts to specific mailing lists in Loops, go to **Settings > Lists > Mailing lists** and select **Create a list**
49+
5. Enter a name and description for the list, and copy the list ID. You will need this when creating the Zap in Zapier
50+
51+
## Step 2: Create a Zap in Zapier
52+
53+
1. Log in to your Zapier account and select **Create** > **Zaps**
54+
2. In the **Trigger** step, search for **Webhooks** and select it.
55+
3. In the **Event** dropdown, select **Catch Raw Hook**, then select **Continue**
56+
57+
<Aside>
58+
59+
**Catch Raw Hook** is required for Kinde webhooks because Kinde sends webhook data as a JWT token string. The raw hook will capture the complete webhook payload including the JWT token.
60+
61+
</Aside>
62+
63+
4. In the **Test** tab, Zapier will generate a unique webhook URL for your Zap. The URL will look like: `https://hooks.zapier.com/hooks/catch/1234567/abcdefg/`
64+
65+
Copy this URL - you'll need it in the next step.
66+
67+
Keep this Zap open - you'll return to it after configuring the webhook in Kinde.
68+
69+
## Step 3: Create a webhook in Kinde
70+
71+
1. In your Kinde dashboard, go to **Settings > Webhooks**
72+
2. Select **Add webhook**
73+
3. Give your webhook a descriptive name (e.g., "Kinde Zapier Loops")
74+
4. Enter a description explaining what this webhook is for (e.g., "Sync users to Loops when created")
75+
5. In the **Endpoint URL** field, paste the Zapier webhook URL you copied in Step 2
76+
6. Select **Add event** to select which events you want to trigger this webhook
77+
78+
For this example, select `user.created` to trigger the webhook when a new user is created
79+
80+
Common events you might use:
81+
- `user.created` - When a new user signs up for the first time
82+
- `user.updated` - When user information is updated
83+
- `user.authenticated` - When a new or existing user logs in
84+
85+
For a complete list of available events, see [Add and manage webhooks](/integrate/webhooks/add-manage-webhooks#webhook-triggers)
86+
87+
7. Select **Save** to create the webhook
88+
89+
## Step 4: Test the webhook trigger
90+
91+
1. In your Kinde dashboard, create a test user to trigger the webhook:
92+
- Go to **Users** and select **Add user**
93+
- Enter test user details (e.g., name: "Test User", email: "test@example.com")
94+
- Select **Save**
95+
2. Return to Zapier and select **Test trigger** in the trigger step
96+
3. You should see the webhook data appear. The data will be a raw JWT token string in the body
97+
4. Select **Continue with selected record** to proceed to the next step
98+
5. Zapier will open a new popup. Search for **Code** and select it
99+
100+
## Step 5: Decode the JWT using Zapier Code action
101+
102+
Since Kinde sends webhook data as a JWT token, you'll need to decode it to access the user information. Zapier's Code action allows you to run JavaScript to decode the JWT.
103+
104+
1. Select **Code by Zapier** and from the Action event dropdown, select **Run JavaScript** as the action. Select **Continue**
105+
2. In the **Input Data** field, add a field called `jwt` and map it to the **Raw Body** from the webhook trigger
106+
3. In the **Code** field, paste the following JavaScript to decode the JWT, replacing the existing code:
107+
108+
```javascript
109+
// Function to decode a JWT token
110+
function decodeJWT(token) {
111+
if (!token) {
112+
throw new Error('JWT token is missing');
113+
}
114+
115+
const parts = token.split('.');
116+
if (parts.length !== 3) {
117+
throw new Error('Invalid JWT token');
118+
}
119+
120+
const payload = parts[1].replace(/-/g, '+').replace(/_/g, '/');
121+
const padded = payload + '='.repeat((4 - (payload.length % 4)) % 4);
122+
const decoded = JSON.parse(Buffer.from(padded, 'base64').toString('utf-8'));
123+
return decoded;
124+
}
125+
126+
// Get the JWT from input data
127+
const jwt = inputData?.jwt;
128+
129+
// Decode the JWT with error handling
130+
let decoded = null;
131+
try {
132+
decoded = decodeJWT(jwt);
133+
} catch (error) {
134+
return {
135+
error: error.message || 'Failed to decode JWT'
136+
};
137+
}
138+
139+
// Extract user data from the decoded payload
140+
const userData = decoded?.data?.user || {};
141+
142+
// Return the decoded data
143+
return {
144+
firstName: userData.first_name || '',
145+
lastName: userData.last_name || '',
146+
email: userData.email || '',
147+
fullName: `${userData.first_name || ''} ${userData.last_name || ''}`.trim(),
148+
userId: userData.id || '',
149+
orgCode: userData?.organizations?.[0]?.code || '',
150+
rawData: decoded
151+
};
152+
```
153+
154+
4. Select **Continue**, then **Test step** to verify the JWT is decoded correctly.
155+
5. You should see the decoded user data including first name, last name, and email
156+
6. Select **Continue**
157+
158+
<Aside>
159+
160+
The JWT payload structure from Kinde includes a `data` object containing the user information. The Code action extracts fields like `first_name`, `last_name`, and `email` from this data object. See the [webhook payload example](/integrate/webhooks/about-webhooks) for more details.
161+
162+
</Aside>
163+
164+
## Step 6: Add Loops action
165+
166+
Now that you have decoded the JWT, you can use the extracted data to add contacts to Loops. This will sync your Kinde users to Loops for email marketing and automation.
167+
168+
1. In Zapier, edit your Zap and select the plus icon **+** to add another step after the Code action
169+
2. Search for **Loops** and select it
170+
3. From the Action event dropdown, select **Add Contact** as the action
171+
4. Connect your Loops account:
172+
- Click **Sign in to Loops**
173+
- Enter your Loops API key you copied from Step 1
174+
- Select **Continue**
175+
5. Map the fields from your decoded JWT to Loops:
176+
- **Email**: Map to the `Email` field from the Code step output (required)
177+
- **First Name**: Map to the `First Name` field from the Code step output
178+
- **Last Name**: Map to the `Last Name` field from the Code step output
179+
- **Source**: Set to `kinde` or `zapier` (optional)
180+
- **Subscribed**: Set to `true` (default) to ensure users receive emails
181+
182+
<Aside title="Marketing consent">
183+
Setting `subscribed` to `true` automatically opts users into marketing emails. Under GDPR and CAN-SPAM regulations, explicit consent is typically required before sending marketing communications.
184+
185+
**Best practices:**
186+
- Add clear consent language at signup (e.g., "I agree to receive marketing emails") and only set `subscribed` to `true` if the user explicitly consents
187+
- Alternatively, default `subscribed` to `false` and implement a double opt-in flow where users confirm their email address before receiving marketing emails
188+
- Log and store the user's consent timestamp and source (e.g., "signup_form", "profile_settings") for auditability and compliance purposes
189+
190+
If the user doesn't consent, set `subscribed` to `false`.
191+
</Aside>
192+
193+
6. Select **Continue**
194+
7. Select **Test step** to verify the contact is created in Loops
195+
8. Check your Loops dashboard to confirm the contact was added with the correct information
196+
9. Select **Publish** to activate your Zap
197+
198+
<Aside>
199+
200+
**Tip**: If you want to update existing contacts instead of creating duplicates, use the **Update Contact** action instead. Loops will update the contact if the email already exists, or create a new one if it doesn't.
201+
202+
</Aside>
203+
204+
## Step 7: Test the complete integration
205+
206+
1. In your Kinde dashboard, go to **Users** and select **Add user**
207+
2. Create a new user with a name and email address
208+
3. Select **Save** to create the user
209+
4. The webhook will automatically trigger, sending the user data to Zapier
210+
5. Zapier will decode the JWT, extract the user information, and add the contact to Loops
211+
6. Check your Loops dashboard to verify the contact was added with the correct name and email
212+
7. You can also check Zapier's **Task History** to see if your Zap ran successfully
213+
214+
## Import Kinde users to Loops
215+
216+
You can import all your Kinde users to Loops using Kinde's export user feature. Follow these steps:
217+
218+
1. In your Kinde dashboard, go to **Settings > Business > Details**
219+
2. Scroll down to the **Export data** section and select **Export**
220+
3. In the pop-up window, select **All data (except passwords)**, then select **Next**
221+
4. Enter the one-time verification code sent to your email and select **Next**
222+
5. You will be able to download the `kinde_export.zip` file
223+
6. Unzip the file and you will see the `users.ndjson` file with all your Kinde users data
224+
7. Create a new `.csv` file with the following columns: `First Name`, `Last Name`, `Email`, `User Group`.
225+
226+
Copy the user data from the `users.ndjson` file to this `.csv` file
227+
228+
You can use the following Python script to convert `users.ndjson` to `.csv` file:
229+
230+
```python
231+
#!/usr/bin/env python3
232+
# convert_users_to_csv.py
233+
"""
234+
Convert users.ndjson to CSV with columns:
235+
First Name, Last Name, Email, User Group
236+
"""
237+
238+
import json
239+
import csv
240+
import os
241+
242+
def extract_user_groups(user_data):
243+
"""Extract user groups from organizations field."""
244+
if 'organizations' in user_data and user_data['organizations']:
245+
# Extract organization codes and join them with comma
246+
org_codes = [org.get('code', '') for org in user_data['organizations'] if isinstance(org, dict)]
247+
return ', '.join(org_codes)
248+
return ''
249+
250+
def convert_ndjson_to_csv(input_file, output_file):
251+
"""Convert NDJSON file to CSV."""
252+
rows = []
253+
254+
# Read and parse NDJSON file
255+
with open(input_file, 'r', encoding='utf-8') as f:
256+
for line in f:
257+
line = line.strip()
258+
if not line:
259+
continue
260+
261+
try:
262+
user_data = json.loads(line)
263+
264+
# Extract fields with fallback to empty string
265+
first_name = user_data.get('first_name', '')
266+
last_name = user_data.get('last_name', '')
267+
email = user_data.get('email', '')
268+
user_group = extract_user_groups(user_data)
269+
270+
rows.append({
271+
'First Name': first_name,
272+
'Last Name': last_name,
273+
'Email': email,
274+
'User Group': user_group
275+
})
276+
except json.JSONDecodeError as e:
277+
print(f"Warning: Skipping invalid JSON line: {e}")
278+
continue
279+
280+
# Write to CSV
281+
if rows:
282+
fieldnames = ['First Name', 'Last Name', 'Email', 'User Group']
283+
with open(output_file, 'w', newline='', encoding='utf-8') as f:
284+
writer = csv.DictWriter(f, fieldnames=fieldnames)
285+
writer.writeheader()
286+
writer.writerows(rows)
287+
288+
print(f"Successfully converted {len(rows)} users to {output_file}")
289+
else:
290+
print("No data found to convert")
291+
292+
if __name__ == '__main__':
293+
# Get the directory of this script
294+
script_dir = os.path.dirname(os.path.abspath(__file__))
295+
input_file = os.path.join(script_dir, 'users.ndjson')
296+
output_file = os.path.join(script_dir, 'users_output.csv')
297+
298+
convert_ndjson_to_csv(input_file, output_file)
299+
```
300+
Run the script using the following command (You will need Python 3.x installed):
301+
302+
```bash
303+
python3 convert_users_to_csv.py
304+
```
305+
306+
8. Go to Loops > **Audience**, and select **Import**. A pop-up opens
307+
9. Select **CSV** and select **Upload CSV**
308+
10. On the new screen, upload your `.csv` file you created earlier and select **Next**
309+
11. Map the CSV columns and select **Import contacts**
310+
12. You will see the imported users in Loops **Audience** page
311+
312+
### Conclusion
313+
314+
Now that you've successfully connected Kinde webhooks to Loops via Zapier, you can automate your email marketing and keep your user base synchronized. This integration enables you to:
315+
316+
- Automatically sync new users to Loops for email marketing
317+
- Create personalized email campaigns based on Kinde user data
318+
- Build automated email workflows triggered by Kinde events
319+
- Segment your audience using data from Kinde
320+
321+
For more information about Loops features and capabilities, visit the [Loops documentation](https://loops.so/docs).

src/content/docs/integrate/third-party-tools/kinde-mailgun-email-delivery.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,9 @@ When a user is created, Kinde sends a webhook payload (as a JWT token) that cont
120120
"data": {
121121
"user": {
122122
"email": "new.user@example.com",
123-
"user_id": "usr_abc",
124123
"first_name": "John",
125-
"last_name": "Doe"
124+
"last_name": "Doe",
125+
"id": "kp_1234567890"
126126
}
127127
},
128128
"source": "admin"

src/content/docs/manage-users/add-and-edit/send-invitations-webhook.mdx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,15 @@ Payload example:
4646
```json
4747
{
4848
"type": "user.created",
49-
"id": "evt_123",
5049
"data": {
51-
"user_id": "usr_abc",
52-
"email": "new.user@example.com",
53-
"source": "admin"
54-
}
50+
"user": {
51+
"email": "new.user@example.com",
52+
"first_name": "John",
53+
"last_name": "Doe",
54+
"id": "kp_1234567890"
55+
}
56+
},
57+
"source": "admin"
5558
}
5659
```
5760

0 commit comments

Comments
 (0)