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
Create a customer via the Dashboard
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.
Install the Stripe SDK for API creation
Install the Stripe SDK for API creation
If you want to create customers programmatically, install the Stripe Node.js library.
1npm install stripeExpected result: The stripe package is installed in node_modules.
Create a customer via the API
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.
1const stripe = require('stripe')(process.env.STRIPE_SECRET_KEY);23const 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});1112console.log('Customer created:', customer.id);Expected result: The console logs a customer ID like cus_ABC123. The customer appears in your Dashboard.
Verify the customer in the Dashboard
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
1const express = require('express');2const stripe = require('stripe')(process.env.STRIPE_SECRET_KEY);34const app = express();5app.use(express.json());67// Create a new customer8app.post('/customers', async (req, res) => {9 try {10 const { email, name, metadata } = req.body;1112 const customer = await stripe.customers.create({13 email,14 name,15 metadata: metadata || {},16 });1718 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});2930// List all customers31app.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});4142const 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.
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.
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.
Talk to an Expert
Our team has built 600+ apps. Get personalized help with your project.
Book a free consultation