Inventory Policies
Retrieve inventory policies and service levels from GAINS with a GET or a webhook.
When GAINS manages your inventory policies, GAINS Connect gives you the current policy of each SKU-location, such as its order quantities, safety stock and service level, so you can apply it in your ERP. This page explains the two inventory endpoints, their filters, and how to receive changed policies by webhook.
Inventory endpoints
| Endpoint | Returns |
|---|---|
400 Bad Request | ItemLocationFilterType is not include or exclude, a filter has more than 10 values, a StockIndicator value is longer than one character (policies only), or Size is not between 1 and 1000 |
GET /inventory/policies | The inventory policy of each SKU-location: order quantities, safety stock, service level, lead time |
GET /inventory/service-level | The same policy with its costs and cost drivers, and the trade-off GAINS evaluated at each service level |
Both return one record per item, with one entry in Locations per SKU-location. The policies endpoint returns DataType inventory_policy, the service level endpoint inventory_service_level. The service level endpoint returns only the SKU-locations for which GAINS has evaluated service levels.
Reading inventory policies
This request reads the policies of stocked SKU-locations in inventory classes A and B:
GET /api/v1/inventory/policies?InventoryClass=A,B&StockIndicator=S{
"DataType": "inventory_policy",
"Data": [
{
"ItemCode": "ASM-7701",
"ItemDescription": "Hub assembly, front",
"Locations": [
{
"LocationCode": "CHI01",
"LocationName": "Chicago DC",
"InventoryPolicy": {
"AdjustedOrq": 120,
"MinimumOrq": 50,
"IncrementalOrq": 10,
"CalcOrq": 118,
"Rsq": 0,
"RsqOverride": 0,
"CalcSs": 34,
"AdjustedSs": 40,
"SsOverride": 0,
"ServiceLevel": 0.95,
"ServiceLevelMinimum": 0.9,
"InventoryClass": "A",
"StockIndicator": "S",
"LeadTime": 2.0,
"ForecastError": 0.18,
"AvgLTTotalDemand": 96
}
}
]
}
],
"Paging": {
"NextCursor": null,
"CurrentDataCount": 1
}
}The endpoints return the current policy of every SKU-location that matches your filters, each time you call them. They do not keep track of what you have already read; to receive only the policies that change, use the webhook.
Size counts SKU-locations; see Pagination. On GET /inventory/policies, results are ordered by ItemCode, then LocationCode, so an item's locations can continue on the next page and the same ItemCode can appear on two consecutive pages.
What a policy contains
| Field | Meaning |
|---|---|
CalcOrq | The order quantity GAINS calculated |
AdjustedOrq | The order quantity after adjustments |
MinimumOrq, IncrementalOrq | The minimum order quantity and the increment orders are rounded to |
CalcSs | The safety stock GAINS calculated |
AdjustedSs | The safety stock after adjustments |
SsOverride | A safety stock a user has set in GAINS |
Rsq, RsqOverride | The reserve stock quantity, and a value a user has set in GAINS |
ServiceLevel, ServiceLevelMinimum | The target service level and its minimum, as fractions: 0.95 is 95% |
InventoryClass | The inventory class, for example A |
StockIndicator | S stocked, N non-stock, C cross-dock hub |
LeadTime | The lead time, in weeks |
ForecastError | The smoothed forecast error (mean absolute deviation) |
AvgLTTotalDemand | The average total demand over the lead time, including dependent demand |
GET /inventory/service-level adds, for each SKU-location, the costs GAINS uses to set the policy, demand and order statistics, the inventory model in use, and a ServiceLevels array. Each entry of ServiceLevels is one service level GAINS evaluated, with the order quantity, safety stock and costs that service level would bring. The reference page lists every field.
Parameters
| Parameter | Effect | Policies | Service level |
|---|---|---|---|
ItemCode | These items | Yes | Yes |
LocationCode | These locations | Yes | Yes |
ItemLocationFilterType | include (default) or exclude: whether ItemCode and LocationCode select or leave out | Yes | Yes |
InventoryClass | These inventory classes | Yes | Yes |
StockIndicator | These stock indicators: S, N or C | Yes | Yes |
Department | These departments | Yes | Yes |
Group | These groups | Yes | Yes |
Planner | These planners | Yes | No |
- Each list parameter takes a comma-separated list of up to 10 values:
Department=10,20. - Different parameters combine with AND.
excludeleaves out every match of either list. WithItemLocationFilterType=exclude,ItemCode=ASM-7701&LocationCode=DAL02leaves out itemASM-7701at every location, and every item atDAL02. It does not leave out only the SKU-locationASM-7701atDAL02.StockIndicatorvalues are one character each onGET /inventory/policies. A longer value answers400.
You can also filter on extended data attributes that your GAINS representative has made available as filters. See Extended Data - Outbound.
Receiving changed policies by webhook
The InventoryPolicyUpdate trigger sends a SKU-location's policy when GAINS detects that it has changed. A delivery has the same structure as GET /inventory/policies, without Paging. Each location also carries EventOccurredAt, the time GAINS calculated the policy, which the endpoint does not return.
The trigger can take a filter, for example InventoryClass IN ('A', 'B'), so that GAINS sends only the policies you need. See Webhooks for setting up destinations and filters, and Webhook Payload Samples for the attributes GAINS watches for a change and a sample payload.
A common pattern is to read every policy once from the endpoint, then keep them up to date from the webhook. There is no webhook for service levels.
Extended data
Policies and service levels can carry extended data on the item and on each location, configured separately for each endpoint. The webhook carries the same extended data as GET /inventory/policies. See Extended Data - Outbound.
Errors
| Status | Cause |
|---|---|
401 Unauthorized | The request carries no valid credentials |
403 Forbidden | Your credentials do not grant access to outbound inventory optimization data |
See Errors Handling & Exceptions for the error response body.
Related
Updated 10 days ago
