Skip to main content
⭐️ If you love EverShop, give it a star on GitHub. Thanks!

Product Variant API

Use the REST API to interact with EverShop product variant.

Create a variant group

Use this endpoint to create a variant group.

Request Schema (application/json)
Field NameField TypeRequired
attribute_codesarray of stringYes
attribute_group_idinteger or stringNo
POST/api/variantGroups
curl  -H "Accept: application/json"  -H "Cookie: admin_token=<your jwt token id>"  https://<your domain>/api/variantGroups
Sample Of Response
{  "data": {    "variant_group_id": 8,    "uuid": "99a7b39ca63211edb46b60d819134f39",    "attribute_group_id": 1,    "attribute_one": 4,    "attribute_two": 2,    "attribute_three": 3,    "attribute_four": 5,    "attribute_five": 6  }}

Add variant item

Use this endpoint to add a product to a variant group.

Request Schema (application/json)
Field NameField TypeRequired
product_idstringYes
POST/api/variantGroups/{id}/items
curl  -H "Accept: application/json"  -H "Cookie: admin_token=<your jwt token id>"  https://<your domain>/api/variantGroups/{id}/items
Sample Of Response
{  "data": {    "id": "r57hfgh5656",    "attributes": [      {        "attribute_id": 2,        "attribute_code": "color",        "option_id": 5      },      {        "attribute_id": 3,        "attribute_code": "size",        "option_id": 6      }    ],    "product": {      "product_id": 281,      "uuid": "99a7b39ca63211edb46b60d819134f39",      "variant_group_id": 2,      "visibility": 1,      "group_id": 4,      "image": null,      "sku": "skuUpdated",      "price": 45,      "qty": 123,      "weight": 17,      "manage_stock": 1,      "stock_availability": 1,      "tax_class": null,      "status": 1,      "created_at": "2023-02-07 00:01:46",      "updated_at": "2023-02-07 00:01:46"    }  }}