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

EndpointReturns
400 Bad RequestItemLocationFilterType 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/policiesThe inventory policy of each SKU-location: order quantities, safety stock, service level, lead time
GET /inventory/service-levelThe 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

FieldMeaning
CalcOrqThe order quantity GAINS calculated
AdjustedOrqThe order quantity after adjustments
MinimumOrq, IncrementalOrqThe minimum order quantity and the increment orders are rounded to
CalcSsThe safety stock GAINS calculated
AdjustedSsThe safety stock after adjustments
SsOverrideA safety stock a user has set in GAINS
Rsq, RsqOverrideThe reserve stock quantity, and a value a user has set in GAINS
ServiceLevel, ServiceLevelMinimumThe target service level and its minimum, as fractions: 0.95 is 95%
InventoryClassThe inventory class, for example A
StockIndicatorS stocked, N non-stock, C cross-dock hub
LeadTimeThe lead time, in weeks
ForecastErrorThe smoothed forecast error (mean absolute deviation)
AvgLTTotalDemandThe 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

ParameterEffectPoliciesService level
ItemCodeThese itemsYesYes
LocationCodeThese locationsYesYes
ItemLocationFilterTypeinclude (default) or exclude: whether ItemCode and LocationCode select or leave outYesYes
InventoryClassThese inventory classesYesYes
StockIndicatorThese stock indicators: S, N or CYesYes
DepartmentThese departmentsYesYes
GroupThese groupsYesYes
PlannerThese plannersYesNo
  • Each list parameter takes a comma-separated list of up to 10 values: Department=10,20.
  • Different parameters combine with AND.
  • exclude leaves out every match of either list. With ItemLocationFilterType=exclude, ItemCode=ASM-7701&LocationCode=DAL02 leaves out item ASM-7701 at every location, and every item at DAL02. It does not leave out only the SKU-location ASM-7701 at DAL02.
  • StockIndicator values are one character each on GET /inventory/policies. A longer value answers 400.

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

StatusCause
401 UnauthorizedThe request carries no valid credentials
403 ForbiddenYour credentials do not grant access to outbound inventory optimization data

See Errors Handling & Exceptions for the error response body.

Related


Did this page help you?