Create Products using Rest API : Magento V2.0

Create Products using Rest API : Magento V2.0

August 9, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Create Products using Rest API : Magento V2.0

Creating Products using REST API: Magento Version 2.0

Hello, developers! I’m eager to help you resolve your issue with creating products via the REST API in Magento version 2.0.

Understanding the REST API Endpoint for Product Creation

The first step is to understand the endpoint structure for creating a new product:

http://<your_magento_url>/rest/V1/products

Replace <your_magento_url> with the actual URL of your Magento instance. For example, it would look something like this: http://13.91.208.146/rest/V1/products.

Setting Up the Request Headers

You’ve already set up your headers correctly:

Authorization: Bearer **********************
Content-Type: application/json

The Authorization header should contain a valid access token, and Content-Type should be application/json since we’re sending JSON data.

Formatting the JSON Body for Product Creation

You’ve provided an extensive JSON body with many fields. Let’s break down some key points:

Required Fields

Magento 2 requires certain fields to be present when creating a new product. You missed the root-level field product. Here’s how your JSON should look:

{
    "product": {
        "sku": "10090-White-XL",
        //... other fields ...
    }
}

Hierarchical Structure

Notice that all product attributes are nested within the product key. This hierarchical structure is required by Magento’s REST API.

Nested Configuration Fields

For fields like categories, websites, and attribute sets, they should be provided as nested objects:

"categories": {
    "category_id": 2,
    "position": 0
},
"websites": [
    { "website_id": 1 }
],
"attribute_set_code": "Default"

Resolving the Error

The error message { "message":"%fieldName is a required field.","parameters":{"fieldName":"product"}} indicates that Magento expects a top-level product object containing all product attributes.

With this change, your updated JSON body should look like this:

{
    "product": {
        "sku": "10090-White-XL",
        //... other fields ...
    }
}

Best Practices for Product API Integration

Use Proper Magento Guides

Always refer to the official Magento REST API v2 guide for the most accurate information.

Test in a Development Environment

Before making changes to your production site, always test your API calls in a development or staging environment first.

Handle Errors Gracefully

Implement error handling in your application to capture and handle any errors returned by the Magento API. This includes parsing the JSON response for status codes and error messages.

Conclusion

Creating products via the REST API requires understanding the endpoint structure, setting up proper headers, and formatting the JSON body according to Magento’s hierarchical requirements.

Remember to:

  • Always check for required fields.
  • Use nested objects where necessary (e.g., categories, websites).
  • Test in a safe environment before applying changes to production.
  • Implement robust error handling.

If you have any further questions or need help with other API integrations, feel free to explore more tutorials and guides at Laravel Company. We’re always here to support your development needs!

Magento 2 Catalog API Configuration

Our network