Import Physical Inventory - Sellercloud API Docs

Overview

This endpoint is for importing inventory in bulk via the Rest API. (For setting the physical inventory of an individual product via the REST API, see here instead.) This endpoint exposes the same functionality as the Import Physical Inventory feature in our new Sellercloud UI.

In order to do a bulk inventory import, you must first download an Import Physical Inventory template file from the Sellercloud UI in one of these formats:

See this article for assistance with getting a template file. After you’ve downloaded a template file and populated with inventory info (either manually or via code), you can proceed with importing that file via the REST API.

In order to import physical inventory in bulk, you must have a valid token, which is received after authentication. For information on how you can authenticate, see: Authentication

Endpoint

This would be the endpoint for the TT server:

https://tt.api.sellercloud.com/rest/api/Inventory/ImportPhysicalInventory

For your server, the endpoint will be:

https://{your_server_id}.api.sellercloud.com/rest/api/Inventory/ImportPhysicalInventory

Request

Parameter Data Type Description Is Required
UpdateType int Partial: 0
Full: 1
Optional.
Default value: Partial
Partial is strongly recommended. Full will set any SKU in the system that is not in the file to a quantity of zero.
No
FileContent string Base64 encoded string, which represents file content Yes
FileExtension string The file extension. Must be provided when the format is excel and the file is with extension “.xlsx”. Example “.xlsx”. No
InventoryDate DateTime Inventory Date
Optional.
Default value: current time of import.
No
Format int Tab Delimited: 0
CSV: 1
Excel: 2
Yes
WarehouseID int ID of the warehouse where the imported inventory should be set Yes
PinCode string Pin Code Depends, see below
MergeDefaultWarehouseInventoryIntoShadowParent bool If to merge default warehouse inventory into shadow parent.
Optional.
Default Value: True
No

Pin code is required if client setting “ Require PIN to change inventory quantity” is enabled.

Response

Demo

public enum PhysicalInventoryUpdateType
    {
        Partial,
        Full
    }
public enum FileFormatType
    {
        TAB_Delimited = 0,
        CSV = 1,
        Excel = 2
    }
string url = $"http://cwa.api.sellercloud.com/api/Inventory/ImportPhysicalInventory";
string token = "test_token";

var content = new ImportBulkPhysicalInventoryRequest()
{
    FileContents = Convert.ToBase64String(File.ReadAllBytes($@"C:DataTestRunsBulk.xls")),
    Format = FileFormatType.Excel,
    UpdateType = PhysicalInventoryUpdateType.Partial,
    InventoryDate = DateTime.Now,
    MergeDefaultWarehouseInventoryIntoShadowParent = true
};

using (var client = new HttpClient())
using (var request = new HttpRequestMessage(HttpMethod.Post, url))
{
    client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
    var json = JsonConvert.SerializeObject(content);
    using (var stringContent = new StringContent(json, Encoding.UTF8, "application/json"))
    {
        request.Content = stringContent;
        var responseMessage = await client.SendAsync(request);
        var jsonContent = await responseMessage.Content.ReadAsStringAsync();
    }
}
public class ImportBulkPhysicalInventoryRequest
{
    public PhysicalInventoryUpdateType? UpdateType { get; set; }
    public string FileContent { get; set; }
    public DateTime? InventoryDate { get; set; }
    public FileFormatType? Format { get; set; }
    public int? WarehouseID { get; set; }
    public string PinCode { get; set; }
    public bool MergeDefaultWarehouseInventoryIntoShadowParent { get; set; }
}