Anchor to inventoryItemUpdateinventory
inventoryItemUpdate
mutation
Requires access scope. Also: The user must have a permission to update an inventory item.
Updates an inventory item.
Anchor to Arguments
Arguments
- •ID!required
The ID of the inventory item to update.
- Anchor to inputinput•Inventory
Item requiredInput!
Was this section helpful?
Anchor to InventoryItemUpdatePayload returnsInventoryItemUpdatePayload returns
- Anchor to inventoryIteminventory•
Item The inventory item that was updated.
- Anchor to userErrorsuser•
Errors [UserError!]! non-null The list of errors that occurred from executing the mutation.
Was this section helpful?
- Updates an existing inventory item
- inventoryItemUpdate reference
Examples
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation inventoryItemUpdate($id: ID!, $input: InventoryItemInput!) {
inventoryItemUpdate(id: $id, input: $input) {
inventoryItem {
id
unitCost {
amount
}
tracked
countryCodeOfOrigin
provinceCodeOfOrigin
harmonizedSystemCode
countryHarmonizedSystemCodes(first: 1) {
edges {
node {
harmonizedSystemCode
countryCode
}
}
}
}
userErrors {
message
mutation inventoryItemUpdate($id: ID!, $input: InventoryItemInput!) {
inventoryItemUpdate(id: $id, input: $input) {
inventoryItem {
id
unitCost {
amount
}
tracked
countryCodeOfOrigin
provinceCodeOfOrigin
harmonizedSystemCode
countryHarmonizedSystemCodes(first: 1) {
edges {
node {
harmonizedSystemCode
countryCode
}
}
}
}
userErrors {
message
}
}
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "mutation inventoryItemUpdate($id: ID!, $input: InventoryItemInput!) { inventoryItemUpdate(id: $id, input: $input) { inventoryItem { id unitCost { amount } tracked countryCodeOfOrigin provinceCodeOfOrigin harmonizedSystemCode countryHarmonizedSystemCodes(first: 1) { edges { node { harmonizedSystemCode countryCode } } } } userErrors { message } } }",
"variables": {
"id": "gid://shopify/InventoryItem/43729076",
"input": {
"cost": 145.89,
"tracked": false,
"countryCodeOfOrigin": "US",
"provinceCodeOfOrigin": "OR",
"harmonizedSystemCode": "621710",
"countryHarmonizedSystemCodes": [
{
"harmonizedSystemCode": "6217109510",
"countryCode": "CA"
}
]
}
}
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
mutation inventoryItemUpdate($id: ID!, $input: InventoryItemInput!) {
inventoryItemUpdate(id: $id, input: $input) {
inventoryItem {
id
unitCost {
amount
}
tracked
countryCodeOfOrigin
provinceCodeOfOrigin
harmonizedSystemCode
countryHarmonizedSystemCodes(first: 1) {
edges {
node {
harmonizedSystemCode
countryCode
}
}
}
}
userErrors {
message
}
}
}`,
{
variables: {
"id": "gid://shopify/InventoryItem/43729076",
"input": {
"cost": 145.89,
"tracked": false,
"countryCodeOfOrigin": "US",
"provinceCodeOfOrigin": "OR",
"harmonizedSystemCode": "621710",
"countryHarmonizedSystemCodes": [
{
"harmonizedSystemCode": "6217109510",
"countryCode": "CA"
}
]
}
},
},
);
const data = await response.json();
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: {
"query": `mutation inventoryItemUpdate($id: ID!, $input: InventoryItemInput!) {
inventoryItemUpdate(id: $id, input: $input) {
inventoryItem {
id
unitCost {
amount
}
tracked
countryCodeOfOrigin
provinceCodeOfOrigin
harmonizedSystemCode
countryHarmonizedSystemCodes(first: 1) {
edges {
node {
harmonizedSystemCode
countryCode
}
}
}
}
userErrors {
message
}
}
}`,
"variables": {
"id": "gid://shopify/InventoryItem/43729076",
"input": {
"cost": 145.89,
"tracked": false,
"countryCodeOfOrigin": "US",
"provinceCodeOfOrigin": "OR",
"harmonizedSystemCode": "621710",
"countryHarmonizedSystemCodes": [
{
"harmonizedSystemCode": "6217109510",
"countryCode": "CA"
}
]
}
},
},
});
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 inventoryItemUpdate($id: ID!, $input: InventoryItemInput!) {
inventoryItemUpdate(id: $id, input: $input) {
inventoryItem {
id
unitCost {
amount
}
tracked
countryCodeOfOrigin
provinceCodeOfOrigin
harmonizedSystemCode
countryHarmonizedSystemCodes(first: 1) {
edges {
node {
harmonizedSystemCode
countryCode
}
}
}
}
userErrors {
message
}
}
}
QUERY
variables = {
"id": "gid://shopify/InventoryItem/43729076",
"input": {
"cost": 145.89,
"tracked": false,
"countryCodeOfOrigin": "US",
"provinceCodeOfOrigin": "OR",
"harmonizedSystemCode": "621710",
"countryHarmonizedSystemCodes": [{"harmonizedSystemCode"=>"6217109510", "countryCode"=>"CA"}]
}
}
response = client.query(query: query, variables: variables)
Input variables
JSON{
"id": "gid://shopify/InventoryItem/43729076",
"input": {
"cost": 145.89,
"tracked": false,
"countryCodeOfOrigin": "US",
"provinceCodeOfOrigin": "OR",
"harmonizedSystemCode": "621710",
"countryHarmonizedSystemCodes": [
{
"harmonizedSystemCode": "6217109510",
"countryCode": "CA"
}
]
}
}
Response
JSON{
"inventoryItemUpdate": {
"inventoryItem": {
"id": "gid://shopify/InventoryItem/43729076",
"unitCost": {
"amount": "145.89"
},
"tracked": false,
"countryCodeOfOrigin": "US",
"provinceCodeOfOrigin": "OR",
"harmonizedSystemCode": "621710",
"countryHarmonizedSystemCodes": {
"edges": [
{
"node": {
"harmonizedSystemCode": "6217109510",
"countryCode": "CA"
}
}
]
}
},
"userErrors": []
}
}