Salesforce Commerce API: High-Performance Location Inventory Import for Salesforce Omnichannel Inventory

In the previous article, I explained how to use Salesforce Commerce APIs for OCI. Now, it’s time to use the import file API so we can import data into OCI.

Currently, there are 2 import file APIs we can use to import inventory data:

  1. Location Inventory Import File – High-Performance: Accepts GZIP or JSON files up to 100 MB in size.
  2. Location Inventory Import File – Legacy: The file size limit is 10 MB, and it must be in JSON format.

As you can see, there is no reason to use the legacy version of the import file API because it supports bigger size and GZIP format. Also, the format of the high-performance version is much better.

High-Performance Layout Sample



Legacy Layout Sample




Using the File Import API

Before using the API, I want to make sure that OCI has no data at all, at least for the product that I’ll import. The stockkeeping unit of the product is called PRD-1.

As you see, both API and OCI App are showing stock as zero for the product PRD-1.

In order to use the import file API, we will need to use three different Commerce APIs (one API call will be used for status check)

1. Submit Inventory Import

Submit Inventory Import API call lets OCI know that a file import process is about to happen. The API call will contain the file details such as name, hash type, encoding and the most important file hash.

I will first prepare the json file by using the high-performance layout. The external reference of the location I have is MYLOC. I’ll add 10 quantity for PRD-1 product.

"recordId": "0a875399c752e39dbe0",
"onHand": 10,
"sku": "PRD-1",
"effectiveDate": "2023-04-08T14:05:22.790896-07:00",
"locationId": "MYLOC"

Afterwards, I’ll get the file hash by using a command tool. You can also use any web tool that is publicly available.

Make sure the hash is all lower case.

    "fileName": "inventory.json",
    "linkDuration": 60,
    "fileFormat": "JSON",
    "fileHashType": "SHA-256",
    "fileHash": "5feac9f3f3530c90deacd53a73c2e7519d01f892e7147d95b995ed834cfbfb37"

    "importId": "7181b37d-4ef0-4dfb-b170-22d34c7f8449",
    "importStatusLink": "/inventory/impex/v1/organizations/c5c2e840-27a0-487a-aef4-2ec08a2221b3/availability-records/imports/7181b37d-4ef0-4dfb-b170-22d34c7f8449/status",
    "uploadLink": "/inventory/impex/v1/organizations/c5c2e840-27a0-487a-aef4-2ec08a2221b3/availability-records/imports/uploadlink/7181b37d-4ef0-4dfb-b170-22d34c7f8449",
    "uploadMethod": "POST",
    "uploadLinkExpirationUTC": "2024-03-24T10:06:56.429Z"

In the response, you’ll see two different links which are: status link that we’ll use after posting the file upload to check the status of the process and upload link, the actual upload API.

2. Post Upload Import File

Post Upload Import File is the actual API that triggers the import process. I’ll directly use the upload link from the response of the first API call which we just performed and, I’ll choose the file as an inventory file and add it to API request.

3. Get Availability Import Status

Get Availability Import Status API returns the status of the import process. The status we are looking for is COMPLETED.

Again, I’ll use the import status link endpoint from the response of the first API call.

We have both COMPLETED & SUCCESS status for the import file process. Let’s now check the stock for PRD-1 product via the OCI app in Salesforce.

Let’s also check with Get Availability API.

Leave a Comment

Your email address will not be published. Required fields are marked *