Skip to content

How to create a grouped product with the api in one post?

How can I create a grouped product with the magento api in only one post. I know I can create configurable products in only one post adding the options in the next attributes

"configurable_product_options": [
                {
                    "attribute_id": "663",
                    "label": "co_color_filtro",
                    "values": [
                        {
                            "value_index": 9
                        }
                    ]
                }
            ],
            "configurable_product_links": []

How can I do this with a grouped product? Because the magento tutorial uses differents endpoint for create the product and add the simple items https://developer.adobe.com/commerce/webapi/rest/tutorials/grouped-product/

I tried doing something like this

  "products": [
    {
      "sku": "new-grouped",
      "name": "New Grouped Product",
      "attribute_set_id": 4,
      "type_id": "grouped",
      "visibility": 4,
      "status": 0,
      "extension_attributes": {
        "website_ids": [4],
        "category_links": [
          {
            "position": 0,
            "category_id": "2083"
          }
        ],
        "product_links": [
          {
            "link_type": "associated",
            "linked_product_sku": "009-9031191",
            "linked_product_type": "simple",
            "position": 1,
            "extension_attributes": {
              "qty": 1
            }
          },
          {
            "link_type": "associated",
            "linked_product_sku": "009-9031220",
            "linked_product_type": "simple",
            "position": 2,
            "extension_attributes": {
              "qty": 1
            }
          },
          {
            "link_type": "associated",
            "linked_product_sku": "009-9036452",
            "linked_product_type": "simple",
            "position": 3,
            "extension_attributes": {
              "qty": 1
            }
          }
        ]
      }
    }
  ]
}