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
Parameter | Type | Description |
---|---|---|
name | string | Merchant Name: Officially registered name under which the merchant operates |
referenceKey | string | The unique identifier used to differentiate each merchant within the Scayle platform. |
priority | integer | Priority of the merchant. Merchants with higher number has priorty in case of product aggregation |
orderDelegationUrl | URL | URL to send order delegation requests to the merchant |
cancellationUrl | URL | URL 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.
Parameter | Type | Description |
---|---|---|
name | string | name of the merchant |
referenceKey | string | reference key of the merchant. |
priority | integer | priority of the merchant |
orderDelegationUrl | string | URL to send order delegation requests to the merchant |
cancellationUrl | string | URL 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.
Parameter | Type | Description |
---|---|---|
id | integer | The ID of the merchant created by SCAYLE |
name | string | name of the merchant |
referenceKey | string | reference key of the merchant |
priority | integer | priority of the merchant |
orderDelegationUrl | string | URL to send order delegation requests to the merchant |
cancellationUrl | string | URL to send order cancellation requests to the merchant |
contacts | MerchantContact[] | A list of contacts connected to the merchant. |
returnAddress | ReturnAddresses[] | A list of return address connected to the merchant in different shop countries |
carriers | Carrier[] | A list of carriers connected to the merchant in different shop countries |
warehouses | Warehouse[] | 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
Parameter | Details |
---|---|
with | String Allows to load the following nested resources within this request:
|
limit | Integer Maximum number of items in the result. (default: |
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
Parameter | Details |
---|---|
entities | A collection of merchants. |
cursor | An 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;