A variant is a new version of the product. Example: Colors or sizes. If you don’t create a new variant, you will have to treat shirts with 3 colors, yellow, blue, and green, as 3 separate products. Product Variant allows you to treat yellow, blue and green shirts as 3 variations of the same product as a shirt.
Each product has a maximum of 100 variants. For every business running on Shopify, new variants are required. So, today I will show you how to create a new product variant using Postman in Shopify.
Step 1: Generate API credentials from the Shopify admin
- Log in to your Shopify admin
- Go to Apps – Manage private apps
![Shopify API [year] : Create A New Product Variant using Postman 1 Generate API credentials from the Shopify admin](https://www.beehexa.com/wp-content/uploads/2021/11/apps.png)
- Click Create a new private app
- In the App details section, enter a name for your app, and an emergency developer email.
- In the Admin API section, select the areas of your store that you want the app to access
![Shopify API [year] : Create A New Product Variant using Postman 2 Generate API credentials from the Shopify admin](https://www.beehexa.com/wp-content/uploads/2021/11/Read-01-2.png)
- Click Save
The Admin API section displays the app’s API key and password when you save the app’s details.
Step 2: Create A New Product Variant
-
- Log in to your Postman and create a new workspace
-
- Create a new POST with this URL:
https://{username}:{password}@{shop}.myshopify.com/admin/api/{api-version}/{resource}.json
-
- {username} – The API key that you generated.
-
- {password} – The API password that you generated.
-
- {shop} – The name of your development store.
-
- {api-version} – The supported API version that you want to use.
-
- {resource} – A resource endpoint from the REST Admin API.
Or you can copy this example in the Shopify Admin, remember to change {resource} to {products/product ID/variants}:
https://33a72f01e02987636e1c1a9a4e95c840:[email protected]/admin/api/2021-10/products/4356051664959/variants.json
![Shopify API [year] : Create A New Product Variant using Postman 3 Example URL](https://www.beehexa.com/wp-content/uploads/2021/11/example-URL.png)
-
- Paste the URL above.
![Shopify API [year] : Create A New Product Variant using Postman 4 Post](https://www.beehexa.com/wp-content/uploads/2021/11/New-Post.png)
In the body section, enter this code, then click Send.
{
"variant": {
"option1": "Yellow",
"price": "1.00"
}
}
Response:
API will return the data like this.
{
"variant": {
"id": 39525900648511,
"product_id": 4356051664959,
"title": "Yellow",
"price": "1.00",
"sku": "",
"position": 2,
"inventory_policy": "deny",
"compare_at_price": null,
"fulfillment_service": "manual",
"inventory_management": "shopify",
"option1": "Yellow",
"option2": null,
"option3": null,
"created_at": "2021-11-24T11:31:58+09:00",
"updated_at": "2021-11-24T11:31:58+09:00",
"taxable": true,
"barcode": null,
"grams": 0,
"image_id": null,
"weight": 0.0,
"weight_unit": "kg",
"inventory_item_id": 41620530987071,
"inventory_quantity": 0,
"old_inventory_quantity": 0,
"requires_shipping": true,
"admin_graphql_api_id": "gid://shopify/ProductVariant/39525900648511"
}
}
![Shopify API [year] : Create A New Product Variant using Postman 5 Response](https://www.beehexa.com/wp-content/uploads/2021/11/respone-of-request.png)
Step 3: Verify the result
In the admin, choose products, click all products, then search product by product id.
Look at the variant area.
![Shopify API [year] : Create A New Product Variant using Postman 6 Variants area](https://www.beehexa.com/wp-content/uploads/2021/11/variants.png)
As you can see, the new product variant has been created.
I have shown you all steps to create a new product variant using Postman with Shopify API . If you have any questions, please comment below or refer to our Devdocs.
If you still do not understand the tutorial’s content, you can watch the video below for a more overview.
Hopefully, you can do it!