docs
  1. SCAYLE Resource Center
  2. Developer Guides
  3. Products
  4. Manage Merchants

Manage Merchants

General

Merchant is a term used for various assortment sources that supply products to the system and deliver these products to the clients. A default merchant with merchant reference key "default" is created during the integration phase. If the merchant reference key is not specified in the product creation request, the newly created product will be assigned to the default merchant.

Admin API

Create a merchant

When creating a new merchant you can specify two URLs to manage the order process more efficiently.

  • Order Delegation URL: Used for delegating orders to merchants.
  • Cancellation URL: Used for delegating order cancellations.

Both webhooks operate in a blocking mode, executing synchronously during order creation and cancellation. When an order is created or cancelled, a request is sent to the respective webhook, which must complete its operation before the process continues. This ensures that workflows or processes tied to these webhooks are executed in real-time, providing up-to-date and accurate order

When setting up webhooks that require basic authentication, include the username and password in the URL.

This method is used to create a new merchant.

let newMerchant = {
    name: "ACME",
    referenceKey: "acme",
    priority: 1,
    orderDelegationUrl: "https://username:[email protected]/order",
    cancellationUrl: "https://username:[email protected]/order-cancel"
};
let response = await 
adminApi.apis.Merchants.createMerchant({requestBody: newMerchant});
let merchant = response.body;

When creating new merchants the following validation rules must pass:

  • Merchant with the same reference key should not exist in the DB.

Parameters

ParameterTypeDescription
namestringMerchant Name: Officially registered name under which the merchant operates
referenceKeystringThe unique identifier used to differentiate each merchant within the Scayle platform.
priorityintegerPriority of the merchant. Merchants with higher number has priorty in case of product aggregation
orderDelegationUrlURLURL to send order delegation requests to the merchant
cancellationUrlURLURL to send order cancellation requests to the merchant

When a username and password are included in the delegation or cancellation URL, they will be masked in the response.

Update Merchant

You can update a Merchant by providing the respective attributes with new values to replace the old ones.

This method can be used to update or replace an existing brand.

This method does not support partial updates.

let response = await client.apis.Merchants.getMerchant({merchantIdentifier: 1});
let merchant = response.body;
​
merchant.priority = 5;
merchant.cancellationUrl = "https://username:[email protected]/order/cancelleation";
response = await client.apis.Merchants.updateMerchant({merchantIdentifier: merchant.id}, {requestBody: merchant});

When creating new merchants the following validation rules must pass:

  • Merchants with the provided reference key should not exist in the DB.
  • If the merchant with the same reference key exists it should belong to the same merchant provided in the request.
ParameterTypeDescription
namestringname of the merchant
referenceKeystringreference key of the merchant.
priorityintegerpriority of the merchant
orderDelegationUrlstringURL to send order delegation requests to the merchant
cancellationUrlstringURL to send order cancellation requests to the merchant

When a username and password are included in the delegation or cancellation URL, they will be masked in response.

Get A Merchant

When you create a brand, SCAYLE will assign a unique ID for internal references. You can use this ID or the reference key to get a merchant.

This method allows including nested resources using with parameter.

ParameterTypeDescription
idintegerThe ID of the merchant created by SCAYLE
namestringname of the merchant
referenceKeystringreference key of the merchant
priorityintegerpriority of the merchant
orderDelegationUrlstringURL to send order delegation requests to the merchant
cancellationUrlstringURL to send order cancellation requests to the merchant
contactsMerchantContact[]A list of contacts connected to the merchant.
returnAddressReturnAddresses[]A list of return address connected to the merchant in different shop countries
carriersCarrier[]A list of carriers connected to the merchant in different shop countries
warehousesWarehouse[]A list of warehouses connected to the merchant

Get merchant by ID

response = await adminApi.apis.Merchants.getMerchant({merchantId: 1});
let merchant = response.body;

Get a Merchant with warehouses

response = await adminApi.apis.Merchants.getMerchant({
  merchantId: 1,
  with: 'warehouses'
})

Get a collection of Merchants

Learn how to retrieve a collection of merchants.

You can request multiple merchants by e.g., specifying merchant Id. As search results are paginated, you can set the amount of merchants displayed per page.

About this Method

This method can be used to get a collection of existing merchant. It is possible to refine the search by applying filters in the options.

This method allows including nested resources using the with parameter.

Get Merchants

let response = await adminApi.apis.Merchants.getMerchants();

Options

ParameterDetails
with

String

Allows to load the following nested resources within this request:

  • contacts
  • carriers
  • returnAddresses
  • warehouses
limit

Integer

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

filters[minId]

Integer

Return merchants with an ID greater than or equal to the minId

filters[maxId]

Integer

Return merchants with ID less than or equal to the maxId

Merchant Collection

ParameterDetails
entitiesA collection of merchants.
cursorAn object containing information for use in pagination.

Examples

Get a list of 10 Merchants

let response = await adminApi.apis.Merchants.getMerchants({
  limit: 10
});
let brands = response.body.entities;