APIEase integrated with Shopify Flow - Cat image inventory
This demo shows how a storefront button triggers APIEase, Shopify Flow, and a chained GraphQL call to adjust inventory based on a cat image’s width.

How the demo works
- A storefront button calls an APIEase proxy endpoint.
- APIEase calls The Cat API to fetch a random image (includes width/height).
- The Cat API response is passed to Shopify Flow via a chained Flow request.
- Flow runs logic to classify the image size (small, medium, large).
- Flow returns the matching location and inventory item to APIEase.
- A final APIEase request calls Shopify GraphQL to increment the correct variant’s inventory.
- The storefront shows success or error after the mutation completes (Shopify inventory updates may take a moment to appear).
APIEase request chain
-
Request #1: The Cat API
- Name:
Flow - Cat Images - Get Cat - Type:
http - Address:
https://api.thecatapi.com/v1/images/search - Method:
GET - Next Request:
Flow - Cat Images - Add Cat - Sample response:
{
"data": [
{
"id": "ced",
"url": "https://cdn2.thecatapi.com/images/ced.jpg",
"width": 720,
"height": 960
}
],
"status": 200
}
The response is forwarded as
previousRequestResponseinto the Flow request. - Name:
-
Request #2: Shopify Flow (APIEase Flow Trigger)
- Name:
Flow - Cat Images - Add Cat - Type:
flow - Next Request:
Flow - Cat Images - Increment Inventory - Incoming Flow parameters:
{
"requestFlowParameters": {},
"previousRequestResponse": {
"0": {
"id": "ced",
"url": "https://cdn2.thecatapi.com/images/ced.jpg",
"width": 720,
"height": 960
}
},
"executionId": "99524b60-0b4d-11f0-8ea0-67506abcdec8"
} - Flow adds
incrementInventoryParameter(location and inventory item) and returns:{
"status": 200,
"data": {
"requestFlowParameters": {},
"previousRequestResponse": {
"0": {
"id": "ced",
"url": "https://cdn2.thecatapi.com/images/ced.jpg",
"width": 720,
"height": 960
}
},
"executionId": "99524b60-0b4d-11f0-8ea0-67506abcdec8",
"incrementInventoryParameter": {
"location": "gid://shopify/Location/80446030117",
"inventoryItemId": "gid://shopify/InventoryItem/52358268420389"
}
}
}
- Name:
This example uses an explicit X-Shopify-Access-Token header for the Shopify Admin API call. For automatic shop access token usage and overrides, see Automatic vs overridden Shopify access tokens.
- Request #3: Shopify GraphQL
- Name:
Flow - Cat Images - Increment Inventory - Type:
http - Address:
https://store-apiease-admin-local.myshopify.com/admin/api/2025-01/graphql.json - Method:
POST - Headers:
X-Shopify-Access-Token:[access-token]Content-Type:application/json
- GraphQL body (uses Flow output for replacements):
{
"query": "mutation inventoryAdjustQuantities($input: InventoryAdjustQuantitiesInput!) { inventoryAdjustQuantities(input: $input) { userErrors { field message } inventoryAdjustmentGroup { createdAt reason changes { name delta } } } }",
"variables": {
"input": {
"reason": "correction",
"name": "available",
"changes": [
{
"delta": 1,
"inventoryItemId": "{incrementInventoryParameter.inventoryItemId}",
"locationId": "{incrementInventoryParameter.location}"
}
]
}
}
}
- Name:
Shopify Flow workflow
- Trigger: apiease-flow-trigger.
- Condition: Confirm the incoming
requestIdmatches the Flow request. - Action: Shopify Get location data to retrieve variants and locations.
- Action: Run Code to classify image size and select the matching inventory item.
- Action: apiease-flow-action to return Flow parameters (including
incrementInventoryParameter) to APIEase.

Run Code inputs
query {
getLocationData {
id
inventoryLevels {
item {
id
sku
variant {
title
sellableOnlineQuantity
}
}
}
}
flowParameters
}
Run Code script
export default function main(input) {
const { getLocationData, flowParameters } = input;
const flowParametersObject = JSON.parse(flowParameters);
const firstImage = flowParametersObject.previousRequestResponse['0'];
const width = firstImage?.width;
if (typeof width !== 'number') {
return { message: 'Image width not found or invalid.', targetSize: null };
}
let targetSize;
if (width < 400) {
targetSize = 'Small';
} else if (width < 800) {
targetSize = 'Medium';
} else {
targetSize = 'Large';
}
if (!Array.isArray(getLocationData) || getLocationData.length === 0) {
return { message: 'No location data found.' };
}
const incrementInventoryParameter = {};
for (const location of getLocationData) {
for (const level of location.inventoryLevels) {
const item = level.item;
const variant = item?.variant;
if (variant?.title === targetSize) {
incrementInventoryParameter.location = location.id;
incrementInventoryParameter.inventoryItemId = item.id;
}
}
}
flowParametersObject.incrementInventoryParameter = incrementInventoryParameter;
const flowParametersStringified = JSON.stringify(flowParametersObject);
return { message: flowParametersStringified };
}
The Run Code step classifies the image size and attaches incrementInventoryParameter so APIEase can substitute those values in the GraphQL mutation.

APIEase Flow Action
