🔥 Just Launched! Werra Premium Template for HyväSee it in Action

How to Create & Update Product Using REST API in Magento 2

By Sanjay JethvaUpdated on May 22, 2025 3 min read

Are you following the ERP model of business for Magento 2 store?

Ever had the requirement to manage the changes in ERP to directly reflect in the Magento 2 online store?

If yes, you can consider this post as the starting point for you where I am giving the solution to create & update product using API in Magento 2.

You can also refer to the official document for starters,

“A software interface that lets third-party applications read and write to a system using programming language constructs or statements.”

Magento supports and provides REST and SOAP.

Magento uses Swagger to display REST APIs for all installed products and allows you to try out the APIs.

The Magento 2 REST API identifies various functions to perform requests and receive responses. One can perform these interactions by using the HTTP protocol.

Steps to create & update product using API in Magento 2:

Method to create product using API in Magento 2:

First, you need to generate an authentication key and follow the below steps for the same:

1. Navigate to System > Extensions > Integration

2. Click Add New Integration button

3. Enter your Name and admin Password

1_create-product-using-API-in-Magento-2

4. Click save and active button

5. Click Allow. Now the Authentication key is generated

2_create product using API in Magento 2

New API:

new api

New Auth:

new auth

First you need to open swagger like <YourBaseURL>/Swagger/# or open list of API https://devdocs.magento.com/swagger/#/

In order to create and update product in Magento 2, you may require to generate admin access token first. Read here how to get admin token in Magento 2 API.

Open Postman and enter URL to create the product:

  1.  <YourbaseURL>/rest//V1/products eg. http://127.0.0.1/magento/rest/V1/products
  2. Select Method Post
  3. Header part :Authorization: Bearer <Hear Enter generated Authentication key>
    Content-Type:   application/json
  4. Enter payload data into body section
{
  "product": {
    "sku": "samsung-a50",
    "name": "Samsung A50 ",
    "attribute_set_id": 4,
    "price": 150000,
    "status": 1,
    "visibility": 1,
    "type_id": "Default",
    "weight": "1",
    "extension_attributes": {
      "category_links": [
        {
          "position": 0,
          "category_id": "6"
        }
      ],
      "stock_item": {
        "qty": "10",
        "is_in_stock": true
      }
    },
    "custom_attributes": [
      {
        "attribute_code": "pattern",
        "value": "1960"
      },
      {
        "attribute_code": "color",
        "value": "45"
      },
      {
        "attribute_code": "size",
        "value": "168"
      }
    ]
  }
}

Method to Update Product Using API in Magento 2:

URL:  <BaseURL>/rest/V1/products/{SKU}  eg. http://127.0.0.1/magento/rest/V1/products/samsung-a50

Select Method : PUT

Body

{
  "product": {
    "price": 20000,
    "custom_attributes": [
      {
        "attribute_code": "color",
        "value": "47"
      }
    ]
  }
}

First, you need to open swagger like <YourBaseURL>/Swagger/# or open list of API https://devdocs.magento.com/swagger/#/

That’s it.

It would be great if you could share the post with Magento 2 developers via social media.

Thank you.

Sanjay Jethva Full Image
Article bySanjay Jethva

Sanjay is the co-founder and CTO of Meetanshi with hands-on expertise with Magento since 2011. He specializes in complex development, integrations, extensions, and customizations. Sanjay is one the top 50 contributor to the Magento community and is recognized by Adobe. His passion for Magento 2 and Shopify solutions has made him a trusted source for businesses seeking to optimize their online stores. He loves sharing technical solutions related to Magento 2 & Shopify.