A Shopify API mock for testing inventory updates.
Your agent reads seeded products and warehouse stock through GraphQL, then adjusts inventory. Query the inventory level again to check the quantity at the chosen location.
inventory_adjustedCalls the inventoryAdjustQuantities mutation
Starting records
locations
- ref
oakland- name
Oakland warehouse
products
- ref
gateway- title
Acme Edge Gateway- vendor
Acme
Connect your agent to the Shopify mock
When ancha runs your agent, it sets:
SHOPIFY_API_URLSHOPIFY_ACCESS_TOKENSHOPIFY_API_VERSIONSHOPIFY_STOREFRONT_ACCESS_TOKENSHOPIFY_API_SECRET
Point the client you already use at them.
import { createAdminApiClient } from '@shopify/admin-api-client';
const shopify = createAdminApiClient({ storeDomain: 'acme-store.myshopify.com', apiVersion: process.env.SHOPIFY_API_VERSION!, accessToken: process.env.SHOPIFY_ACCESS_TOKEN!,
customFetchApi: (url, init) => fetch(String(url).replace(/^https:\/\/[^/]+/, process.env.SHOPIFY_API_URL!), init) });
const { data, errors } = await shopify.request('{ orders(first: 10) { nodes { id name } } }');
import { createGraphQLClient } from '@shopify/graphql-client';
const storefront = createGraphQLClient({
url: process.env.SHOPIFY_API_URL! + '/api/' + process.env.SHOPIFY_API_VERSION! + '/graphql.json',
headers: { 'X-Shopify-Storefront-Access-Token': process.env.SHOPIFY_STOREFRONT_ACCESS_TOKEN! },
});
const catalog = await storefront.request('{ products(first: 10) { nodes { id title variants(first: 10) { nodes { id price { amount currencyCode } } } } } }');
// Verify order webhooks with process.env.SHOPIFY_API_SECRET and the raw request body.Locally, ancha runs your agent as an ordinary process, so keep real Shopify credentials out of its environment.
See all 47 endpoints
cart
cartcartAttributesUpdate
cartAttributesUpdatecartBuyerIdentityUpdate
cartBuyerIdentityUpdatecartCreate
cartCreatecartLinesAdd
cartLinesAddcartLinesRemove
cartLinesRemovecartLinesUpdate
cartLinesUpdatecartNoteUpdate
cartNoteUpdatecollection
collectioncollections
collectionscustomer
customercustomerCreate
customerCreatecustomers
customerscustomerUpdate
customerUpdatefulfillmentCreate
fulfillmentCreatefulfillmentOrder
fulfillmentOrderfulfillmentTrackingInfoUpdate
fulfillmentTrackingInfoUpdateinventoryAdjustQuantities
inventoryAdjustQuantitiesinventoryItem
inventoryIteminventorySetQuantities
inventorySetQuantitiesjob
joblocation
locationlocations
locationsnode
nodenodenodes
nodesnodesorder
orderorderCancel
orderCancelorderClose
orderCloseorderMarkAsPaid
orderMarkAsPaidorderOpen
orderOpenorders
ordersorderUpdate
orderUpdateproduct
productproductproducts
productsproductsproductUpdate
productUpdateproductVariant
productVariantproductVariants
productVariantsproductVariantsBulkUpdate
productVariantsBulkUpdaterefundCreate
refundCreateshop
shopshoptagsAdd
tagsAddtagsRemove
tagsRemoveSeed your own data
The data the Shopify mock starts with on every run, cut to a few records. ancha twins seed shopify prints every field.
Full seed YAML
twins:
- shopify
seed:
shopify:
shop:
name: Acme Store
domain: acme-store
email: store@acme.example
owner: Ben Carter
created: -9000h
locations:
- ref: oakland
name: Oakland warehouse
address:
address1: 1200 Embarcadero
city: Oakland
province_code: CA
zip: "94606"
phone: "+15105550142"
created: -9000h
products:
- ref: gateway
title: Acme Edge Gateway
vendor: Acme
product_type: Hardware
tags:
- gateway
created: -6000h
description_html: <p>Connects warehouse sensors to Acme over Ethernet or LTE. Includes a power supply and a one-year warranty.</p>
options:
- Connectivity
variants:
- ref: gateway_eth
options:
- Ethernet
sku: AEG-ETH
barcode: "0850041200016"
price: "349.00"
cost: "182.00"
inventory:
oakland: 31
customers:
- ref: grace
first_name: Grace
last_name: Lin
email: grace.lin@bluefield-logistics.example
tags:
- b2b
state: ENABLED
created: -500h
address:
company: Bluefield Logistics
address1: 800 Harbor Way
city: Columbus
province_code: OH
zip: "43215"
orders:
- ref: order_bluefield
customer: grace
created: -400h
line_items:
- variant: gateway_eth
quantity: 2
shipping:
title: UPS Ground
price: "15.00"
tags:
- b2b
fulfillments:
- at: -390h
tracking:
company: UPS
number: 1Z4A81W90312345671
url: https://www.ups.com/track?tracknum=1Z4A81W90312345671
delivered: -340h
Check what your agent did
Checks YAML
checks:
- id: inventory_adjusted
trace:
called: MUTATION inventoryAdjustQuantitiesTested together
All 43 toolsShopify API mock FAQ
How do I check which Shopify warehouse an agent changed?
In the mock, inventoryAdjustQuantities applies each delta to the specified inventoryItemId and locationId. Read the item’s inventoryLevel(locationId:) and quantities(names: ["available"]) to inspect stock at that location.
What happens when an inventory agent acts on an old Shopify stock count?
Pass the expected stock count as changeFromQuantity in the mock’s inventorySetQuantities mutation. If it differs from the current quantity, userErrors contains CHANGE_FROM_QUANTITY_STALE and the mutation leaves inventory unchanged.
How can a Shopify inventory adjustment be retried without applying its delta twice?
Use the same @idempotent(key:) value and arguments when retrying inventoryAdjustQuantities. The mock returns the existing adjustment group; reusing the key with different arguments produces IDEMPOTENCY_KEY_PARAMETER_MISMATCH in userErrors.
Install the CLI and run your agent against the Shopify mock.
Ancha is not affiliated with Shopify.