Skip to main content

Product Stock by Warehouse

Query the amount of available stock per product in a specific warehouse. This endpoint is essential for verifying availability before creating orders.

GET/v1/client/products/stock

This endpoint allows you to obtain the amount of available stock per product in the selected warehouse. It is necessary to provide the Authorization header with the Bearer token obtained previously and also provide a query param with the ID of the warehouse you want to query.

Headers

ParameterTypeRequiredDescription
Authorizationstringβœ… YesBearer token obtained from /token/generate endpoint

Query Parameters

ParameterTypeRequiredDescription
warehouse_idintegerβœ… YesID of the warehouse to query

Examples

curl -X GET "https://apisandbox.eonwms.com/v1/client/products/stock?warehouse_id=1" \
-H "Authorization: Bearer YOUR_TOKEN"

Responses

200Success - List of products with stock

{
"data": [
{
"id": "1",
"type": "product",
"attributes": {
"sku": "THISISSKU01",
"description": "WINGSPAN BOARDGAME",
"stock": {
"quantity": 997
}
}
},
{
"id": "2",
"type": "product",
"attributes": {
"sku": "THISISSKU2",
"description": "WINGSPAN OCEANIA EXPANTION",
"stock": {
"quantity": 500
}
}
}
]
}

401Unauthorized - Invalid token

{
"code": 401,
"fault": {
"arguments": {
"Authorization": "invalid"
},
"type": "InvalidAuthorizationException",
"message": "The request is unauthorized, the access token is invalid."
}
}

422Unprocessable - Invalid warehouse

{
"code": 422,
"fault": {
"arguments": {
"warehouse": "invalid"
},
"type": "warehouseParamIsInvalid",
"message": "the client does not have access to the selected warehouse."
}
}

Response Structure​

Each product in the data array includes:

Product Information​

  • id: Internal product ID
  • type: Will always be "product"
  • attributes: Contains product details
    • sku: Unique product code (Stock Keeping Unit)
    • description: Product description
    • stock: Inventory information
      • quantity: Available quantity in the warehouse

Stock Considerations​

Real-Time Stock​

The displayed stock is real-time and considers:

  • βœ… Available physical inventory
  • βœ… Reservations from orders in process
  • βœ… Recent inventory adjustments

Stock DOES NOT Include​

  • ❌ Products in transit to the warehouse
  • ❌ Damaged or quarantined products
  • ❌ Scheduled future reservations

Common Use Cases​

1. Pre-Order Verification​

async function validateOrderAvailability(warehouseId, products) {
// Get current stock
const response = await fetch(
`https://apisandbox.eonwms.com/v1/client/products/stock?warehouse_id=${warehouseId}`,
{
headers: { 'Authorization': 'Bearer YOUR_TOKEN' }
}
);

const stockData = await response.json();
const issues = [];

// Check each order product
for (const item of products) {
const productInStock = stockData.data.find(
p => p.attributes.sku === item.sku
);

if (!productInStock) {
issues.push({
sku: item.sku,
type: 'NOT_EXISTS',
message: `Product ${item.sku} does not exist in the warehouse`
});
continue;
}

const available = productInStock.attributes.stock.quantity;

if (available < item.quantity) {
issues.push({
sku: item.sku,
type: 'INSUFFICIENT_STOCK',
message: `Only ${available} units available, ${item.quantity} required`,
available,
required: item.quantity,
missing: item.quantity - available
});
}
}

return {
validOrder: issues.length === 0,
issues
};
}

2. Low Stock Monitor​

async function monitorLowStock(warehouseId, minimumThreshold = 10) {
const response = await fetch(
`https://apisandbox.eonwms.com/v1/client/products/stock?warehouse_id=${warehouseId}`,
{
headers: { 'Authorization': 'Bearer YOUR_TOKEN' }
}
);

const stockData = await response.json();

const lowStockProducts = stockData.data
.filter(p => p.attributes.stock.quantity <= minimumThreshold)
.map(p => ({
sku: p.attributes.sku,
description: p.attributes.description,
currentStock: p.attributes.stock.quantity,
status: p.attributes.stock.quantity === 0 ? 'OUT_OF_STOCK' : 'LOW_STOCK'
}));

if (lowStockProducts.length > 0) {
console.log(`⚠️ Alert: ${lowStockProducts.length} products with low stock`);
lowStockProducts.forEach(p => {
console.log(`- ${p.sku}: ${p.currentStock} units (${p.status})`);
});
}

return lowStockProducts;
}

3. Inventory Report​

async function generateInventoryReport(warehouseId) {
const response = await fetch(
`https://apisandbox.eonwms.com/v1/client/products/stock?warehouse_id=${warehouseId}`,
{
headers: { 'Authorization': 'Bearer YOUR_TOKEN' }
}
);

const stockData = await response.json();

// Calculate metrics
const totalSKUs = stockData.data.length;
const totalUnits = stockData.data.reduce(
(sum, p) => sum + p.attributes.stock.quantity, 0
);
const outOfStockSKUs = stockData.data.filter(
p => p.attributes.stock.quantity === 0
).length;
const inStockSKUs = totalSKUs - outOfStockSKUs;

// Generate report
const report = {
warehouse: warehouseId,
date: new Date().toISOString(),
summary: {
totalSKUs,
inStockSKUs,
outOfStockSKUs,
totalUnits,
availabilityPercentage: ((inStockSKUs / totalSKUs) * 100).toFixed(2) + '%'
},
productDetails: stockData.data.map(p => ({
sku: p.attributes.sku,
description: p.attributes.description,
stock: p.attributes.stock.quantity,
status: p.attributes.stock.quantity === 0 ? 'Out of Stock' :
p.attributes.stock.quantity < 10 ? 'Low Stock' : 'Available'
}))
};

return report;
}

4. External System Synchronization​

class InventorySynchronizer {
constructor(token, warehouseId) {
this.token = token;
this.warehouseId = warehouseId;
}

async getChronosStock() {
const response = await fetch(
`https://apisandbox.eonwms.com/v1/client/products/stock?warehouse_id=${this.warehouseId}`,
{
headers: { 'Authorization': `Bearer ${this.token}` }
}
);

return await response.json();
}

async syncWithLocalSystem(updateCallback) {
try {
const chronosStock = await this.getChronosStock();

for (const product of chronosStock.data) {
const { sku, stock } = product.attributes;

// Update local system
await updateCallback(sku, stock.quantity);
}

return {
success: true,
productsSynced: chronosStock.data.length
};
} catch (error) {
return {
success: false,
error: error.message
};
}
}
}

// Usage
const synchronizer = new InventorySynchronizer('YOUR_TOKEN', 1);

await synchronizer.syncWithLocalSystem(async (sku, quantity) => {
// Update your local database
await db.products.update({ sku }, { chronosStock: quantity });
});

Best Practices​

Query Frequency​

  • Before each order: Always verify stock
  • Periodic updates: Every 15-30 minutes for synchronization
  • Alerts: Set up hourly checks for critical products

Handling Zero Stock​

function handleOutOfStock(sku, alternatives = []) {
// Options when there's no stock:

// 1. Search in other warehouses
const searchOtherWarehouses = async () => {
const warehouses = await getAvailableWarehouses();
for (const wh of warehouses) {
const stock = await checkStock(wh.id, sku);
if (stock > 0) return { warehouseId: wh.id, stock };
}
return null;
};

// 2. Suggest alternative products
const suggestAlternatives = () => {
return alternatives.filter(alt => alt.stock > 0);
};

// 3. Allow backorder (if enabled)
const allowBackorder = () => {
return {
message: "Product available for order. Extended delivery time.",
estimatedTime: "7-10 days"
};
};
}
Query Optimization

If you need to check multiple SKUs, it's more efficient to make a single query and filter locally instead of making multiple calls per individual SKU.

Stock Synchronization

Stock can change rapidly. Always verify availability just before creating an order, don't rely on cached data for too long.

Reserved Stock

When you create an order, stock is automatically reserved. If the order is cancelled or not processed, the stock is released after a determined time.