Import Physical Inventory

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:

  • TAB Delimited
  • CSV
  • Excel

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

  • Method Type: HttpPut
  • Authorization: Use Bearer Token + token received from token authentication
  • Header info: Content-Type: application/json
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
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

  • If inventory is imported successfully, then response will be Status Code 200 => OK
  • If token is not valid, then response will be Status Code 401 => Not Valid Token
  • Error on server response => Status Code 500 => Internal Server Error

Demo

Full
}

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 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; }
}

Was this article helpful?

Related Articles