Por favor, tente com o código abaixo, espero que funcione para você.
criamos um produto simples com o atributo 'cor' e os IDs de produtos simples são 1011.1012 e 1013.
<?php
/********* 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();
}
var_dump($result);
?>