Create an inventory count
Description
Create an inventory count at a location. Each line item identifies an inventory item
to count in the location's default bin, optionally with a counted `quantity`: the
`actualQuantity` counted and the `expectedQuantity` on-hand baseline the count is
measured against (the count is rejected if the live on-hand no longer matches it).
This mutation is part of the [physical inventory feature preview](https://shopify.dev/changelog/physical-inventory-feature-preview).
Query
mutation InventoryCountCreate($locationId: ID!, $lineItems: [InventoryCountLineItemInput!], $idempotencyKey: String!) {
inventoryCountCreate(locationId: $locationId, lineItems: $lineItems) @idempotent(key: $idempotencyKey) {
inventoryCount {
id
createdAt
locationSnapshot {
name
snapshottedAt
address {
address1
address2
city
province
provinceCode
country
countryCode
zip
phone
latitude
longitude
}
location {
id
name
}
}
lineItems(first: 10) {
nodes {
id
inventoryItem {
id
}
productTitle
variantTitle
sku
expectedQuantity
totalCountedQuantity
variance
}
}
}
userErrors {
field
message
code
}
}
}
Variables
{
"locationId": "gid://shopify/Location/346779380",
"lineItems": [
{
"inventoryItemId": "gid://shopify/InventoryItem/30322695",
"quantity": {
"actualQuantity": 10,
"expectedQuantity": 10
}
}
],
"idempotencyKey": "c8dab397-7dc7-401c-89ef-a8286535d50f"
}
cURL
curl -X POST \
https://your-development-store.myshopify.com/admin/api/unstable/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "mutation InventoryCountCreate($locationId: ID!, $lineItems: [InventoryCountLineItemInput!], $idempotencyKey: String!) { inventoryCountCreate(locationId: $locationId, lineItems: $lineItems) @idempotent(key: $idempotencyKey) { inventoryCount { id createdAt locationSnapshot { name snapshottedAt address { address1 address2 city province provinceCode country countryCode zip phone latitude longitude } location { id name } } lineItems(first: 10) { nodes { id inventoryItem { id } productTitle variantTitle sku expectedQuantity totalCountedQuantity variance } } } userErrors { field message code } } }",
"variables": {
"locationId": "gid://shopify/Location/346779380",
"lineItems": [
{
"inventoryItemId": "gid://shopify/InventoryItem/30322695",
"quantity": {
"actualQuantity": 10,
"expectedQuantity": 10
}
}
],
"idempotencyKey": "c8dab397-7dc7-401c-89ef-a8286535d50f"
}
}'
React Router
import { authenticate } from "../shopify.server";
export const loader = async ({request}) => {
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation InventoryCountCreate($locationId: ID!, $lineItems: [InventoryCountLineItemInput!], $idempotencyKey: String!) {
inventoryCountCreate(locationId: $locationId, lineItems: $lineItems) @idempotent(key: $idempotencyKey) {
inventoryCount {
id
createdAt
locationSnapshot {
name
snapshottedAt
address {
address1
address2
city
province
provinceCode
country
countryCode
zip
phone
latitude
longitude
}
location {
id
name
}
}
lineItems(first: 10) {
nodes {
id
inventoryItem {
id
}
productTitle
variantTitle
sku
expectedQuantity
totalCountedQuantity
variance
}
}
}
userErrors {
field
message
code
}
}
}`,
{
variables: {
"locationId": "gid://shopify/Location/346779380",
"lineItems": [
{
"inventoryItemId": "gid://shopify/InventoryItem/30322695",
"quantity": {
"actualQuantity": 10,
"expectedQuantity": 10
}
}
],
"idempotencyKey": "c8dab397-7dc7-401c-89ef-a8286535d50f"
},
},
);
const json = await response.json();
return json.data;
}
Ruby
session = ShopifyAPI::Auth::Session.new(
shop: "your-development-store.myshopify.com",
access_token: access_token
)
client = ShopifyAPI::Clients::Graphql::Admin.new(
session: session
)
query = <<~QUERY
mutation InventoryCountCreate($locationId: ID!, $lineItems: [InventoryCountLineItemInput!], $idempotencyKey: String!) {
inventoryCountCreate(locationId: $locationId, lineItems: $lineItems) @idempotent(key: $idempotencyKey) {
inventoryCount {
id
createdAt
locationSnapshot {
name
snapshottedAt
address {
address1
address2
city
province
provinceCode
country
countryCode
zip
phone
latitude
longitude
}
location {
id
name
}
}
lineItems(first: 10) {
nodes {
id
inventoryItem {
id
}
productTitle
variantTitle
sku
expectedQuantity
totalCountedQuantity
variance
}
}
}
userErrors {
field
message
code
}
}
}
QUERY
variables = {
"locationId": "gid://shopify/Location/346779380",
"lineItems": [
{
"inventoryItemId": "gid://shopify/InventoryItem/30322695",
"quantity": {
"actualQuantity": 10,
"expectedQuantity": 10
}
}
],
"idempotencyKey": "c8dab397-7dc7-401c-89ef-a8286535d50f"
}
response = client.query(query: query, variables: variables)
Node.js
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `mutation InventoryCountCreate($locationId: ID!, $lineItems: [InventoryCountLineItemInput!], $idempotencyKey: String!) {
inventoryCountCreate(locationId: $locationId, lineItems: $lineItems) @idempotent(key: $idempotencyKey) {
inventoryCount {
id
createdAt
locationSnapshot {
name
snapshottedAt
address {
address1
address2
city
province
provinceCode
country
countryCode
zip
phone
latitude
longitude
}
location {
id
name
}
}
lineItems(first: 10) {
nodes {
id
inventoryItem {
id
}
productTitle
variantTitle
sku
expectedQuantity
totalCountedQuantity
variance
}
}
}
userErrors {
field
message
code
}
}
}`,
"variables": {
"locationId": "gid://shopify/Location/346779380",
"lineItems": [
{
"inventoryItemId": "gid://shopify/InventoryItem/30322695",
"quantity": {
"actualQuantity": 10,
"expectedQuantity": 10
}
}
],
"idempotencyKey": "c8dab397-7dc7-401c-89ef-a8286535d50f"
},
},
});
Shopify CLI
shopify app execute \
--query \
'mutation InventoryCountCreate($locationId: ID!, $lineItems: [InventoryCountLineItemInput!], $idempotencyKey: String!) {
inventoryCountCreate(locationId: $locationId, lineItems: $lineItems) @idempotent(key: $idempotencyKey) {
inventoryCount {
id
createdAt
locationSnapshot {
name
snapshottedAt
address {
address1
address2
city
province
provinceCode
country
countryCode
zip
phone
latitude
longitude
}
location {
id
name
}
}
lineItems(first: 10) {
nodes {
id
inventoryItem {
id
}
productTitle
variantTitle
sku
expectedQuantity
totalCountedQuantity
variance
}
}
}
userErrors {
field
message
code
}
}
}' \
--variables \
'{
"locationId": "gid://shopify/Location/346779380",
"lineItems": [
{
"inventoryItemId": "gid://shopify/InventoryItem/30322695",
"quantity": {
"actualQuantity": 10,
"expectedQuantity": 10
}
}
],
"idempotencyKey": "c8dab397-7dc7-401c-89ef-a8286535d50f"
}'
Direct API Access
const response = await fetch('shopify:admin/api/unstable/graphql.json', {
method: 'POST',
body: JSON.stringify({
query: `
mutation InventoryCountCreate($locationId: ID!, $lineItems: [InventoryCountLineItemInput!], $idempotencyKey: String!) {
inventoryCountCreate(locationId: $locationId, lineItems: $lineItems) @idempotent(key: $idempotencyKey) {
inventoryCount {
id
createdAt
locationSnapshot {
name
snapshottedAt
address {
address1
address2
city
province
provinceCode
country
countryCode
zip
phone
latitude
longitude
}
location {
id
name
}
}
lineItems(first: 10) {
nodes {
id
inventoryItem {
id
}
productTitle
variantTitle
sku
expectedQuantity
totalCountedQuantity
variance
}
}
}
userErrors {
field
message
code
}
}
}
`,
variables: {
"locationId": "gid://shopify/Location/346779380",
"lineItems": [
{
"inventoryItemId": "gid://shopify/InventoryItem/30322695",
"quantity": {
"actualQuantity": 10,
"expectedQuantity": 10
}
}
],
"idempotencyKey": "c8dab397-7dc7-401c-89ef-a8286535d50f"
},
}),
});
const { data } = await response.json();
console.log(data);
Response
{
"inventoryCountCreate": {
"inventoryCount": {
"id": "gid://shopify/InventoryCount/1005435490",
"createdAt": "2026-07-17T20:17:12Z",
"locationSnapshot": {
"name": "Ottawa Store",
"snapshottedAt": "2026-07-17T20:14:52Z",
"address": {
"address1": "126 york street",
"address2": "second and third floor",
"city": "ottawa",
"province": "ontario",
"provinceCode": null,
"country": "CA",
"countryCode": null,
"zip": "k1n5t5",
"phone": "613-596-1486",
"latitude": 45.42891,
"longitude": -75.68966
},
"location": {
"id": "gid://shopify/Location/346779380",
"name": "Ottawa Store"
}
},
"lineItems": {
"nodes": [
{
"id": "gid://shopify/InventoryCountLineItem/1052652494",
"inventoryItem": {
"id": "gid://shopify/InventoryItem/30322695"
},
"productTitle": "Element",
"variantTitle": "151cm",
"sku": "element-151",
"expectedQuantity": 10,
"totalCountedQuantity": 10,
"variance": 0
}
]
}
},
"userErrors": []
}
}
Create an inventory count for items in a specific bin
Description
Create an inventory count for items held in a specific bin. Each line item identifies
an inventory item and the `inventoryBinId` of the bin being counted, optionally with a
counted `quantity`: the `actualQuantity` counted and the `expectedQuantity` on-hand
baseline the count is measured against (the count is rejected if the live on-hand no
longer matches it). This mutation is part of the
[physical inventory feature preview](https://shopify.dev/changelog/physical-inventory-feature-preview).
Query
mutation InventoryCountCreate($locationId: ID!, $lineItems: [InventoryCountLineItemInput!], $idempotencyKey: String!) {
inventoryCountCreate(locationId: $locationId, lineItems: $lineItems) @idempotent(key: $idempotencyKey) {
inventoryCount {
id
createdAt
locationSnapshot {
name
snapshottedAt
address {
address1
address2
city
province
provinceCode
country
countryCode
zip
phone
latitude
longitude
}
location {
id
name
}
}
lineItems(first: 10) {
nodes {
id
inventoryItem {
id
}
productTitle
variantTitle
sku
expectedQuantity
totalCountedQuantity
variance
}
}
}
userErrors {
field
message
code
}
}
}
Variables
{
"locationId": "gid://shopify/Location/275072021",
"lineItems": [
{
"inventoryItemId": "gid://shopify/InventoryItem/30322695",
"inventoryBinId": "gid://shopify/InventoryBin/482067856",
"quantity": {
"actualQuantity": 10,
"expectedQuantity": 10
}
}
],
"idempotencyKey": "028375af-da69-4114-bf80-bba496cf11df"
}
cURL
curl -X POST \
https://your-development-store.myshopify.com/admin/api/unstable/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "mutation InventoryCountCreate($locationId: ID!, $lineItems: [InventoryCountLineItemInput!], $idempotencyKey: String!) { inventoryCountCreate(locationId: $locationId, lineItems: $lineItems) @idempotent(key: $idempotencyKey) { inventoryCount { id createdAt locationSnapshot { name snapshottedAt address { address1 address2 city province provinceCode country countryCode zip phone latitude longitude } location { id name } } lineItems(first: 10) { nodes { id inventoryItem { id } productTitle variantTitle sku expectedQuantity totalCountedQuantity variance } } } userErrors { field message code } } }",
"variables": {
"locationId": "gid://shopify/Location/275072021",
"lineItems": [
{
"inventoryItemId": "gid://shopify/InventoryItem/30322695",
"inventoryBinId": "gid://shopify/InventoryBin/482067856",
"quantity": {
"actualQuantity": 10,
"expectedQuantity": 10
}
}
],
"idempotencyKey": "028375af-da69-4114-bf80-bba496cf11df"
}
}'
React Router
import { authenticate } from "../shopify.server";
export const loader = async ({request}) => {
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation InventoryCountCreate($locationId: ID!, $lineItems: [InventoryCountLineItemInput!], $idempotencyKey: String!) {
inventoryCountCreate(locationId: $locationId, lineItems: $lineItems) @idempotent(key: $idempotencyKey) {
inventoryCount {
id
createdAt
locationSnapshot {
name
snapshottedAt
address {
address1
address2
city
province
provinceCode
country
countryCode
zip
phone
latitude
longitude
}
location {
id
name
}
}
lineItems(first: 10) {
nodes {
id
inventoryItem {
id
}
productTitle
variantTitle
sku
expectedQuantity
totalCountedQuantity
variance
}
}
}
userErrors {
field
message
code
}
}
}`,
{
variables: {
"locationId": "gid://shopify/Location/275072021",
"lineItems": [
{
"inventoryItemId": "gid://shopify/InventoryItem/30322695",
"inventoryBinId": "gid://shopify/InventoryBin/482067856",
"quantity": {
"actualQuantity": 10,
"expectedQuantity": 10
}
}
],
"idempotencyKey": "028375af-da69-4114-bf80-bba496cf11df"
},
},
);
const json = await response.json();
return json.data;
}
Ruby
session = ShopifyAPI::Auth::Session.new(
shop: "your-development-store.myshopify.com",
access_token: access_token
)
client = ShopifyAPI::Clients::Graphql::Admin.new(
session: session
)
query = <<~QUERY
mutation InventoryCountCreate($locationId: ID!, $lineItems: [InventoryCountLineItemInput!], $idempotencyKey: String!) {
inventoryCountCreate(locationId: $locationId, lineItems: $lineItems) @idempotent(key: $idempotencyKey) {
inventoryCount {
id
createdAt
locationSnapshot {
name
snapshottedAt
address {
address1
address2
city
province
provinceCode
country
countryCode
zip
phone
latitude
longitude
}
location {
id
name
}
}
lineItems(first: 10) {
nodes {
id
inventoryItem {
id
}
productTitle
variantTitle
sku
expectedQuantity
totalCountedQuantity
variance
}
}
}
userErrors {
field
message
code
}
}
}
QUERY
variables = {
"locationId": "gid://shopify/Location/275072021",
"lineItems": [
{
"inventoryItemId": "gid://shopify/InventoryItem/30322695",
"inventoryBinId": "gid://shopify/InventoryBin/482067856",
"quantity": {
"actualQuantity": 10,
"expectedQuantity": 10
}
}
],
"idempotencyKey": "028375af-da69-4114-bf80-bba496cf11df"
}
response = client.query(query: query, variables: variables)
Node.js
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `mutation InventoryCountCreate($locationId: ID!, $lineItems: [InventoryCountLineItemInput!], $idempotencyKey: String!) {
inventoryCountCreate(locationId: $locationId, lineItems: $lineItems) @idempotent(key: $idempotencyKey) {
inventoryCount {
id
createdAt
locationSnapshot {
name
snapshottedAt
address {
address1
address2
city
province
provinceCode
country
countryCode
zip
phone
latitude
longitude
}
location {
id
name
}
}
lineItems(first: 10) {
nodes {
id
inventoryItem {
id
}
productTitle
variantTitle
sku
expectedQuantity
totalCountedQuantity
variance
}
}
}
userErrors {
field
message
code
}
}
}`,
"variables": {
"locationId": "gid://shopify/Location/275072021",
"lineItems": [
{
"inventoryItemId": "gid://shopify/InventoryItem/30322695",
"inventoryBinId": "gid://shopify/InventoryBin/482067856",
"quantity": {
"actualQuantity": 10,
"expectedQuantity": 10
}
}
],
"idempotencyKey": "028375af-da69-4114-bf80-bba496cf11df"
},
},
});
Shopify CLI
shopify app execute \
--query \
'mutation InventoryCountCreate($locationId: ID!, $lineItems: [InventoryCountLineItemInput!], $idempotencyKey: String!) {
inventoryCountCreate(locationId: $locationId, lineItems: $lineItems) @idempotent(key: $idempotencyKey) {
inventoryCount {
id
createdAt
locationSnapshot {
name
snapshottedAt
address {
address1
address2
city
province
provinceCode
country
countryCode
zip
phone
latitude
longitude
}
location {
id
name
}
}
lineItems(first: 10) {
nodes {
id
inventoryItem {
id
}
productTitle
variantTitle
sku
expectedQuantity
totalCountedQuantity
variance
}
}
}
userErrors {
field
message
code
}
}
}' \
--variables \
'{
"locationId": "gid://shopify/Location/275072021",
"lineItems": [
{
"inventoryItemId": "gid://shopify/InventoryItem/30322695",
"inventoryBinId": "gid://shopify/InventoryBin/482067856",
"quantity": {
"actualQuantity": 10,
"expectedQuantity": 10
}
}
],
"idempotencyKey": "028375af-da69-4114-bf80-bba496cf11df"
}'
Direct API Access
const response = await fetch('shopify:admin/api/unstable/graphql.json', {
method: 'POST',
body: JSON.stringify({
query: `
mutation InventoryCountCreate($locationId: ID!, $lineItems: [InventoryCountLineItemInput!], $idempotencyKey: String!) {
inventoryCountCreate(locationId: $locationId, lineItems: $lineItems) @idempotent(key: $idempotencyKey) {
inventoryCount {
id
createdAt
locationSnapshot {
name
snapshottedAt
address {
address1
address2
city
province
provinceCode
country
countryCode
zip
phone
latitude
longitude
}
location {
id
name
}
}
lineItems(first: 10) {
nodes {
id
inventoryItem {
id
}
productTitle
variantTitle
sku
expectedQuantity
totalCountedQuantity
variance
}
}
}
userErrors {
field
message
code
}
}
}
`,
variables: {
"locationId": "gid://shopify/Location/275072021",
"lineItems": [
{
"inventoryItemId": "gid://shopify/InventoryItem/30322695",
"inventoryBinId": "gid://shopify/InventoryBin/482067856",
"quantity": {
"actualQuantity": 10,
"expectedQuantity": 10
}
}
],
"idempotencyKey": "028375af-da69-4114-bf80-bba496cf11df"
},
}),
});
const { data } = await response.json();
console.log(data);
Response
{
"inventoryCountCreate": {
"inventoryCount": {
"id": "gid://shopify/InventoryCount/1005435491",
"createdAt": "2026-07-17T20:17:12Z",
"locationSnapshot": {
"name": "I Have Sub Locations",
"snapshottedAt": "2026-07-17T20:17:12Z",
"address": {
"address1": null,
"address2": null,
"city": null,
"province": null,
"provinceCode": null,
"country": "CA",
"countryCode": null,
"zip": null,
"phone": null,
"latitude": null,
"longitude": null
},
"location": {
"id": "gid://shopify/Location/275072021",
"name": "I Have Sub Locations"
}
},
"lineItems": {
"nodes": [
{
"id": "gid://shopify/InventoryCountLineItem/1052652495",
"inventoryItem": {
"id": "gid://shopify/InventoryItem/30322695"
},
"productTitle": "Element",
"variantTitle": "151cm",
"sku": "element-151",
"expectedQuantity": 10,
"totalCountedQuantity": 10,
"variance": 0
}
]
}
},
"userErrors": []
}
}