Api Reference

Inventory Levels

Edit this page

Inventory Levels API

Scope: Workspace-scoped — requires authenticated organization context and valid credentials for that workspace.

Endpoints

Create Inventory Level

POST /api/inventory-levels

Create or update inventory level settings (min/max/reorder quantities) for a product at a location.

Request Body:

1{
2 "productMasterId": "prod_123",
3 "locationId": "loc_123",
4 "minQuantity": 50,
5 "reorderQuantity": 100,
6 "maxQuantity": 500,
7 "status": "Supported",
8 "abcClass": "A",
9 "expectedLeadTimeDays": 7,
10 "replenishmentPeriodDays": 14,
11 "forecastPeriodDays": 30,
12 "forecastQuantity": 200,
13 "preferredBinLocationId": "bin_123",
14 "replenishmentLocationId": "loc_456",
15 "comments": "High priority item"
16}

Request Fields:

| Field | Type | Required | Description | |-------|------|----------|-------------| | productMasterId | string | Yes* | Product Master ID (or productId for legacy) | | productId | string | No | Legacy Product ID (deprecated) | | locationId | string | Yes | Location ID | | minQuantity | number | No | Minimum quantity (must be ≤ reorder ≤ max) | | reorderQuantity | number | No | Reorder point (must be ≥ min and ≤ max) | | maxQuantity | number | No | Maximum quantity (must be ≥ reorder) | | status | string | No | Status (default: "Supported") | | abcClass | string | No | ABC classification (A, B, or C) | | expectedLeadTimeDays | integer | No | Expected lead time in days | | replenishmentPeriodDays | integer | No | Replenishment period in days | | forecastPeriodDays | integer | No | Forecast period in days | | forecastQuantity | number | No | Forecast quantity | | preferredBinLocationId | string | No | Preferred bin location | | replenishmentLocationId | string | No | Replenishment source location | | comments | string | No | Additional comments |

Response:

1{
2 "id": "level_123",
3 "productMasterId": "prod_123",
4 "locationId": "loc_123",
5 "minQuantity": 50,
6 "reorderQuantity": 100,
7 "maxQuantity": 500,
8 "status": "Supported",
9 "abcClass": "A",
10 "createdAt": "2024-01-15T10:00:00Z",
11 "updatedAt": "2024-01-15T10:00:00Z",
12 "product": {
13 "id": "prod_123",
14 "sku": "SKU-123",
15 "name": "Product Name"
16 },
17 "productMaster": {
18 "id": "prod_123",
19 "globalSku": "SKU-123",
20 "productName": "Product Name"
21 }
22}

Update Inventory Level

PATCH /api/inventory-levels/{id}

Update inventory level settings.

Request Body:

1{
2 "minQuantity": 75,
3 "reorderQuantity": 150,
4 "maxQuantity": 600,
5 "status": "Supported",
6 "abcClass": "A",
7 "comments": "Updated based on recent demand"
8}

Response:

1{
2 "id": "level_123",
3 "productMasterId": "prod_123",
4 "locationId": "loc_123",
5 "minQuantity": 75,
6 "reorderQuantity": 150,
7 "maxQuantity": 600,
8 "status": "Supported",
9 "abcClass": "A",
10 "updatedAt": "2024-01-15T11:00:00Z"
11}

Delete Inventory Level

DELETE /api/inventory-levels/{id}

Delete an inventory level configuration.

Response:

1{
2 "success": true,
3 "message": "Inventory level deleted"
4}

Example Requests

Create Inventory Level

1curl -X POST "https://app.betterdata.co/api/inventory-levels" \
2 -H "Authorization: Bearer YOUR_API_KEY" \
3 -H "Content-Type: application/json" \
4 -d '{
5 "productMasterId": "prod_123",
6 "locationId": "loc_123",
7 "minQuantity": 50,
8 "reorderQuantity": 100,
9 "maxQuantity": 500
10 }'

Update Inventory Level

1curl -X PATCH "https://app.betterdata.co/api/inventory-levels/level_123" \
2 -H "Authorization: Bearer YOUR_API_KEY" \
3 -H "Content-Type: application/json" \
4 -d '{
5 "reorderQuantity": 150
6 }'

Common Errors

400 Bad Request - Invalid Quantities

1{
2 "error": "Invalid quantities: min ≤ reorder ≤ max required"
3}

Cause: Quantity validation failed (e.g., min > reorder or reorder > max).

Solution: Ensure min ≤ reorder ≤ max.

404 Not Found

1{
2 "error": "Product or location not found"
3}

Cause: Product or location doesn't exist or isn't accessible.

Solution: Verify the product and location IDs are correct and accessible to your organization.



Permissions & Roles

Viewing inventory levels requires standard user permissions. All inventory data is scoped to your organization.