How can I create a new variant with a custom SKU using the 2024-07 API?

In 2024 07 API, there will be a product variant field cleanup.

sku: This field will continue to be returned on the Product Variant model, but is not directly editable. Rather the field will just proxy the sku field from the inventory item.

If the SKU is not directly editable, how can I call the productVariantCreate mutation with a custom SKU in the ProductVariantInput?

I want to create a new variant with a custom SKU. Where is the field moved to?

Hi @jam_chan ,

productVariantCreate has an inventoryItem field that you can set these values in
https://shopify.dev/docs/api/admin-graphql/2024-07/mutations/productvariantcreate

Also mentioned in 2024-04:

1 Like

Does that mean that in the API version 2024-04 there is not way to set variant SKU?

The inventoryItem field is in 2024-04 as well, you do not need to wait for 2024-07.

@RobZone

The inventoryItem field is in 2024-04 but the SKU field is not

https://shopify.dev/docs/api/admin-graphql/2024-04/input-objects/InventoryItemInput

https://shopify.dev/docs/api/admin-graphql/2024-04/mutations/productvariantcreate

1 Like

Yeah as @jam_chan mentioned, it seems that the sku field has been forgotten from inventoryItem field in version 2024-04.

My mistake, I was looking at the wrong graphql object. You will need to use the deprecated sku field on ProductVariantInput for older versions.