Appearance
Inventory Webhook Notification (v2)
Webhook Version
This page documents Webhook v2 inventory updates. For the previous version, see Inventory Updates v1.
The Inventory Webhook Notification from MyLION provides you with updates about changes in inventory levels for specific products. This enables you to maintain accurate and up-to-date inventory information within your application. Below, you'll find details about the payload structure of the notification and how to set up your receiving endpoint to process these inventory updates.
What's New in v2
- Product identification is now a nested
productIdobject (instead of flatmyLionId/externalIdfields). skuandparentSkufields added for product identification.- Stock data is now grouped under a
stockDetailobject with more granular fields:localCurrentQuantityreplacesstock.localCurrentProducibleQuantityreplacesmanufacturingQuantity.localIncomingQuantities— new array of upcoming stock arrivals with date and quantity.external1CurrentQuantity/external2CurrentQuantity— new fields for external warehouse stock levels.
Payload Structure
When an inventory update event occurs within the MyLION ERP system, a webhook notification is sent to your designated endpoint. The payload of this notification follows this structure:
json
{
"inventories": [
{
"productId": {
"myLionId": 12345678,
"externalId": "extId"
},
"parentId": {
"myLionId": 456,
"externalId": "parentExtId"
},
"sku": "SKU-001",
"parentSku": "SKU-PARENT",
"stockDetail": {
"localCurrentQuantity": 1.24,
"localCurrentProducibleQuantity": 5.3,
"localIncomingQuantities": [
{
"arrival": "2024-06-01",
"quantity": 100.0
}
],
"external1CurrentQuantity": 10.0,
"external2CurrentQuantity": 5.0
}
}
]
}{
"inventories": [
{
"productId": {
"myLionId": 12345678,
"externalId": "extId"
},
"parentId": {
"myLionId": 456,
"externalId": "parentExtId"
},
"sku": "SKU-001",
"parentSku": "SKU-PARENT",
"stockDetail": {
"localCurrentQuantity": 1.24,
"localCurrentProducibleQuantity": 5.3,
"localIncomingQuantities": [
{
"arrival": "2024-06-01",
"quantity": 100.0
}
],
"external1CurrentQuantity": 10.0,
"external2CurrentQuantity": 5.0
}
}
]
}Field Reference
inventories[]
| Field | Type | Description |
|---|---|---|
productId | object | Identifies the product. See below. |
parentId | object | Identifies the parent product. See below. |
sku | String | The SKU of the product. |
parentSku | String | The SKU of the parent product. |
stockDetail | object | Grouped stock information. See below. |
productId / parentId
| Field | Type | Description |
|---|---|---|
myLionId | Integer | The unique identifier within MyLION. |
externalId | String | Your external identifier. |
stockDetail
| Field | Type | Description |
|---|---|---|
localCurrentQuantity | Double | Current local stock level. |
localCurrentProducibleQuantity | Double | Current producible quantity in the local warehouse. |
localIncomingQuantities | Array<object> | Upcoming stock arrivals. See below. |
external1CurrentQuantity | Double | Current stock level in external warehouse 1. |
external2CurrentQuantity | Double | Current stock level in external warehouse 2. |
localIncomingQuantities[]
| Field | Type | Description |
|---|---|---|
arrival | String | Expected arrival date (yyyy-MM-dd). |
quantity | Double | Expected incoming quantity. |
Receiving Endpoint
To process the Inventory Webhook Notification from MyLION, you need to set up a receiving endpoint in your application. The endpoint URL should follow this format:
bash
https://<your_base_url>/rest/mylion/v2/inventoryhttps://<your_base_url>/rest/mylion/v2/inventoryWhen MyLION sends a webhook notification, it will make a POST request to the specified endpoint with the payload containing the updated inventory information. The expected response is HTTP OK (200), no payload.
Processing the Notification
Upon receiving the webhook notification, you can process the payload to update the inventory levels in your application's database or system. You should validate the authenticity of the incoming request using the webhook authentication method previously outlined to ensure the data's integrity.