Salesforce Commerce Import APIs
Import product and category data to a store with a .csv
file by using the Salesforce Commerce Import APIs. You can import data asynchronously.
For product data, there are two Commerce Import Product Job resources: one to create a product import job, and another to manage a job. Use Commerce Import Product Job, Create to globally update or add products and related entities from a specified product import file. Use the manage resource to get the status of a job with a GET request or cancel a job with a PATCH request. For the PATCH request, specify the status
property as Aborted
in the Product Import Cancel Input request body.
A resource was previously introduced for synchronous product imports, but it was superseded by asynchronous product imports, and we plan to remove it in API version 63.0. Use Commerce Import Product Job, Create to import products instead.
When you construct a product import .csv file, specify column headings that correspond to product, category, and price book information. Each row in the file represents a product and its variations. See CSV File Format for Importing Commerce Data.
The Import APIs for category data are similar to the resources for product data. To import category data asynchronously, make a POST request to the Commerce Import Category Job, Create resource. To get the status of a category import job, make a GET request to the Commerce Import Category Job, Manage resource. To cancel a category import job, make a PATCH request to the manage resource with the status
property specified as Aborted
in the Category Import Abort Input request body.
When you construct a category import .csv file, specify column headings that correspond to category path, URL slug, and category description information. Each row in the file represents a category and its structure. See CSV File Format for Importing Category Data for a Store.
To understand the Import APIs, consider the steps involved in a product import. This scenario features just a few Import APIs and doesn't include the entire functionality.
First, construct a .csv
file where column headings correspond to product, category, and price book information and each row represents a product and its variations. The column headings are case-insensitive, and the columns can be in any order. To properly encode special characters, save the .csv
file in UTF-8 format.
Then, upload your file to Salesforce Files. The upload assigns the file a content version ID, which the Import APIs use later to access the file. To get the content version ID, view the file details in the Salesforce Files UI. The second-to-last part of the URL is the content version ID. If you upload the file by using the User Files Connect API, the API response includes the content version ID.
Next, make a POST request to /commerce/management/import/product/jobs
. The request body for POST, Global Product Import Input, has a property, importConfiguration
, that specifies the settings and source for the import. Import Settings are applied to all products in the import file and can set details such as which CMS workspace or entitlement policy to associate with the products. The importSettings
property is required if you specify media-related, price-related, or category-related column headings in your .csv
file.
To provide the content version ID for your file, use the importSource
property of the request body. If you’re simply testing the API functionality, you can also provide a sample .csv
file by setting the sampleData
property to one of the pre-defined datasets (for example, B2BSampleData
).
Resource | Supported HTTP Methods | Description |
---|---|---|
/commerce/management/import/category/jobs | POST | Create a job to asynchronously import category data by using a .csv file. |
/commerce/management/import/category/jobs/{jobId} | GET, PATCH | Cancel or get the status of a job to asynchronously import category data by using a .csv file. |
/commerce/management/webstores/{webstoreId}/product-import | POST | Synchronously import products for a B2B or D2C store by using a .csv file. |
/commerce/management/import/product/jobs | POST | Create a job to asynchronously import product data by using a .csv file. |
/commerce/management/import/product/jobs/{jobId} | GET, PATCH | Manage an asynchronous product import job. You can cancel or get the status of the job. |