Skip to main content
RapidDev - Software Development Agency
stripe-guide

How to add a new customer in Stripe

Add a new customer in Stripe through the Dashboard (Customers → + Add customer) or via the API with stripe.customers.create(). Storing customers lets you attach payment methods, track purchase history, and manage subscriptions. Use test mode to practice before going live.

What you'll learn

  • How to create a customer in the Stripe Dashboard
  • How to create a customer via the Stripe Node.js API
  • How to attach metadata and payment methods to customers
  • How to verify customer creation in test mode
Book a free consultation
4.9Clutch rating
600+Happy partners
17+Countries served
190+Team members
Beginner4 min read10 minutesStripe API v2024-12+, Node.js 18+, Stripe DashboardMarch 2026RapidDev Engineering Team
TL;DR

Add a new customer in Stripe through the Dashboard (Customers → + Add customer) or via the API with stripe.customers.create(). Storing customers lets you attach payment methods, track purchase history, and manage subscriptions. Use test mode to practice before going live.

Why Create Customers in Stripe?

Stripe Customer objects let you store payment methods, track invoices, manage subscriptions, and build a complete purchase history for each buyer. Without a customer record, every charge is a one-off transaction with no way to link future payments or issue refunds by person. Creating customers is the foundation of any recurring billing or multi-purchase workflow.

Prerequisites

  • A Stripe account (free to create at dashboard.stripe.com)
  • Node.js 18 or newer installed (for API method)
  • Your Stripe secret key (sk_test_...) from Dashboard → Developers → API keys
  • Basic familiarity with the Stripe Dashboard

Step-by-step guide

1

Create a customer via the Dashboard

Log in to the Stripe Dashboard, navigate to Customers in the left sidebar, and click '+ Add customer' in the top right. Fill in the name, email, and optional description. Click 'Add customer' to save.

Expected result: A new customer appears in the Customers list with a cus_ ID.

2

Install the Stripe SDK for API creation

If you want to create customers programmatically, install the Stripe Node.js library.

typescript
1npm install stripe

Expected result: The stripe package is installed in node_modules.

3

Create a customer via the API

Use stripe.customers.create() on your server. Pass the customer's email, name, and any metadata you want to store. The API returns the full customer object including the cus_ ID.

typescript
1const stripe = require('stripe')(process.env.STRIPE_SECRET_KEY);
2
3const customer = await stripe.customers.create({
4 email: 'jane@example.com',
5 name: 'Jane Doe',
6 metadata: {
7 internal_id: 'user_12345',
8 plan: 'pro',
9 },
10});
11
12console.log('Customer created:', customer.id);

Expected result: The console logs a customer ID like cus_ABC123. The customer appears in your Dashboard.

4

Verify the customer in the Dashboard

Go to Customers in the Stripe Dashboard and search by email or name. Click the customer to see their details, payment methods, and transaction history.

Expected result: The customer record shows the name, email, and metadata you provided.

Complete working example

create-customer.js
1const express = require('express');
2const stripe = require('stripe')(process.env.STRIPE_SECRET_KEY);
3
4const app = express();
5app.use(express.json());
6
7// Create a new customer
8app.post('/customers', async (req, res) => {
9 try {
10 const { email, name, metadata } = req.body;
11
12 const customer = await stripe.customers.create({
13 email,
14 name,
15 metadata: metadata || {},
16 });
17
18 res.json({
19 id: customer.id,
20 email: customer.email,
21 name: customer.name,
22 created: customer.created,
23 });
24 } catch (err) {
25 console.error('Error creating customer:', err.message);
26 res.status(500).json({ error: err.message });
27 }
28});
29
30// List all customers
31app.get('/customers', async (req, res) => {
32 try {
33 const customers = await stripe.customers.list({
34 limit: 10,
35 });
36 res.json(customers.data);
37 } catch (err) {
38 res.status(500).json({ error: err.message });
39 }
40});
41
42const PORT = process.env.PORT || 3000;
43app.listen(PORT, () => console.log(`Server running on port ${PORT}`));

Common mistakes when adding a new customer in Stripe

Why it's a problem: Creating duplicate customers for the same email

How to avoid: Stripe does not enforce unique emails. Before creating, search with stripe.customers.list({ email }) and reuse the existing customer if found.

Why it's a problem: Not using metadata to link to your internal user ID

How to avoid: Always add your app's user ID as metadata so you can reconcile Stripe records with your database.

Why it's a problem: Using the secret key on the frontend

How to avoid: Customer creation requires the secret key (sk_), which must only be used server-side. Never expose it in client code.

Best practices

  • Always search for an existing customer by email before creating a new one to avoid duplicates
  • Store your internal user ID in the customer's metadata field for easy cross-referencing
  • Use test mode (sk_test_) during development to avoid creating real customer records
  • Add a description field to help your team identify customers in the Dashboard
  • Set up webhook listeners for customer.created events to sync new customers to your database
  • Use environment variables for your Stripe secret key — never commit it to version control
  • Include the customer's phone number if you plan to use Stripe for SMS receipts or 2FA

Still stuck?

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

ChatGPT Prompt

Write a Node.js Express endpoint that creates a Stripe customer with email, name, and metadata fields. Return the customer ID and creation timestamp. Use the stripe npm package and process.env.STRIPE_SECRET_KEY.

Stripe Prompt

Add a /customers POST endpoint to my server that creates a Stripe customer. Accept email, name, and an optional metadata object in the request body. Return the new customer ID. Check for existing customers with the same email first to prevent duplicates.

Frequently asked questions

Is there a limit to how many customers I can create in Stripe?

No. Stripe has no hard limit on customer records. You can create millions of customers. API rate limits apply (100 requests/second in live mode) but do not restrict total customer count.

Does Stripe enforce unique email addresses for customers?

No. Stripe allows multiple customer records with the same email. Your application should check for existing customers before creating duplicates.

Can I create customers in test mode?

Yes. Use your test secret key (sk_test_) to create customers that exist only in test mode. They do not appear in live mode and no real data is involved.

How do I delete a customer in Stripe?

Use stripe.customers.del(customerId) via the API or click the overflow menu on a customer in the Dashboard and select Delete. Deletion is permanent and cancels active subscriptions.

What if I need help building a customer management system with Stripe?

For complex setups like multi-tenant customer management or syncing Stripe customers with your CRM, the RapidDev team can help architect and implement a production-ready solution.

Can I add custom fields to a Stripe customer?

Use the metadata field to store up to 50 key-value pairs (keys up to 40 chars, values up to 500 chars). This is the recommended way to attach custom data to customers.

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.