Get inventory item data
In workflows that require inventory item data, you can use the Get inventory item data action to retrieve inventory item information from your store. Inventory items represent the actual stock units that are tracked for product variants.
On this page
Configuration
Fields
The Get inventory item data action contains the following fields:
| Field | Description |
|---|---|
| Sort data by | Required. The parameters by which the data returned by the search query is sorted. |
| Maximum number of results | Required. The maximum amount of results that can be returned by the search query that you select. You can return up to 100 at a time. |
| Query | Required. Choose from common queries or select Advanced to create your own. |
Query string
This is an example query for getting inventory items that are tracked:
tracked:trueThe tracked variable is a filter available on the Inventory items query and can be used multiple times or combined with other variables.
When querying data, it's helpful to know:
Queries must follow a certain syntax
Query field values are not always documented. In some cases, the values can be found by looking at the API docs. Alternatively, you can often find the field values in the URLs in the Admin when you filter. For example, to find some Order query values, filter the Orders page in the Admin, and then check the URL.
You can run or test a query in your shop by using the Shopify GraphiQL app.
Be mindful of what happens if your query fails. Often the API will return all results (instead of none).
Returned data
All Get data actions return a list of anywhere from 0 and 100 resources. Depending your use case, you might want to use this data in various ways:
- If you need to handle each list item individually, such as to add a tag for each, then you can use the For each action.
- If you need to aggregate data, such as count how many results were returned, then you can use the Count or Sum actions.
- If you need output the list, such as send an email with all the items, then you can use returned data directly in susbsequent actions.
To access the returned data in steps that follow this action, use the variable named Get inventory item data, which is a list of inventory items. You can use this variable in both conditions and actions. For example, you can send the list of inventory items in a Send internal email action similar to this:
{% for single_inventory_item in getInventoryItemData %}
* SKU: {{ single_inventory_item.sku }} - Cost: {{ single_inventory_item.unitCost.amount }}
{% endfor %}Triggers
You can use this action in any workflow, including the Scheduled time trigger. In a workflow that uses the Scheduled time trigger, the workflow starts at a time that you've specified, rather than as a result of an event. Because there is no specific event in your store or from an app that starts the workflow, there is no data automatically included.
API Reference
For more information about the API used in this action, see the Inventory items query.