How to work with the APIs for customers.
APIs in this topic
| Resource | Purpose | Reference |
|---|---|---|
| Customers | Represent a person purchasing Products. | Customers |
| Customer Search | Search across a large number of Customers in a Project, for back-office use cases. | Customer Search |
| Customer Groups | Assign special prices to specific products based on a Customer Group. | Customer Groups |
| Me endpoints | Access the resources of a single Customer. | Me endpoints overview |
Data model
Global versus Store-specific Customers
stores field is empty.stores field contains one or more Stores.Two different authorization flows are used depending on the type of Customer:
Customer addresses
addresses array. Each address entry has an auto-generated id and, optionally, a user-defined key. The platform uses the id to reference addresses from dedicated fields (shippingAddressIds, billingAddressIds, defaultShippingAddressId, defaultBillingAddressId) to express whether an address is used for shipping, billing, or as a default.id. The relevant update actions accept either the address id or its key to identify the address. Removing an address also clears the Customer references to that address.Customer Group assignments
customerGroup field allows assigning one Customer Group per Customer, while the customerGroupAssignments field supports assigning up to 500 Customer Groups and better supports complex pricing scenarios.customerGroupAssignments field in new projects. In addition to supporting assigning multiple Customer Groups to Customers, it provides greater flexibility in complex pricing scenarios. To migrate existing Projects from using a single Customer Group per Customer to using multiple Customer Groups, see our migration guide.Working with the APIs
Email case-insensitivity
Customer authentication (sign-in)
- To authenticate a global Customer (not associated with a Store), use the general or Store-specific endpoint.
- To authenticate a Store-specific Customer, use the Store-specific endpoint.
anonymousCart, a single anonymous Cart can be assigned. With anonymousId, all Carts, Orders, ShoppingLists, and Payments with the same anonymousId can be assigned to the Customer. If both anonymousCart and anonymousId are defined, the anonymous Cart must have the same anonymousId assigned.Cart assignment can happen in one of two ways:
- If the Customer does not have a Cart yet, or the value of AnonymousCartSignInMode is set to
UseAsNewActiveCustomerCart, then the anonymous Cart becomes the Customer's Cart. - If the Customer already has one or more Carts and the value of AnonymousCartSignInMode is set to
MergeWithExistingCustomerCart, then the items of the anonymous Cart will be merged into the Customer's most recently modified active Cart. This process is referred to as Cart merge and results in a specific set of changes for both Carts.
Cart merge during sign-in and sign-up
Cart merge is applied by default on the following endpoints:
- Create (sign up) Customer
- Create (sign up) Customer in Store
- Authenticate (sign-in) Customer
- Authenticate (sign in) Customer in Store.
anonymousCartSignInMode field on the CustomerSignin to UseAsNewActiveCustomerCart.The response to a sign-in or sign-up contains the Customer's most recently modified active Cart. They can then modify this Cart and place an order.
Customer email verification
To verify a Customer's email, do the following:
-
Send an email token embedded in a link to the Customer.
- For global Customers, use the Create email token for Customer endpoint.
- For Store-specific Customers, use Create email token for Customer in Store endpoint.
If the token is valid for 60 minutes or less, its value can be retrieved through the CustomerEmailTokenCreated Message—enabling asynchronous flows.By default, creating an email token does not invalidate older tokens; to invalidate older tokens, use the CustomerCreateEmailToken update action. -
When the Customer clicks the link, optionally retrieve the Customer by the email token.
- For global Customers, use the Get Customer by email token endpoint.
- For Store-specific Customers, use the Get Customer in Store by email token endpoint.
-
Verify the Customer's email. This sets the Customer's
isEmailVerifiedfield totrue.- For global Customers, use the Verify email of Customer endpoint.
- For Store-specific Customers, use the Verify email of Customer in Store endpoint.
- These methods are also provided on the My Customer Profile with their respective Scopes.
isEmailVerified property is set to false.Customer password reset
To reset a Customer's password, do the following:
-
Send a password reset token embedded in a link to the Customer.
- For global Customers, use the Create password reset token for Customer endpoint.
- For Store-specific Customers, use Create password reset token for Customer in Store endpoint.
If the token is valid for 60 minutes or less, its value can be retrieved through the CustomerPasswordTokenCreated Message—enabling asynchronous flows.By default, creating a password token does not invalidate older tokens; to invalidate older tokens, use the CustomerCreatePasswordResetToken update action. -
When the Customer clicks the link, optionally retrieve the Customer by the password token.
- For global Customers, use the Get Customer by password token endpoint.
- For Store-specific Customers, use the Get Customer in Store by password token endpoint.
-
When the Customer enters the new password, reset the Customer's password.
- For global Customers, use the Reset password of Customer endpoint.
- For Store-specific Customers, use the Reset password of Customer in Store endpoint.
- These methods are also provided on the My Customer Profile with their respective Scopes.
Customer permissions
view_customers scope provides access to all Customers in your Project.
Therefore, you must implement your own data protection in your storefront or use the Me endpoints.Store-specific permissions
Customer-specific prices B2B B2X
customerId has to reference an Associate in the Business Unit that represents the customer. To ensure that you apply the correct pricing, reference the customer-specific Channel in the distributionChannel of the Cart's Line Item Drafts. Without specifying the Channel, the base price is selected instead of the customer-specific price.Standalone and create Prices for every Channel.Customer Search
Limits
10 000 000 Customers can be created per Project. A Customer can be assigned to a maximum of 500 Customer Groups. These are soft limits that can be increased per Project after a performance impact review. See Limit increase guidance.10 000 Customer Groups can be created per Project. This is a soft limit that can be increased per Project after a performance impact review. See Limit increase guidance.10 000 addresses per Customer can be indexed for Customer Search.50 Custom Fields per Customer can be indexed. If a Customer has more, only the first 50 Custom Fields, sorted alphabetically by field name, are indexed.