Overview
The Customer Module manages customer data including profiles, addresses, and customer group memberships. It provides essential customer relationship management capabilities for your commerce platform. Key Features:- Customer profile management
- Multiple address support
- Customer groups for segmentation
- Account and guest customer tracking
- Searchable customer data
- Custom metadata storage
When to Use
Use the Customer Module when you need to:- Create and manage customer profiles
- Store customer contact information
- Manage multiple shipping addresses per customer
- Organize customers into groups
- Track registered vs. guest customers
- Store custom customer attributes
- Search customers by name, email, or phone
Data Models
Customer
The core customer entity representing a person or business.Unique customer identifier (prefix:
cus_)Customer email address (searchable)
Customer first name (searchable)
Customer last name (searchable)
Company name for B2B customers (searchable)
Customer phone number (searchable)
Whether customer has a registered account (default: false)
ID of user who created the customer record
Additional custom data
Customer shipping/billing addresses
Customer groups this customer belongs to
CustomerAddress
Represents a saved customer address.Unique address identifier
ID of the parent customer
Name for this address (e.g., “Home”, “Office”)
Whether this is the default shipping address
Whether this is the default billing address
First name
Last name
Phone number
Company name
Address line 1
Address line 2
City
Two-letter ISO country code
State or province
Postal/ZIP code
Additional custom data
CustomerGroup
Groups customers for segmentation and targeting.Unique customer group identifier
Customer group name
Additional custom data
Customers in this group
CustomerGroupCustomer
Join entity for many-to-many customer-group relationship.Unique relationship identifier
ID of the customer
ID of the customer group
Service Interface
The Customer Module service is available at@medusajs/medusa/customer.
Retrieve Customer
Retrieve a single customer with related data.The ID of the customer to retrieve
The retrieved customer
List Customers
List customers with filtering and search.Filters to apply
Filter by customer IDs
Filter by email (supports partial match)
Filter by account status
Filter by first name (searchable)
Filter by last name (searchable)
Filter by phone number (searchable)
Filter by customer group
Array of customers matching the filters
Total count of matching customers
Create Customers
Create one or more customer profiles.Customer data to create
Customer email address
Customer first name
Customer last name
Company name for B2B
Phone number
Whether customer has a registered account
Initial addresses for the customer
Custom metadata
The created customer(s)
Update Customers
Update customer information.Customer ID(s) or filter selector
Fields to update
Create Customer Addresses
Add addresses to a customer.Address data
ID of the customer
Name for this address
Set as default shipping address
Set as default billing address
First name
Last name
Address line 1
City
Two-letter ISO country code
Postal/ZIP code
Update Customer Addresses
Modify existing addresses.Delete Customer Addresses
Remove addresses from a customer.Create Customer Groups
Create customer groups for segmentation.Add Customers to Group
Assign customers to a customer group.Remove Customers from Group
Remove customer group associations.Integration Examples
With Cart Module
Associate carts with customers.With Order Module
Link orders to customers.With Auth Module
Manage customer authentication.With Pricing Module
Customer group-based pricing.Best Practices
-
Email Uniqueness: Enforce unique emails for accounts by using the
has_accountflag. Guests can share emails, but registered customers must have unique email/has_account combinations. -
Address Management: Use
is_default_shippingandis_default_billingto mark primary addresses for quick access. -
Customer Groups: Leverage customer groups for:
- Price list targeting
- Promotion eligibility
- Custom business logic
- Reporting and analytics
- Searchable Fields: Take advantage of searchable fields (email, first_name, last_name, company_name, phone) for customer lookup.
-
Guest to Account Conversion: When converting a guest to a registered customer, update
has_accounttotrueand ensure email uniqueness. - Metadata Usage: Store custom attributes in metadata for flexibility without schema changes.
Related Modules
- Cart Module - Associate carts with customers
- Order Module - Track customer orders
- Auth Providers - Customer authentication
- Pricing Module - Customer group pricing