GraphQL API Method to Create Shipping Package and Assign to Product Variants

Hey there,

I’m searching on programmatically setting up shipping packages for products for our merchant (as he got different dimensions for each product in Woocommerce we need to migrate) and need clarification on the current GraphQL API capabilities.

What I’m trying to achieve is to create custom shipping packages (with length, width, height dimensions) and assign them to individual product variants via the GraphQL Admin API.

So far I’ve found, there is a shippingPackageUpdate mutation in the API documentation, but I cannot find a corresponding shippingPackageCreate mutation to create new packages.

The productUpdate and inventoryItemUpdate mutations don’t seem to have fields for assigning shipping packages or setting physical dimensions

Is there a GraphQL mutation to create new shipping packages (not just update existing ones)?
Can shipping packages be assigned to product variant/ product through GraphQL, or is this only possible through the Shopify admin UI?

If this isn’t currently supported in GraphQL, what’s the recommended approach for programmatically managing product shipping dimensions? Any guidance would be greatly appreciated!

Thanks!

Hi @azerm

The Shopify Admin GraphQL API lets you update and delete existing shipping packages, but not create them. There is a shippingPackageUpdate mutation that takes a CustomShippingPackageInput (including dimensions and weight), and a shippingPackageDelete mutation, but there is no shippingPackageCreate mutation exposed in the schema. That means new custom shipping packages must be created in the Shopify admin UI (Settings → Shipping and delivery → Packages), not programmatically via GraphQL.

Once packages exist, you can assign them to products/variants via GraphQL, but this is done through the inventory item, not directly on the product or variant. Each ProductVariant has an associated InventoryItem, and InventoryItemInput includes a measurement field of type InventoryItemMeasurementInput, which contains shippingPackageId and weight. You set these using mutations like inventoryItemUpdate or via product/variant mutations that accept inventoryItem input (e.g. ProductVariantSetInput.inventoryItem).

The practical migration pattern is therefore: (1) define a finite set of shipping packages with dimensions in the Shopify admin, (2) map each WooCommerce product/variant to one of these packages and determine its shipping weight, and (3) programmatically assign measurement.shippingPackageId and measurement.weight on the corresponding InventoryItem via GraphQL. If you need to preserve precise per-product length/width/height beyond what these packages represent, store those raw dimensions in metafields on the product, variant, or inventory item, and let your own app or carrier logic consume them while Shopify uses the selected package + weight for its internal shipping calculations.