Registering customers
- 6 minutes to read
Each online store has its customers. To store and process their personalized designs, you must register these customers in your Customer's Canvas account. As a result of this registration, private data storage for a customer is created with special data access restrictions.
During the personalization process, customers can upload their images to private storage. At the same time, the authorization policy of Customer's Canvas provides the necessary isolation of the private data of different customers.
Managing storefront users
The entity storefront user allows you to manage the customers of an online store.
You can use the endpoint StorefrontUsers_Create to register a user and create private storage. When registering a user, you must explicitly specify whether the user is anonymous. Private storage of an anonymous user is temporary and must be merged with the regular storefront user account when this user logs in, as described below.
For example, if the storefront ID is 12
, you can register a new user like this.
curl -X \
POST "https://api.customerscanvashub.com/api/storefront/v1/storefront-users?storefrontId=12" \
-H "accept: text/plain" \
-H "content-type: application/json-patch+json" \
-H "Authorization: Bearer <TOKEN>" \
-d "{'storefrontUserId': 'john@wood.com', 'isAnonymous': true}"
If a user with the specified identifier already exists, the error code 409 will be returned. If the result is successful, a user ID will be returned.
You can check that the customer already exists using the endpoint StorefrontUsers_Get.
curl -X \
GET "https://api.customerscanvashub.com/api/storefront/v1/storefront-users/john%40wood.com?storefrontId=12" \
-H "accept: text/plain" \
-H "Authorization: Bearer <TOKEN>"
Once you receive the response, you need to check its status code. If the code is 200
, the user was found in the storefront.
The key to access private storage is a customer token. You can get it using the endpoint StorefrontUsers_GetToken. The customer token represents a classic JSON Web Token (JWT) prepared by the Customer's Canvas authorization module. You must pass this token to the personalization tool to work with the data of a specific customer.
curl -X \
GET "https://api.customerscanvashub.com/api/storefront/v1/storefront-users/token?storefrontUserId=john%40wood.com&storefrontId=12" \
-H "accept: text/plain" \
-H "Authorization: Bearer <TOKEN>"
To transfer data from temporary storage created during the anonymous product personalization to private storage linked to the customer ID in the online store, you can use the endpoint StorefrontUsers_MergeAnonymous. Customer's Canvas only supports data transfer from an anonymous user to a permanent user.
For example, if an anonymous user was registered with the ID user-123
, you can merge their storage with storage of the regular user john@wood.com
as follows:
curl -X \
POST "https://api.customerscanvashub.com/api/storefront/v1/storefront-users/merge-anonymous?storefrontId=12" \
-H "accept: text/plain" \
-H "content-type: application/json-patch+json" \
-H "Authorization: Bearer <TOKEN>" \
-d "{'anonymousStorefrontUserId': 'user-123', 'regularStorefrontUserId': 'john@wood.com'}"
Before your customer starts the personalization process, you must first register the customer in your Customer's Canvas account and prepare their private storage. In real life, there are two different approaches, which we will now describe in more detail.
Product personalization by an identified customer
Let's assume that the customer, having opened a page of your online store, first logged into the account, and only after that proceeded to select a product for personalization.
In this case, by the time they personalize the product, you already have the permanent ID of the customer's account in your online store. Just before starting the personalization process, you can check whether a customer with this ID is registered in your Customer's Canvas account and, if needed, register them and create their private storage.
This approach allows your customer to use their data, which was previously placed in private storage, when personalizing products.
Product personalization by an anonymous customer
Consider a situation where the customer immediately selects products for personalization, postponing the authorization until the payment is made.
In this case, before starting the personalization process, you need to register a temporary anonymous user and create separate private storage based on the session ID.
When the customer finishes personalizing and proceeds to payment, they will log in to your online store account. At the stage of saving the personalization results, you can check whether a customer with such an ID is registered in your Customer's Canvas account and, if needed, register them and create new private storage.
After that, you can transfer the data uploaded during the anonymous personalization session to private storage that corresponds to the customer ID.
If this customer returns for another purchase and logs in before the personalization process, they can access the data uploaded in the current anonymous session.
In the next topic, you will learn how to bind products to designs.