Documentation
Feedback
Guides
API Reference

Guides
Guides
Integration Guides

Headless profile management and order history

Profile management is an important feature, that allows shoppers in your store to view and edit their personal information, as well as order history and other features.

VTEX's native storefront accomplishes this with the My account page, but below you can learn how to use VTEX APIs to build the same features in your headless shopping experience.

Profile management

Regarding profile management, your integration must be able to access profile information, edit profile information and also perform password resets.

Accessing profile information

The best way to retrieve shopper profile information on your headless storefront is to use this endpoint of the Checkout API:

By default, this endpoint returns only complete profiles, but you may use the boolean query parameter ensureComplete=false to get incomplete profiles as well.

A complete profile includes all information necessary to place an order: email, firstName, lastName, phone, document, and an associated address with all required fields.

Editing profile information

VTEX uses Master Data v1 to store and manage shopper information. To manage profile data from your headless storefront, you must use the SafeData app, which provides a secure middleware layer for retrieving and storing Master Data information directly from the frontend.

Learn more about Master Data and its basic components.

Before you begin: Install the SafeData app in your VTEX account. SafeData acts as a validation layer on top of Master Data API to ensure the data being queried or modified belongs to the user executing the action. For more information, refer to the SafeData documentation.

In Master Data v1, shopper profiles are documents in the CL data entity, while addresses are documents in the AD data entity. The SafeData app provides endpoints similar to Master Data endpoints, but with built-in security validation. See below the SafeData endpoints for managing documents:

  • Update partial document: PATCH /api/io/safedata/{entity}/documents/{id}
  • Get document by ID: GET /api/io/safedata/{entity}/documents/{id}

The SafeData API uses the pattern /api/io/safedata/{entity}/documents/{id}, where {entity} is the data entity acronym (e.g., CL for customer profiles, AD for addresses) and {id} is the document ID.

Example request to update a user profile:

Method: PATCH

Path:


_10
https://{{accountName}}.vtexcommercestable.com.br/api/io/safedata/CL/documents/{{documentId}}

Body:


_10
{
_10
"firstName": "John",
_10
"lastName": "Doe",
_10
"email": "john.doe@example.com",
_10
"phone": "+5511999999999"
_10
}

If you prefer to search shopper information by other information, such as email address, instead of the document ID, you can use the Checkout API endpoint mentioned in the Accessing profile information section above.

Password

Currently, there is no way to edit shoppers' passwords from a headless frontend. However, you can implement password expiration, so that your customers can then go to your store and create a new password.

To implement this feature, follow the instructions in the guide Expiring a shopper's password.

This method of password expiration does not trigger any notification. You must notify the shopper that they must create a new password on your website. Learn more about Shopper authentication for headless stores.

News letter subscription

When shoppers go to the profile management section of your store, they may wish to manage their consent of newsletter subscription. For this purpose, note that this information is in the shopper profile, in the boolean field named isNewsletterOptIn.

Order history

You can use the endpoints below to fetch order information related to a specific shopper.

Actions on existing orders

Some stores allow shoppers to request changes or even the cancellation of existing orders. For order cancelation, use this endpoint:

For requesting changes to an existing order, you can use the endpoint below, but see the Change order guide to learn more about this process.

Learn more

See these other guides to learn more about building a headless shopping experience using VTEX:

Contributors
1
Photo of the contributor
Was this helpful?
Yes
No
Suggest Edits (GitHub)
Contributors
1
Photo of the contributor
Was this helpful?
Suggest edits (GitHub)
On this page