Skip to main content

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.
string
required
Unique customer identifier (prefix: cus_)
string
Customer email address (searchable)
string
Customer first name (searchable)
string
Customer last name (searchable)
string
Company name for B2B customers (searchable)
string
Customer phone number (searchable)
boolean
Whether customer has a registered account (default: false)
string
ID of user who created the customer record
object
Additional custom data
CustomerAddress[]
Customer shipping/billing addresses
CustomerGroup[]
Customer groups this customer belongs to

CustomerAddress

Represents a saved customer address.
string
required
Unique address identifier
string
required
ID of the parent customer
string
Name for this address (e.g., “Home”, “Office”)
boolean
Whether this is the default shipping address
boolean
Whether this is the default billing address
string
First name
string
Last name
string
Phone number
string
Company name
string
Address line 1
string
Address line 2
string
City
string
Two-letter ISO country code
string
State or province
string
Postal/ZIP code
object
Additional custom data

CustomerGroup

Groups customers for segmentation and targeting.
string
required
Unique customer group identifier
string
required
Customer group name
object
Additional custom data
Customer[]
Customers in this group

CustomerGroupCustomer

Join entity for many-to-many customer-group relationship.
string
required
Unique relationship identifier
string
required
ID of the customer
string
required
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.
string
required
The ID of the customer to retrieve
FindConfig
Configuration for the query
string[]
Relations to load (e.g., ["addresses", "groups"])
string[]
Fields to select from the customer
CustomerDTO
The retrieved customer

List Customers

List customers with filtering and search.
FilterableCustomerProps
Filters to apply
string | string[]
Filter by customer IDs
string | string[]
Filter by email (supports partial match)
boolean
Filter by account status
string
Filter by first name (searchable)
string
Filter by last name (searchable)
string
Filter by phone number (searchable)
object
Filter by customer group
CustomerDTO[]
Array of customers matching the filters
number
Total count of matching customers

Create Customers

Create one or more customer profiles.
CreateCustomerDTO | CreateCustomerDTO[]
required
Customer data to create
string
Customer email address
string
Customer first name
string
Customer last name
string
Company name for B2B
string
Phone number
boolean
Whether customer has a registered account
CreateCustomerAddressDTO[]
Initial addresses for the customer
object
Custom metadata
CustomerDTO | CustomerDTO[]
The created customer(s)

Update Customers

Update customer information.
string | string[] | FilterableCustomerProps
required
Customer ID(s) or filter selector
CustomerUpdatableFields
required
Fields to update

Create Customer Addresses

Add addresses to a customer.
CreateCustomerAddressDTO | CreateCustomerAddressDTO[]
required
Address data
string
required
ID of the customer
string
Name for this address
boolean
Set as default shipping address
boolean
Set as default billing address
string
First name
string
Last name
string
Address line 1
string
City
string
Two-letter ISO country code
string
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.
CreateCustomerGroupDTO | CreateCustomerGroupDTO[]
required
Customer group data
string
required
Customer group name
object
Custom metadata

Add Customers to Group

Assign customers to a customer group.
GroupCustomerPair | GroupCustomerPair[]
required
Customer-group associations
string
required
ID of the customer
string
required
ID of the 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

  1. Email Uniqueness: Enforce unique emails for accounts by using the has_account flag. Guests can share emails, but registered customers must have unique email/has_account combinations.
  2. Address Management: Use is_default_shipping and is_default_billing to mark primary addresses for quick access.
  3. Customer Groups: Leverage customer groups for:
    • Price list targeting
    • Promotion eligibility
    • Custom business logic
    • Reporting and analytics
  4. Searchable Fields: Take advantage of searchable fields (email, first_name, last_name, company_name, phone) for customer lookup.
  5. Guest to Account Conversion: When converting a guest to a registered customer, update has_account to true and ensure email uniqueness.
  6. Metadata Usage: Store custom attributes in metadata for flexibility without schema changes.