docs
  1. SCAYLE Resource Center
  2. Developer Guides
  3. Logistics
  4. Warehouses

Warehouses

General

SCAYLE comes with multi-warehouse support, allowing you to assign warehouses to merchants and shop countries.

Shop country warehouse

A shop country warehouse represents a warehouse assigned to a shop country.
When assigning a warehouse to a shop country, you can define a priority and a package group.

Priority

Shop country warehouses can have a priority, which allows defining from which warehouse an item should get shipped first. The higher the value, the higher the priority.

Package Group

See Attach Group Overview for more information.

Admin API

Configure warehouses

Warehouses must be configured before sending stock information as variants.

Remember, variants are the last level within SCAYLE's product structure and represent the sellable entity. See Product Structure.

In the next sections, we’ll explain how our warehouses work, how many you might need, and how to configure them based on our example scenario.

Understanding warehouses

In the world of SCAYLE, a warehouse is a logical entity that holds stock for specific variants. Every warehouse is assigned to one or more shop countries.

Need a refresher on shop countries? Check: What is a “Shop Country” in SCAYLE?

A warehouse can represent a physical warehouse, but it doesn’t have to.

Furthermore, warehouses outline priority that defines which stock should be sold first per variant. You can configure priority on the shop country level. The higher the value, the higher the priority. Also, stock assigned to a specific warehouse can have different delivery times on the shop country level (please refer to Delivery Estimations for more information about this feature.)

Warehouses can be configured using the Admin API. However, in most cases, you will only configure warehouses once without further changes, so we recommend using the SCAYLE Panel.

Identifying the correct warehouse structure

The following set of questions can help you to identify which warehouse structure you need:

  1. Do you have more than one physical warehouse? If yes, you can consider having multiple warehouses in SCAYLE.
  2. Do you have more than one physical warehouse, but all warehouses have the same estimated delivery times in all shop countries? If this is the case, you can just use one.
  3. Do you have more than one shop country and more than one physical warehouse? If yes, you should consider translating the warehouses to SCAYLE so you can define which warehouse should serve each shop country.

Applying the theory to practice

Now let’s see how we would set up warehouses for our Fashion Store. Our example operates 2 warehouses. Here are some additional details we need to configure our warehouses:

  1. The warehouse in Germany is in Frankfurt, and the warehouse in Switzerland is in Basel.
  2. The stock in the Basel warehouse is only available in Switzerland, but the stock in the Frankfurt warehouse is available in both countries.
  3. Since Switzerland can retrieve stock from both warehouses, we should consider selling the stock in Basel before the stock in Frankfurt to ensure quick deliveries.

The following diagram illustrates the scenario:

Warehouses

In this situation, we need to create two warehouses. The warehouse in Frankfurt will be assigned to all shop countries, while the warehouse in Basel will only be assigned to the 2 shop countries of Switzerland. (We identified the need to have three shop countries in this chapter: Shop Structure).

First, we have to create the warehouses via the SCAYLE Panel:

  1. Go to Settings > Merchant management > Select default merchant > Edit.
  2. Scroll down until you see the Warehouses like this:

Add Warehouse.

  1. Click on Create new.

Assign your warehouses to specific shop countries

  1. Go to Shops > Shop Name > Shop Country > Storefront > Warehouses.
  2. Select the warehouses that have to be assigned from the dropdown menu and save the form. Perform this step for every shop country/warehouse combination required.

Storefront - Add Warehouse.

Great job! Now you’ve learned the warehouse basics and assigned them to our Fashion Store. Time to send stock information in the next section.

Create warehouse

It is not possible to modify warehouse's referenceKey after its creation!

This method is used to create a new warehouse on a global level.

  • If only one merchant exists, the warehouse is automatically attached to the merchant.
  • If multiple merchants exist, add the warehouse to the shop country using the create shop country warehouse endpoint, then use the dedicated endpoint attach a warehouse to a merchant
let response = await adminApi.apis.Warehouses.createWarehouse({}, {requestBody: warehouse});
warehouse = response.body;

Parameters

ParameterTypeDescriptionRequired
idintegerThe ID of the warehouse created by SCAYLE.true
referenceKeystringA key that uniquely identifies the warehouse within the tenant's ecosystem.true
merchantsMerchantA list of merchants the warehouse is attached to.false
shopCountriesWarehouseShopCountryShop country information related to the warehouse.false
let newWarehouse = {
    referenceKey: "my-warehouse"
};

let response = await adminApi.apis.Warehouses.createWarehouse({}, {requestBody: newWarehouse});
let createdWarehouse = response.body;

console.log(createdWarehouse.id);

Learn how to attach a warehouse to a shop country with its priority and package group.

When you attach a warehouse to a shop country, you can set a priority and assign it to a package group.

This method is used to attach a warehouse to a shop country as described here.

  • When there is only one merchant in the system, the warehouse will be automatically created and attached to the merchant. If there are multiple merchants, the warehouse needs to be created upfront via the dedicated endpoint, and then attached to the relevant merchants and shop countries.
  • Once the warehouse is created, the referenceKey cannot be modified.
let response = await adminApi.apis.Warehouses.createShopCountryWarehouse(
    { shopKey: shopKey, countryCode: countryCode },
    { requestBody: shopCountryWarehouse }
);
let createdShopCountryWarehouse = response.body;

Parameters

ParameterTypeDescriptionRequired
idintegerThe ID of the warehouse created by SCAYLE.true
referenceKeystringA key that uniquely identifies the warehouse within the tenant's ecosystem.true
priorityintegerThe priority of the warehouse. The higher the value, the higher the priority.false
packageGroupPackageGroupThe assigned package group of the warehouse.false

Attach a Warehouse to a Shop Country

let newShopCountryWarehouse = {
    referenceKey: "my-warehouse",
    priority: 100
};

let response = await adminApi.apis.Warehouses.createShopCountryWarehouse(
    {
        shopKey: "ms",
        countryCode: "DE"
    },
    {
        requestBody: newShopCountryWarehouse
    }
);

let createdShopCountryWarehouse = response.body;

Attach with a Package Group

Create a shop warehouse with package group:

let newShopCountryWarehouse = {
    referenceKey: "my-warehouse",
    packageGroup: {
        id: 3
    }
};

let response = await adminApi.apis.Warehouses.createShopCountryWarehouse(
    {
        shopKey: "ms",
        countryCode: "DE"
    },
    {
        requestBody: newShopCountryWarehouse
    }
);

let createdShopCountryWarehouse = response.body;

Attach warehouses to a merchant

This method is used to attach an existing warehouse to a merchant.

await adminApi.apis.Warehouses.attachMerchantWarehouse({merchantIdentifier: 1, warehouseIdentifier: 1});

Attaching the same warehouse to the merchant twice will result in 400 response code with MERCHANT_WAREHOUSE_ALREADY_EXISTS error key.

Example

await adminApi.apis.Warehouses.attachMerchantWarehouse({merchantIdentifier: 1, warehouseIdentifier: 1});

Detach warehouses from a merchant

This method is used to detach a warehouse from a merchant.

await adminApi.apis.Warehouses.detachMerchantWarehouse({merchantIdentifier: merchantIdentifier, warehouseIdentifier: warehouseIdentifier});

Example

await adminApi.apis.Warehouses.detachMerchantWarehouse({merchantIdentifier: merchantIdentifier, warehouseIdentifier: warehouseIdentifier});

Get a collection

You can request multiple warehouses along with the related data such as merchants and shop countries.

This method is used to get a collection of existing warehouses.

ParameterTypeDescriptionRequired
withstringAllows to load the following nested resources within this request: merchants, shopCountriesfalse
limitintegerMaximum number of items in the result. (default: 100, maximum: 1000)false
filters[id]stringComma-separated list of warehouse IDs that should be used for filtering.false
filters[minId]integerMinimum warehouse ID of entities that should be returned.false
filters[maxId]integerMaximum warehouse ID of entities that should be returned.false
sortstringSort by the provided column. Available values: id.false
sortDirstringDefines the sorting order: ascending or descending. Available values: asc (default), desc.false
let response = await adminApi.apis.Warehouses.getWarehouses();
let warehouses = response.body.entities;

Get a collection of warehouses attached to a merchant

You can request warehouses attached to a merchant using its identifier.

let response = await adminApi.apis.Warehouses.getMerchantWarehouses({merchantIdentifier: merchantIdentifier});
let warehouses = response.body.entities;

Options

ParameterDetails
with

String

Allows to load the following nested resources within this request:

  • merchants
  • shopCountries
limit

Integer

Maximum number of items in the result. (default: 100, maximum: 1000)

filters[id]

String

Comma-separated list of warehouse IDs that should be used for filtering.

filters[minId]

Integer

Minimum warehouse ID of entities that should be returned.

filters[maxId]

Integer

Maximum warehouse ID of entities that should be returned.

sort

String

Sort by the provided column. Available values: id.

sortDir

String

Defines the sorting order: ascending or descending.
Available values: asc (default), desc.

Parameters

ParameterTypeDescriptionRequired
entitiesWarehouseA collection of warehouses.true
cursorCursorAn object containing information for pagination.true

Example

let response = await adminApi.apis.Warehouses.getMerchantWarehouses({merchantIdentifier: 1});
let warehouses = response.body.entities;

warehouses.forEach(
    warehouse => console.log(warehouse.id)
);

Update shop country warehouse

In SCAYLE, you can update shop country warehouse relation at any time. The provided information will replace current values and delete old ones.

This method is used to update an existing shop country warehouse relation.

  • This method does not support partial updates.
  • The shop warehouse referenceKey cannot be modified.
let response = await adminApi.apis.Warehouses.updateShopCountryWarehouse(
    { shopKey: shopKey, countryCode: countryCode, shopCountryWarehouseIdentifier: shopCountryWarehouseIdentifier },
    { requestBody: shopCountryWarehouse }
);
let createdShopCountryWarehouse = response.body;

Update Shop Country Warehouse Relation

let shopCountryWarehouse = {
    referenceKey: "my-warehouse",
    priority: 101
};

let response = await adminApi.apis.Warehouses.updateShopCountryWarehouse(
    {
        shopKey: "ms",
        countryCode: "DE",
        shopCountryWarehouseIdentifier: 1
    },
    {
        requestBody: shopCountryWarehouse
    }
);

let updatedShopCountryWarehouse = response.body;

Parameters

ParameterTypeDescriptionRequired
withstringAllows to load the following nested resources within this request: merchants, shopCountriesfalse
limitintegerMaximum number of items in the result. (default: 100, maximum: 1000)false
filters[id]stringComma-separated list of warehouse IDs that should be used for filtering.false
filters[minId]integerMinimum warehouse ID of entities that should be returned.false
filters[maxId]integerMaximum warehouse ID of entities that should be returned.false
sortstringSort by the provided column. Available values: id.false
sortDirstringDefines the sorting order: ascending or descending. Available values: asc (default), desc.false

Detach a warehouse from a shop country

Learn how to detach a warehouse from a shop country.

In SCAYLE, you can detach a warehouse from a shop country. Please make sure to consider all dependencies in advance.

This method can be used to detach a warehouse from a shop country.

This action can not be undone!

adminApi.apis.Warehouses.deleteShopCountryWarehouse(
    { shopKey: shopKey, countryCode: countryCode, shopWarehouseIdentifier: shopWarehouseIdentifier }
);

Examples

Detach by Reference Key

adminApi.apis.Warehouses.deleteShopCountryWarehouse(
    {
        shopKey: "ms",
        countryCode: "DE",
        shopWarehouseIdentifier: "key=my-warehouse"
    }
);

Delete a warehouse

This method is used to delete an existing warehouse.

SCAYLE allows you to delete a warehouse as long as it doesn't have any stock.

await adminApi.apis.Warehouses.deleteWarehouse({warehouseIdentifier: warehouseIdentifier});

Parameters

ParameterDetails
id

Integer READ-ONLY

The ID of the warehouse created by SCAYLE.

referenceKey

String

A key that uniquely identifies the warehouse within the tenant's ecosystem.

merchantsA list of merchants the warehouse is attached to.
shopCountriesShop country information related to the warehouse.

Example

await adminApi.apis.Warehouses.deleteWarehouse({warehouseIdentifier: 1});

Further education - SCAYLE Academy