Salesforce Commerce Product and Category APIs

Streamline product catalog management and improve the shopping experience by using the Salesforce Commerce Product and Category APIs. You can add or update products in your store, link them with specific categories and media records, create variation products, and get product information such as fields, prices, and category paths. The APIs also support product searches by term or category, search suggestions for products, and retrieval of sort rules for the search index.

To add a product to your store, use Commerce Webstore Composite Products, Create. If you want to add a variation of a parent product, such as a different color or size of a shirt, you can use Commerce Webstore Composite Product Variations, Create. These APIs work within the store’s context. When you create a product, the APIs link it to the default buyer group, entitlement policy, and price book records created during store setup. They also associate it to the current store’s catalog and the specified category and media in the POST request.

To update an existing product, make a PUT request to the Commerce Webstore Composite Products, Update resource. When you update a product record, include both the category and media records that are already linked to it and any new ones that you want to add. If you don’t specify the existing associated category and media records, the API removes their association with the product.

To retrieve information about products, you can use one of three resources that support GET requests. These resources respect buyer View Product entitlements, so only users entitled to product data can access it.

  1. For the Product Detail representation of a specific product, make a GET request to the Commerce Webstore Product resource.
  2. For the fields, prices, and default images for a list of products, make a GET request to the Commerce Webstore Products resource.
  3. For a collection of bundle or set child products related to a parent product, make a GET request to the Commerce Webstore Product Children resource.

Effective category structure in a store highlights product relationships and makes products easier to find through search and navigation. To help access your store’s product category information, Salesforce Commerce provides three API resources.

To get the details of a product category, make a GET request to Commerce Webstore Product Category. Include the IDs of the product category and the webstore in the request URL. The response body contains information such as a list of fields, media groups, and the URL slug for the category.

To get subcategories for a specific parent product category or get all the top-level product categories for the store, make a GET request to Commerce Webstore Product Categories Children. The output depends on whether you set the ​​parentProductCategoryId request parameter. If you provide the ID of a product category, the API returns each of that category’s subcategories. A store supports up to 5 levels of categories and subcategories. If ​​parentProductCategoryId is unspecified, the API returns all the top-level product categories for the store.

To get the product category path from the root category to a specific category, make a GET request to Commerce Webstore Product Category Path. The response includes a list of categories in the path with each category’s ID, name, description, and URL slug. This information can help you highlight category hierarchy. For example, you can show a category path that goes from Coffee Beans to Dark Roast.

Help your customers find what they’re looking for with the Product Search APIs. Use these APIs to search for products in your catalog based on search terms or a category ID. You can also get suggested products for a search term, and get sort rules for the search index.

To search for products, make a GET request to Commerce Webstore Search Products. In your request, include a list of up to 32 space-separated search terms. To return only products from a particular product category, specify a category ID as well. You can specify just the category ID to return all products from that category without matching search terms, but at least 1 category ID or search term is required.

A resource was previously introduced to search products by using a POST request, but it was superseded by the GET endpoint. We recommend using the GET endpoint to take advantage of the latest API features. For example, only the GET endpoint supports the parameter searchFields, which is used to specify a subset of searchable fields to query.

To return suggested search terms or products, make a GET request to Commerce Webstore Product Search Suggestions. In your request, you can include a string with up to 10 characters of a user’s search term. The response returns autocomplete suggestions from the user’s recent searches and suggestions from the product catalog. For example, the search term ground can return ground coffee, among other suggestions. Specify how many suggestions to return by setting the maxResults request parameter to a value from 1 to 10. If unspecified, this value defaults to 4.

You can also use this resource without providing a search term. If there’s no search term, the API identifies suggestions based on the user’s recent searches. In the example scenario, after searching for ground coffee, that term can be suggested the next time the user starts a search.

To return suggested products rather than terms, set the boolean request parameter includeSuggestedProducts to true. Product suggestions are returned as product IDs. Then, a call to one of the Product APIs can return information based on the product ID. For example, you can show the name and default image of a product in the search bar dropdown.

Lastly, to retrieve sort rules for a webstore, make a GET request to Commerce Management Webstore Search, Sort Rules. The Commerce search engine’s default Best Match rule sorts search results based on relevance. You can also add custom sort rules with a PUT request so that customers can arrange results by options like price in search and category pages.

To understand the Product and Category APIs, consider the steps involved in a sample workflow. This scenario doesn’t include the entire functionality of the APIs.

Workflow of Product and Category APIs: add products and sort rules, suggest search terms and products, and get search results

A store manager begins by using the Commerce Webstore Composite Products, Create API to update the store’s catalog, adding new products. This action ensures that customers always see the latest offerings and accurate product details.

For products that come in multiple variations, such as different sizes or colors, the manager uses the Commerce Webstore Composite Product Variations, Create API to create these variation listings. Now, customers can choose their preferred product variations directly from the product page.

To add custom sort rules, the manager uses the Commerce Management Webstore Search, Sort Rules API. For example, they can create a sort rule so that customers can arrange results based on product attributes.

In the webstore, customers use the improved search functionality provided by the Commerce Webstore Search Products and Commerce Webstore Product Search Suggestions APIs. They can quickly find products through search terms or categories, and the suggestions help them discover products more easily.

ResourceSupported HTTP MethodsDescription
/commerce/management/webstore/${webstoreId}/composite-productsPOSTAdd a product to your store and associate it with the specified category and media records.
/commerce/management/webstore/${webstoreId}/composite-products/${productId}PUTUpdate an existing product record with the specified category and media records.
/commerce/management/webstore/${webstoreId}/composite-variationsPOSTCreate variation products with media and pricing details for a given parent product.
/commerce/webstores/{webstoreId}/productsGETGet fields, prices, and default images for a list of products.
/commerce/webstores/{webstoreId}/products/{​productId}GETGet a product.
/commerce/webstores/{webstoreId}/products/{​productId}/childrenGETGet a collection of child products related to a parent product.
/commerce/webstores/{webstoreId}/​product-categories/childrenGETGet product categories for a specific parent product category, or get all the top-level product categories for the store.
/commerce/webstores/{webstoreId}/​product-categories/{productCategoryId}GETGet a product category.
/commerce/webstores/{webstoreId}/​product-category-path/product-categories/​{productCategoryId}GETGet the product category path from the root category to the current category.
/commerce/webstores/{webstoreId}/search/​productsGETSearch products by search term or category in a webstore.
/commerce/webstores/{webstoreId}/search/​product-searchPOSTSearch products.
/commerce/webstores/{webstoreId}/search/​sort-rulesGETGet sort rules for the live index.
/commerce/webstores/{webstoreId}/search/​suggestionsGETGet suggestions for product searches.