There is an official Magento document that can walk you through the creation step-by-step located here: https://devdocs.magento.com/guides/v2.3/rest/tutorials/configurable-product/config-product-intro.html
I think that would be the most helpful thing for you, but there are some principles from that document that can be summarized here!
The basic idea is that you first want to make the configurable product, or the parent. Here is their example:
POST <host>/rest/default/V1/products
{
"product": {
"sku": "MS-Champ",
"name": "Champ Tee",
"attribute_set_id": 9,
"status": 1,
"visibility": 4,
"type_id": "configurable",
"weight": "0.5",
"extension_attributes": {
"category_links": [
{
"position": 0,
"category_id": "11"
},
{
"position": 1,
"category_id": "12"
},
{
"position": 2,
"category_id": "16"
}
]
},
"custom_attributes": [
{
"attribute_code": "description",
"value": "The Champ Tee keeps you cool and dry while you do your thing. Let everyone know who you are by adding your name on the back for only $10."
},
{
"attribute_code": "tax_class_id",
"value": "2"
},
{
"attribute_code": "material",
"value": "148"
},
{
"attribute_code": "pattern",
"value": "196"
},
{
"attribute_code": "color",
"value": "52"
}
]
}
}
Then, you create the individual children, or simple products. Make sure to give them the appropriate attribute values, such as distinct colors and sizes. There will need to be one simple product for every combination. Small and green, large and red, small and red, etc. Note that visibility 1 makes it so the product cannot be browsed individually, which is generally the desired effect for configurable children products.
POST <host>/rest/default/V1/products
{
"product": {
"sku": "MS-Champ-S",
"name": "Champ Tee Small",
"attribute_set_id": 9,
"price": 25,
"status": 1,
"visibility": 1,
"type_id": "simple",
"weight": "0.5",
"extension_attributes": {
"category_links": [
{
"position": 0,
"category_id": "11"
},
{
"position": 1,
"category_id": "12"
},
{
"position": 2,
"category_id": "16"
}
],
"stock_item": {
"qty": "10",
"is_in_stock": true
}
},
"custom_attributes": [
{
"attribute_code": "description",
"value": "The Champ Tee keeps you cool and dry while you do your thing. Let everyone know who you are by adding your name on the back for only $10."
},
{
"attribute_code": "tax_class_id",
"value": "2"
},
{
"attribute_code": "material",
"value": "148"
},
{
"attribute_code": "pattern",
"value": "196"
},
{
"attribute_code": "color",
"value": "52"
},
{
"attribute_code": "size",
"value": "168"
}
]
}
}
You can use this example and then define the other options by tweaking the relevant attributes (color, size, etc). Then you create the options for the configurable product, or parent, itself.
POST <host>/rest/default/V1/configurable-products/MS-Champ/options
{
"option": {
"attribute_id": "141",
"label": "Size",
"position": 0,
"is_use_default": true,
"values": [
{
"value_index": 9
}
]
}
}
Then finally, place the simple products into place after the options have been created for them.
POST <host>/rest/default/V1/configurable-products/MS-Champ/child
{
"childSku": "MS-Champ-S"
}
Good luck!
edit:
- As for creating attribute values I would refer to this question: Create product attribute with options in magento2 through rest API
- Yes, value_index is the attribute_set_id.
- attribute_id 141 in this example is size. You can use the following to pull attribute ids, this information is in the "Step 1 Plan your product" section of the link.
Get attribute sets.
GET <host>/rest/<store_code>/V1/eav/attribute-sets/list?
searchCriteria[filter_groups][0][filters][0][field]=attribute_set_name&
searchCriteria[filter_groups][0][filters][0][value]=Top&
searchCriteria[filter_groups][0][filters][0][condition_type]=eq
Get attributes by set.
GET <host>/rest/default/V1/products/attribute-sets/9/attributes
Get catalog categories.
GET <host>/rest/default/V1/categories?
searchCriteria[filter_groups][0][filters][0][field]=id&
searchCriteria[filter_groups][0][filters][0][value]=1&
searchCriteria[filter_groups][0][filters][0][condition_type]=gte
And this link should help you to get the actual values/options for the attributes by the attribute_code. Magento 2 rest api get product's attributes options