updateProductVariant
Requires permission products:product:update.
Updates a variant. Changing the SKU to one already in use is refused. Changing opening stock, opening stock cost or cost needs the permission to adjust stock. Requires permission to update products.
Errors: a failed call returns a GraphQL errors entry, not a field on the result, and data may be null or partial. Read the entry's extensions.code and message; every shape and code is in the Error reference.
Example:
- GraphQL
- cURL
mutation UpdateProductVariant($id: ID!, $updateProductVariantInput: UpdateProductVariantInput!) {
updateProductVariant(
id: $id
updateProductVariantInput: $updateProductVariantInput
) {
id
QRCode
name
createdAt
attributes
barcode
baseUOM {
id
code
colorCode
name
pluralName
createdAt
}
}
}
curl -X POST "https://<api-host>/graphql" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
--data @- <<'EOF'
{
"query": "mutation UpdateProductVariant($id: ID!, $updateProductVariantInput: UpdateProductVariantInput!) {\n updateProductVariant(\n id: $id\n updateProductVariantInput: $updateProductVariantInput\n ) {\n id\n QRCode\n name\n createdAt\n attributes\n barcode\n baseUOM {\n id\n code\n colorCode\n name\n pluralName\n createdAt\n }\n }\n}",
"variables": {
"id": "id",
"updateProductVariantInput": {}
}
}
EOF
Variables:
{
"id": "id",
"updateProductVariantInput": {}
}
Response:
{
"data": {
"updateProductVariant": {
"id": "id",
"QRCode": "string",
"name": "string",
"createdAt": "2025-01-15T00:00:00Z",
"attributes": {},
"barcode": "string",
"baseUOM": {
"id": "id",
"code": "string",
"colorCode": "string",
"name": "string",
"pluralName": "string",
"createdAt": "2025-01-15T00:00:00Z"
}
}
}
}
updateProductVariant(
id: ID!
updateProductVariantInput: UpdateProductVariantInput!
): ProductVariant!
Arguments
updateProductVariant.id ● ID! non-null scalar
The ID of the variant.
updateProductVariant.updateProductVariantInput ● UpdateProductVariantInput! non-null input
The fields to change on the variant.
Type
ProductVariant object
A sellable version of a product, with its own SKU, price, units of measure and stock.