In order to create configurable product I need to create configurable product, virtual product and finally connect them.

Example of json request got from here: How do I create a configurable product using the REST API v2?

I am wondering why do I need this section below in configurable product?


I noticed that this section is required in able to connect virtual product to configurable connect later. But values has no meaning.

In virtual product I can assign any value I want. What is the purpose of this values?


Please try with below code, I hope its work for you.

created a simple product with 'color' attribute and simple product ids are 1011,1012 & 1013.

/********* Create Configurable Product By Rest API *********/
try {
    $url = "http://siteurl.com";
    $apiusername = 'apiusername';
    $apipassword = 'apipassword';
    $userData = array("username" => $apiusername, "password" => $apipassword);

    $ch = curl_init($url."/rest/V1/integration/admin/token");
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($userData));
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "Content-Lenght: " . strlen(json_encode($userData))));

    $token = curl_exec($ch);
    $product_data= '{
                    "product": {
                                "id": 0,
                                "sku": "config_1",
                                "name": "Config Product",
                                "attributeSetId": 4,
                                "price": 20,
                                "status": 1,
                                "visibility": 4,
                                "typeId": "configurable",
                                "createdAt": "string",
                                "updatedAt": "string",
                                "weight": 0.8,
                                "extensionAttributes": {
                                    "stockItem": {
                                        "isInStock": true
                                    "configurableProductLinks": [1011,1012,1013],
                                    "configurableProductOptions": [
                                            "id": 0,
                                            "attributeId": "93",
                                            "label": "Color",
                                            "position": 0,
                                            "isUseDefault": true,
                                                "values": [
                                                        "valueIndex": 11
                                                        "valueIndex": 12
                                                        "valueIndex": 13

     $ch = curl_init($url."/rest/V1/products");
     curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_POSTFIELDS,$product_data);
     curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "Authorization: Bearer " . json_decode($token)));

     $result = curl_exec($ch);
     }catch(Exception $e){

           echo $e->getMessage();

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.