Skip to main content

Stock Groupers API

The Stock Groupers API allows you to manage stock groupers in the Nilo platform. Stock groupers represent warehouses or depots that serve specific stores. These endpoints help you create, update, and manage stock groupers for inventory distribution.

Understanding Stock Groupers

Stock Groupers in Nilo represent warehouses or distribution centers:

  • Grouper Structure
    • Unique internal code for identification (same as warehouse code in your ERP)
    • Name for display and organization
    • Status (enabled/disabled)
    • Store associations (which stores are served by this warehouse)

Important Considerations

  1. Unique Codes: Each grouper requires a unique internal code (typically your warehouse code from ERP)
  2. Store Associations: Groupers define which stores are served by which warehouse
  3. Status Management: Groupers can be enabled or disabled without deletion
  4. Batch Operations: Support for bulk store assignment/removal

Single Grouper Operations

Create Stock Grouper

POST/grouper/stock

Creates a new stock grouper in the Nilo platform.

Request Body Parameters

ParameterTypeRequiredDescription
namestringYesName of the grouper
internalCodestringYesUnique identifier for grouper

Request Body Example

{
"name": "Grouper 1",
"internalCode": "1235"
}

Example Usage

const headers = {
Authorization: "YOUR_AUTH_TOKEN",
"x-api-key": "YOUR_API_KEY",
"Content-Type": "application/json",
};

const data = {
name: "Grouper 1",
internalCode: "1235",
};

fetch("https://api.nilo.com/grouper/stock", {
method: "POST",
headers: headers,
body: JSON.stringify(data),
})
.then((response) => response.json())
.then((result) => console.log(result))
.catch((error) => console.log("error", error));

Update Stock Grouper

PUT/grouper/{code}/stock

Updates an existing stock grouper.

Path Parameters

ParameterTypeRequiredDescription
codestringYesGrouper code to update

Request Body Parameters

ParameterTypeRequiredDescription
namestringYesNew name of grouper

Request Body Example

{
"name": "Grouper 1"
}

Example Usage

const headers = {
Authorization: "YOUR_AUTH_TOKEN",
"x-api-key": "YOUR_API_KEY",
"Content-Type": "application/json",
};

const data = {
name: "Grouper 1",
};

fetch("https://api.nilo.com/grouper/7234/stock", {
method: "PUT",
headers: headers,
body: JSON.stringify(data),
})
.then((response) => response.json())
.then((result) => console.log(result))
.catch((error) => console.log("error", error));

Change Stock Grouper Status

PUT/grouper/{code}/status/stock

Enable or disable a specific stock grouper.

Path Parameters

ParameterTypeRequiredDescription
codestringYesGrouper code

Request Body Parameters

ParameterTypeRequiredDescription
enabledbooleanYesNew status of the grouper

Request Body Example

{
"enabled": true
}

Example Usage

const headers = {
Authorization: "YOUR_AUTH_TOKEN",
"x-api-key": "YOUR_API_KEY",
"Content-Type": "application/json",
};

const data = {
enabled: true,
};

fetch("https://api.nilo.com/grouper/7234/status/stock", {
method: "PUT",
headers: headers,
body: JSON.stringify(data),
})
.then((response) => response.json())
.then((result) => console.log(result))
.catch((error) => console.log("error", error));

Batch Operations

Batch Update Stock Grouper Store Assignments

POST/batch/grouper/stock

Add or remove stores from stock groupers in a single operation. This defines which stores are served by which warehouse.

Request Body Parameters

ParameterTypeRequiredDescription
addobjectNoStores to add to groupers
removeobjectNoStores to remove from groupers

stores array items:

FieldTypeRequiredDescription
groupInternalCodestringYesInternal code of the grouper
storeInternalCodestringYesInternal code of the store

Request Body Example

{
"add": {
"stores": [
{
"groupInternalCode": "WAREHOUSE-001",
"storeInternalCode": "STORE-123"
},
{
"groupInternalCode": "WAREHOUSE-001",
"storeInternalCode": "STORE-456"
}
]
},
"remove": {
"stores": [
{
"groupInternalCode": "WAREHOUSE-002",
"storeInternalCode": "STORE-789"
}
]
}
}

Response Codes

CodeDescription
202Request accepted, processing initiated
402Bad request

Example Usage

const headers = {
Authorization: "YOUR_AUTH_TOKEN",
"x-api-key": "YOUR_API_KEY",
"Content-Type": "application/json",
};

const data = {
add: {
stores: [
{
groupInternalCode: "WAREHOUSE-001",
storeInternalCode: "STORE-123",
},
],
},
remove: {
stores: [
{
groupInternalCode: "WAREHOUSE-002",
storeInternalCode: "STORE-789",
},
],
},
};

fetch(
"https://tm0cs5kjs6.execute-api.us-east-1.amazonaws.com/dev/batch/grouper/stock",
{
method: "POST",
headers: headers,
body: JSON.stringify(data),
}
)
.then((response) => response.json())
.then((result) => console.log(result))
.catch((error) => console.log("error", error));
Stock vs Stock Groupers

This endpoint manages store assignments to stock groupers. To update product availability within a grouper, use the /batch/stock/grouper endpoint in the Stock section.

Security

Authentication

All endpoints require two types of authentication:

  • API Key in header: x-api-key
  • Authorization token in header: Authorization

Required Permissions

For stock grouper endpoints, the following permissions are required:

  • For write operations: supplier/grouper.write
  • For batch operations: supplier/grouper.bulkwrite