This document is intended for merchants and System Integrator (SI) partners who want to migrate or import inventory and order data.

Prerequisites

  • Ensure that you have Orders & Inventory Editor or Administrator privileges to fabric Orders. For more information, see the Role-Based Access Control section.
  • Ensure that you have a valid Authorization Token to provide in the header. When generating an authorization token, ensure that the API System App that you are using to generate the token has the correct role assigned. If a token doesn’t have the correct role, the following error is returned:
{
not a valid key=value pair (missing equal-sign) in Authorization header: {token}
}
  • If you have fabric Products Catalog enabled for your organization, ensure that you create and update the product catalog before importing inventory. If you are using product management software other than fabric’s Product Catalog, you must import your product data using the Products endpoint.
  • Ensure that you have at least one fulfillment location, such as a Distribution Center (DC).

Process

To import inventory, you are required to create an inventory CSV file. Once you have filled in the CSV file, you can upload it to the inventory-imports endpoint. With the file uploaded, fabric process’s the CSV file and populates your inventory. With your baseline inventory populated, you’re ready to update the counters onHand, allocated, and shipped for each location. This populates your total available to purchase amount for each product and populates the inventory for each location.

To import orders, you are required to create an orders JSON file. Once you have completed the JSON file, you can upload it to the oms-imports endpoint. With the file uploaded, fabric process’s the JSON file and populates your orders.

Importing Inventory

Before using the inventory-imports endpoint, you must download and update the Update CSV file template. This file is uploaded in a subsequent API call.

Step 1: Download the CSV template file

  1. Log in to fabric Copilot.

  2. In the left menu, click Inventory.

    The Manage inventory tab is displayed.

  3. Click Import.

    The Import CSV file to add or edit your inventory window is displayed. Two templates are provided.

  4. Click Template: Update.

The inventory_update.csv file is downloaded.

Step 2: Update the CSV template file

The inventory_update.csv file contains a number of columns with optional fields, such as preorder and backorder dates. These fields are set to Null by the system if left blank. The following values are required:

FieldDescription
SKUThe stock keeping unit.
Item IDThe fabric item ID generated after a successful import of a product. This is required only if you use fabric Product Catalog.
Location NumberA unique value used to identify the location such as a DC. Products can have multiple locations associated with their inventory.
Channel IDThe sales channel ID.

Step 3: Create the importId

The inventory-imports endpoint is used to create the importId and returns a uploadFileUrl. The uploadFileUrl is used to upload the CSV file from step 2 that populates your inventory levels.

POST Request:

curl --location --request POST 'https://api.fabric.inc/api/v3/inventory-imports/' \
--header 'x-fabric-tenant-id: {tenantId}' \
--header 'x-fabric-channel-id: 12' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: {authToken} \
--data '{
    "fileName": "C:/Users/Fabric/Downloads/Inventory_Import.csv",
    "type": "INVENTORY"
}'

Response:

{
    "importId": "1716414052775_CUsersFabricDownloadsInventory_Import",
    "uploadFileUrl": "{AWS S3 upload URL}"
}

Step 4: Upload the template file

Use the uploadFileUrl value, which is returned in step 3, and send a PUT request with the template file.

Note: No authorization token is required for this step. If you use Postman, click the URL to automatically open the request in a new tab. Remember to change the request from GET to PUT and in the body of the request click the binary option followed by providing your inventory CSV file.

curl --location --request PUT '{AWS S3 upload URL}' \
--header 'Content-Type: text/csv' \
--data '@/C:/Users/Fabric/Downloads/Inventory_Import.csv'

A successful response returns a 200 status.

Step 5: Check the upload status

Ensure that you have the importId value from the response in Step 3.

You can check your inventory upload status by making a GET request to the inventory-imports/{importId} endpoint.

GET Request:

curl --location --request GET 'https://api.fabric.inc/api/v3/inventory-imports/1716408181352_Inventory_Import' \
--header 'x-fabric-tenant-id: {tenantId}' \
--header 'x-fabric-channel-id: 12' \
--header 'Accept: application/json' \
--header 'Authorization: {authToken}'

Response:

{
    "importId": "1716414052775_CUsersFabricDownloadsInventory_Import",
    "type": "bulk",
    "statusCode": "COMPLETED",
    "attributes": {
        "isTrueUp": false
    },
    "createdAt": "2024-05-22T20:03:01Z",
    "updatedAt": "2024-05-22T20:03:02Z",
    "originalFileUrl": "{AWS S3 upload URL}",
    "importCount": {
        "uploaded": 1,
        "processed": 1,
        "error": 0
    }
}

On the Manage inventory page mentioned in step 1, the Available To Purchase column for each SKU is updated. Note that you may need to refresh your browser to see the update.

Step 6: Update inventory counters

After importing your inventory, update the default counters for onHand, allocated, and shipped for each product. Custom counters are supported and can be created using the Counters API endpoint.

PUT Request:

curl --location --request PUT 'https://api.fabric.inc/v3/inventories/actions/find-and-adjust-inventory-counters' \
--header 'Authorization: Bearer {authorizationToken}' \
--header 'Content-Type: application/json' \
--header 'x-fabric-channel-id: 12' \
--header 'x-fabric-tenant-id: {tenantId}' \
--data '{
  "inventoryId": "664fabec0f0853fe68e2bea8",
  "sku": "123456",
  "itemId": 12332,
  "locationNumber": 90012,
  "counters": {
    "allocated": 50,
    "onHand": 200,
    "shipped": 20
  }
}'

Response:

With the inventory counters updated, the fabric virtual counter also updates the SKU’s Available To Purchase value. In the following example, the value is updated to 130:

{
    "inventoryId": "664e51c60f0853fe681fc3e6",
    "sku": "123456",
    "itemId": 12332,
    "locationNumber": 90012,
    "channelId": "12",
    "createdAt": "2024-05-22T20:12:54.082+00:00",
    "updatedAt": "2024-05-24T22:03:51.903+00:00",
    "backorderLimit": 0,
    "preorderLimit": 0,
    "safetyStock": 0,
    "lowStock": 0,
    "counters": {
        "allocated": 50,
        "onHand": 200,
        "shipped": 20
    },
    "customAttributes": {},
    "networkCounters": {}
}

Importing orders

Before using the oms-imports endpoint, you must create a JSON file containing all your order information in a specific format.

The JSON file is used to provide a centralized source for order, inventory, and warehouse information, enabling you to receive, track, and fulfill customer orders.

Step 1: Create the JSON file containing your orders

Note that each line in the JSON file represents one order. If you want to import 1000 orders , the file should have exactly 1000 lines with each line representing an order object. If you save the JSON file with an extension that makes it more readable or expands the object to more than one line, the upload fails.

Step 2: Retrieve the importId and upload URL

The oms-imports endpoint is used to create the importId and returns a uploadFileUrl. The uploadFileUrl is used to upload the JSON file from step 1.

curl --location --request GET 'https://api.fabric.inc/api/v3/oms-imports' \
--header 'X-Fabric-Tenant-Id: {tenantId}' \
--header 'X-Fabric-Channel-Id: 12' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {authorizationToken}' \
--data '{
    "fileName": "C:/Users/Fabric/Downloads/example_order.json",
    "module": "ORDER",
    "type": "BULK"
}'

Response:

{
    "importId": "6650def0104f907ac98275de",
    "uploadFileUrl": "{AWS S3 Upload URL}",
    "fileName": "example_order.json",
    "module": "ORDER",
    "type": "BULK",
    "statusCode": "INITIATED",
    "createdAt": "2024-05-24T18:39:44Z",
    "updatedAt": "2024-05-24T18:39:44Z"
}

Step 3: Upload the JSON file

Use the uploadFileUrl value, which is returned in step 2, and send a PUT request with the template file.

Note: No authorization token is required for this step. If you use Postman, click the URL to automatically open the request in a new tab. Remember to change the request from GET to PUT and in the body of the request click the binary option followed by providing your inventory CSV file.

curl --location --request PUT '{AWS S3 upload URL}' \
--header 'Content-Type: application/json' \
--data '@/C:/Users/Fabric/Downloads/example_order.json'

A successful response returns a 200 status.

Step 4: Check the status of the import

Ensure that you have the importId value from the response in Step 2.

You can check your order upload status by making a GET request to the oms-imports/{importId} endpoint.

GET Request:

curl --location --request GET 'https://api.fabric.inc/api/v3/oms-imports/{importId}' \
--header 'x-fabric-tenant-id: {tenantId}' \
--header 'x-fabric-channel-id: 12' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {authorizationToken}'

Response:

Depending on the number of orders being imported, this process can take up to 20 minutes to complete. Batches of up to 1 million imports are supported at a time. The statusCode value is set to INITIATED until the process completes.

{
    "importId": "6670898e85d8c162c403f4d3",
    "fileName": "example_order_2.json",
    "module": "ORDER",
    "type": "BULK",
    "statusCode": "COMPLETED",
    "createdAt": "2024-06-17T19:07:58Z",
    "updatedAt": "2024-06-17T19:11:30Z",
    "originalFileUrl": "{AWS S3 Upload URL}"
}

Step 5: Use the order number to retrieve an order

To verify the orders are imported, make a GET request to the orders/order-number/{orderNumber} endpoint using one of the imported order numbers.

Request:

curl --location --request GET 'https://api.fabric.inc/api/v3/orders/order-number/{orderNumber}' \
--header 'x-fabric-tenant-id: {tenantId}' \
--header 'x-fabric-channel-id: 12' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {authorizationToken}'

A successful response returns a 200 status with an order object in the payload.