Magento - How to add a configurable product using REST API?

Magento - How to add a configurable product using REST API?

September 20, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento - How to add a configurable product using REST API?

Magento: Creating Configurable Products via REST API

Managing products in your Magento store is crucial for inventory and customer satisfaction. While the documentation extensively covers adding simple products via API, you might find yourself needing to create configurable items like our t-shirt example above.

Understanding Configurable Products

Configurable products allow you to group multiple variations of a base product under one SKU. In our case, let’s say we have a blue t-shirt that comes in sizes S, M, and L. A configurable product would combine all three as options for the customer while keeping inventory management efficient.

Building the Configurable Product Structure

Before diving into the API call, we need to understand what data is required:

  1. Base Product: First, you must create a base product (simple) that will be the parent of your configurable item.

  2. Child Products: Each variation (size in our case) needs its own simple product associated with the base.

  3. Configurable Attributes: Define which attributes are configurable. For t-shirts, this could be size, color, material, etc.

Creating Configurable Products via API

Step 1: Set Up Your API and Access Token

Ensure you have a valid admin token generated from Magento’s admin panel under “System -> Integrations -> Add New Integration”. This token will grant access to our REST API endpoints.

curl -X GET http://<your_magento_url>/rest/V1/integration/admin/token -d '{"username":"admin", "password":"admin123"}'

Step 2: Create Base and Child Products

We’ll create a base product first, then the child variations.

Base Product:

curl -X POST http://<your_magento_url>/rest/V1/products -H "Content-Type: application/json" -d '
{
    "sku": "T001",
    "name": "Blue T-Shirt",
    "description": "A comfortable blue t-shirt.",
    "short_description": "Casual wear in blue."
}'

Child Products (Variations):

curl -X POST http://<your_magento_url>/rest/V1/products -H "Content-Type: application/json" -d '
{
    "sku": "T002S",
    "name": "Blue T-Shirt Size S",
    "description": "A comfortable blue t-shirt in size S.",
    "short_description": "Casual wear in blue, small."
}'

Repeat this for sizes M and L.

Step 3: Create the Configurable Product

Now we’ll combine these as a configurable product. The key is setting the configurable_products field with the IDs of your child products (variations).

curl -X POST http://<your_magento_url>/rest/V1/configurable-products -H "Content-Type: application/json" -d '
{
    "sku": "CONF-T001",
    "name": "Blue T-Shirt Configurable",
    "configurable_products": [
        {"product_id": 42, "variation_sku": "T002S"},
        {"product_id": 43, "variation_sku": "T002M"},
        {"product_id": 44, "variation_sku": "T002L"}
    ]
}'

Replace 42, 43, and 44 with the actual IDs of your child products.

Conclusion

Configurable products are powerful for managing varied items like apparel or accessories. By leveraging Magento’s REST API, you can now create these complex product types directly from external applications like our desktop software.

Remember to thoroughly test your API calls in a staging environment before deploying to production. Also, consider the performance implications of heavy API usage and optimize accordingly.

For more advanced techniques and best practices in Magento development, be sure to visit Laravel Company for insights into scalable architecture and efficient workflows.

Catalog API Admin Configuration

Our network