Learn how to create and update a product with the Catalog API.
This step-by-step guide will walk you through the process of creating and updating a product within the VTEX platform.
A product is a generic definition of an item that is part of your store’s Catalog, for instance, a shirt.
Products may vary by model, color, size, among other characteristics. Therefore, it would be possible to have the same product (shirt) in different models, like short or long sleeves, gray or pink color, sizes S, M or L.
Each variation, such as a long sleeve gray size S shirt, will correspond to a Stock Keeping Unit (SKU), which is the actual item in the inventory that customers can purchase. Before creating SKUs, you must create a product.
Before you begin
Before you begin managing your SKUs, make sure you've completed the following steps:
- Obtain API Credentials: Ensure you have a valid
appKey
andappToken
with the necessary permissions to access the Catalog API. For more information, please refer to the Roles article.
Creating a product
When creating or updating products, the product must be associated with their corresponding brand and most specific category. Hence, use the Create product with category and brand endpoint to insert a new product, considering the following scenarios:
Regardless of the type of request, if there is a need to create a new product with a specific custom product ID, it is possible to specify the Id
(integer) in the request body. Otherwise, VTEX will generate the ID automatically.
We recommend leaving VTEX to automatically generate an ID, by not including a custom product ID in the
Id
field of the request body. The generated ID can be retrieved in the request's response and must be stored in the system for future updates of this product.
Click the steps below to navigate through this article and explore specific topics. Relevant code will be highlighted and focused for your convenience. Additionally, in the code viewer on the right, you can switch between different code files or tabs to view the corresponding code examples.
Type 1 - New product, category, and brand
Create a new product as well as a new category path (including subcategories) and a new brand by specifying the CategoryPath
and BrandName
parameters in the Create product with category and brand endpoint request body.
Type 1 with custom Id
If there is a need to create a new product with a specific custom product ID, specify the Id
(integer) in the request body.
Type 2 - New product, existing category and brand
Creating a new product given an existing CategoryId
and an existing BrandId
by specifying the CategoryId
and BrandId
parameters in the Create product with category and brand endpoint request body.
Type 2 with custom Id
If there is a need to create a new product with a specific custom product ID, specify the Id
(integer) in the request body.
Retrieving product data
You can retrieve product information by calling the Get product by ID endpoint.
Make sure to copy the response body, modify specific fields and use the full updated body as a request when updating a product.
Updating a product
If you need to change any product field, it is necessary to send all the other fields in the request. Otherwise, all other previously configured information will be deleted. Therefore, before making a change, you should get the product data for the same
Id
and use the response as a template to make the change.
If you want to update information from an existing product, send a request to the Update product endpoint, indicating the Id
of the existing product.
Type 1 - New product, category, and brand
Create a new product as well as a new category path (including subcategories) and a new brand by specifying the CategoryPath
and BrandName
parameters in the Create product with category and brand endpoint request body.
Type 1 with custom Id
If there is a need to create a new product with a specific custom product ID, specify the Id
(integer) in the request body.
Type 2 - New product, existing category and brand
Creating a new product given an existing CategoryId
and an existing BrandId
by specifying the CategoryId
and BrandId
parameters in the Create product with category and brand endpoint request body.
Type 2 with custom Id
If there is a need to create a new product with a specific custom product ID, specify the Id
(integer) in the request body.
Retrieving product data
You can retrieve product information by calling the Get product by ID endpoint.
Make sure to copy the response body, modify specific fields and use the full updated body as a request when updating a product.
Updating a product
If you need to change any product field, it is necessary to send all the other fields in the request. Otherwise, all other previously configured information will be deleted. Therefore, before making a change, you should get the product data for the same
Id
and use the response as a template to make the change.
If you want to update information from an existing product, send a request to the Update product endpoint, indicating the Id
of the existing product.