Magento 2 REST API Tutorial Using Postman – Complete Beginner to Advanced Guide

Magento 2 REST API Tutorial Using Postman – Complete Beginner to Advanced Guide

AI Reading

Quick summary of this article

This tutorial teaches developers how to use Magento 2 REST APIs with Postman, covering everything from initial setup to performing product CRUD operations. It explains how REST APIs allow external applications like ERP systems, mobile apps, and custom software to communicate with a Magento store programmatically, replacing manual Admin Panel tasks with automated HTTP requests.

  • Magento REST APIs use standard HTTP methods - GET to retrieve data, POST to create, PUT to update, and DELETE to remove resources like products, customers, and orders.
  • Authentication requires generating an admin access token via a POST request to /rest/V1/integration/admin/token, then including it as a Bearer Token in all subsequent API calls.
  • Postman environment variables let you store your Magento URL, admin credentials, and generated token once, making it easy to switch between local, staging, and production servers without editing individual requests.
  • Common API errors include 401 Unauthorized (incorrect login), 403 Forbidden (insufficient permissions), 404 Not Found (wrong endpoint), and 500 Internal Server Error (server configuration issues).
  • Best practices include using HTTPS for production, never hardcoding passwords, storing tokens securely, and granting only minimum required permissions to API users.

Magento 2 REST API Tutorial Using Postman – Complete Beginner to Advanced Guide

Magento 2 provides a powerful REST API that allows developers to communicate with their online store programmatically. Instead of performing every task manually from the Magento Admin Panel, developers can create, update, retrieve and delete products, customers, orders, categories, inventory and many other resources using secure API endpoints.

REST APIs are widely used for integrating ERP software, CRM systems, Warehouse Management Systems (WMS), mobile applications, third-party marketplaces, POS software, and custom business applications with Magento. Whether you are building an Android application, iOS application, React website, Flutter app, or Laravel backend, understanding Magento REST APIs is an essential skill for modern Magento development.

In this complete tutorial, you will learn how to use Magento 2 REST APIs with Postman from scratch. We will start with authentication, generate an administrator access token, configure a reusable Postman environment, understand request methods, work with JSON payloads, retrieve store information, and perform complete Product CRUD (Create, Read, Update and Delete) operations.

Unlike many beginner tutorials, this guide explains not only how to send API requests but also why Magento expects specific parameters, how authentication works internally, and how to troubleshoot common API errors like 401 Unauthorized, 403 Forbidden, 404 Not Found and 500 Internal Server Error.

Learning Objectives

After completing this chapter, you should be able to:

  • Understand what Magento 2 REST APIs are.
  • Understand HTTP Requests and Responses.
  • Learn REST API architecture.
  • Install and configure Postman.
  • Create a reusable Magento API Environment.
  • Generate an Admin Authentication Token.
  • Use Bearer Authentication.
  • Understand JSON Request Body.
  • Retrieve Magento Store Information.
  • Perform Product CRUD operations.
  • Understand HTTP Status Codes.
  • Troubleshoot common Magento API errors.
  • Follow professional API development best practices.

1. What is Magento 2 REST API?

REST stands for Representational State Transfer. It is a software architecture that allows two applications to communicate over the internet using standard HTTP methods such as GET, POST, PUT and DELETE.

Magento exposes hundreds of REST API endpoints that can be used to access almost every feature available inside the Magento Admin Panel. Instead of clicking buttons manually, developers can simply send HTTP requests to Magento and receive structured JSON responses.

Basic REST API Flow


Client Application
       │
       ▼
HTTP Request
       │
       ▼
Magento REST API
       │
       ▼
Business Logic
       │
       ▼
Database
       │
       ▼
JSON Response

Whenever a request reaches Magento, the framework validates authentication, checks permissions, processes business logic, retrieves or updates the database, and finally returns the result as a JSON response.

Real World Example

Suppose an ERP system contains 50,000 products. Instead of manually entering every product into Magento, the ERP can send API requests to automatically create or update products. Likewise, a mobile application can retrieve product details, categories and inventory using REST APIs without directly accessing the Magento database.

2. Understanding HTTP Methods

Every REST API request uses an HTTP method. The HTTP method tells Magento what type of action should be performed.

Method Purpose Example
GET Retrieve Data Get Product Information
POST Create Data Create Product
PUT Update Existing Data Update Product Price
DELETE Delete Data Delete Product

Choosing the correct HTTP method is extremely important because Magento validates the request type before executing any operation. Sending a GET request to a POST endpoint usually returns an error.

3. Why Use Postman?

Postman is one of the most popular API development and testing tools. It provides a graphical interface for sending HTTP requests, inspecting responses, managing authentication, creating reusable collections, and automating API testing.

Instead of writing cURL commands every time, developers can simply fill out the request URL, select the HTTP method, add headers, enter JSON data and click the Send button.

Advantages of Postman

  • Simple graphical interface.
  • Supports all HTTP methods.
  • Automatic JSON formatting.
  • Bearer Token authentication.
  • Environment variables.
  • Collections for organizing APIs.
  • Automated testing scripts.
  • Easy export and sharing.
  • Supports REST, GraphQL and SOAP APIs.

4. Install Postman

Download the latest version of Postman from the official website and install it on your operating system.

Postman is available for Windows, macOS and Linux.

Installation Steps

  1. Download Postman.
  2. Install the application.
  3. Launch Postman.
  4. Create a free account (optional).
  5. Create a new Workspace.
  6. Create a new Collection named Magento 2 REST API.

5. Create a Magento API Environment

Instead of hardcoding your Magento URL and authentication credentials inside every request, Postman allows you to create reusable variables known as Environment Variables.

Whenever your Magento server changes from Localhost to Staging or Production, you only need to update the environment variables instead of editing every API request individually.

Create the Following Variables

Variable Example Value Description
baseUrl http://your-magento.local Magento Base URL
adminUsername admin Magento Administrator Username
adminPassword ******** Administrator Password
adminToken (Blank) Generated Automatically

Why Environment Variables Are Important

  • Improve security.
  • Avoid repeating URLs.
  • Switch between Local, Staging and Production.
  • Keep API collections reusable.
  • Reduce configuration mistakes.

In the next section, we will use these environment variables to generate an administrator access token and configure automatic authentication for all Magento API requests.

6. Generate Magento Admin Access Token

Before Magento allows you to create, update or delete products, you must authenticate yourself. Authentication confirms your identity and verifies that you have permission to access protected resources.

Magento uses an Admin Access Token for authentication. This token acts like a temporary digital key. Once generated successfully, it must be included in every protected API request using the Authorization: Bearer header.

Instead of sending your administrator username and password with every request, Magento allows you to authenticate once and then reuse the generated access token for subsequent requests.

Authentication Flow


Admin Username + Password
           │
           ▼
POST /rest/V1/integration/admin/token
           │
           ▼
Magento Authentication
           │
           ▼
Generate Access Token
           │
           ▼
Bearer Token
           │
           ▼
Authorized API Requests

7. Admin Token Endpoint

Magento provides a dedicated REST endpoint for generating administrator access tokens.

HTTP Method

POST

Endpoint

{{baseUrl}}/rest/V1/integration/admin/token

Headers

Header Value
Content-Type application/json

Request Body

{
    "username":"{{adminUsername}}",
    "password":"{{adminPassword}}"
}

Notice that we are using Postman Environment Variables instead of hardcoding the username and password. This makes the collection reusable across multiple Magento installations.

8. Sending the Request in Postman

  1. Create a new POST request.
  2. Enter the endpoint URL.
  3. Select the Body tab.
  4. Choose Raw.
  5. Select JSON from the dropdown.
  6. Paste the JSON request body.
  7. Click the Send button.

If the credentials are correct, Magento authenticates the administrator account and returns a long encrypted access token.

9. Successful Response

Unlike many REST APIs, Magento returns the token as a plain JSON string rather than inside a JSON object.

"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9xxxxxxxxxxxxxxxxxxxxxxxx"

This token is now your authorization credential. Every protected Magento API request must include this token.

10. Automatically Save the Token in Postman

Copying and pasting the access token into every request quickly becomes tedious. Fortunately, Postman allows you to automate this process using JavaScript in the Tests tab.

Open the Tests tab and add the following script.

const token = pm.response.text().replace(/"/g, "");

pm.environment.set("adminToken", token);

Whenever the authentication request is executed successfully, Postman automatically stores the token inside the adminToken environment variable.

From this point onward, every request can use {{adminToken}} without copying anything manually.

11. Verify the Saved Environment Variable

Open your Postman Environment and verify that the adminToken variable now contains a long authentication token.

Variable Value
baseUrl http://your-magento.local
adminUsername admin
adminPassword ********
adminToken eyJ0eXAiOiJKV1QiOi…

12. Using Bearer Authentication

Now that the administrator token has been generated, every protected Magento endpoint must include the Authorization header.

Header

Authorization: Bearer {{adminToken}}

Rather than adding this header manually to every request, Postman provides a built-in Authorization feature.

Configure Collection Authorization

  1. Open your Magento Collection.
  2. Select the Authorization tab.
  3. Choose Bearer Token.
  4. Enter:
{{adminToken}}

Every request inside the collection now automatically inherits the Bearer Token, making your API collection easier to maintain.

13. Common Authentication Errors

Status Code Meaning Possible Cause
400 Bad Request Invalid JSON format
401 Unauthorized Incorrect username or password
403 Forbidden User lacks required permissions
404 Not Found Incorrect API endpoint
500 Internal Server Error Magento configuration or server issue

Example 401 Response

{
    "message":"The consumer isn't authorized to access %resources."
}

How to Fix Authentication Problems

  • Verify the administrator username.
  • Verify the administrator password.
  • Ensure the Magento Admin account is active.
  • Confirm the REST endpoint URL is correct.
  • Clear Magento cache if authentication changes were recently made.
  • Generate a fresh access token after changing the administrator password.
  • Verify that Postman is using the correct environment.

14. Best Practices for Authentication

  • Never hardcode administrator passwords inside your API collection.
  • Always use Environment Variables.
  • Store access tokens securely.
  • Regenerate tokens whenever administrator credentials change.
  • Never publish access tokens in screenshots or blog articles.
  • Use HTTPS on production websites to encrypt API communication.
  • Grant only the minimum required permissions to API users.

Congratulations! Your Magento REST API authentication is now fully configured. In the next section, we will use the generated Bearer Token to retrieve Magento Websites, Store Views, Store Configurations and other system information using secure GET requests.

6. Generate Magento Admin Access Token

Before Magento allows you to create, update or delete products, you must authenticate yourself. Authentication confirms your identity and verifies that you have permission to access protected resources.

Magento uses an Admin Access Token for authentication. This token acts like a temporary digital key. Once generated successfully, it must be included in every protected API request using the Authorization: Bearer header.

Instead of sending your administrator username and password with every request, Magento allows you to authenticate once and then reuse the generated access token for subsequent requests.

Authentication Flow


Admin Username + Password
           │
           ▼
POST /rest/V1/integration/admin/token
           │
           ▼
Magento Authentication
           │
           ▼
Generate Access Token
           │
           ▼
Bearer Token
           │
           ▼
Authorized API Requests

7. Admin Token Endpoint

Magento provides a dedicated REST endpoint for generating administrator access tokens.

HTTP Method

POST

Endpoint

{{baseUrl}}/rest/V1/integration/admin/token

Headers

Header Value
Content-Type application/json

Request Body

{
    "username":"{{adminUsername}}",
    "password":"{{adminPassword}}"
}

Notice that we are using Postman Environment Variables instead of hardcoding the username and password. This makes the collection reusable across multiple Magento installations.

8. Sending the Request in Postman

  1. Create a new POST request.
  2. Enter the endpoint URL.
  3. Select the Body tab.
  4. Choose Raw.
  5. Select JSON from the dropdown.
  6. Paste the JSON request body.
  7. Click the Send button.

If the credentials are correct, Magento authenticates the administrator account and returns a long encrypted access token.

9. Successful Response

Unlike many REST APIs, Magento returns the token as a plain JSON string rather than inside a JSON object.

"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9xxxxxxxxxxxxxxxxxxxxxxxx"

This token is now your authorization credential. Every protected Magento API request must include this token.

10. Automatically Save the Token in Postman

Copying and pasting the access token into every request quickly becomes tedious. Fortunately, Postman allows you to automate this process using JavaScript in the Tests tab.

Open the Tests tab and add the following script.

const token = pm.response.text().replace(/"/g, "");

pm.environment.set("adminToken", token);

Whenever the authentication request is executed successfully, Postman automatically stores the token inside the adminToken environment variable.

From this point onward, every request can use {{adminToken}} without copying anything manually.

11. Verify the Saved Environment Variable

Open your Postman Environment and verify that the adminToken variable now contains a long authentication token.

Variable Value
baseUrl http://your-magento.local
adminUsername admin
adminPassword ********
adminToken eyJ0eXAiOiJKV1QiOi…

12. Using Bearer Authentication

Now that the administrator token has been generated, every protected Magento endpoint must include the Authorization header.

Header

Authorization: Bearer {{adminToken}}

Rather than adding this header manually to every request, Postman provides a built-in Authorization feature.

Configure Collection Authorization

  1. Open your Magento Collection.
  2. Select the Authorization tab.
  3. Choose Bearer Token.
  4. Enter:
{{adminToken}}

Every request inside the collection now automatically inherits the Bearer Token, making your API collection easier to maintain.

13. Common Authentication Errors

Status Code Meaning Possible Cause
400 Bad Request Invalid JSON format
401 Unauthorized Incorrect username or password
403 Forbidden User lacks required permissions
404 Not Found Incorrect API endpoint
500 Internal Server Error Magento configuration or server issue

Example 401 Response

{
    "message":"The consumer isn't authorized to access %resources."
}

How to Fix Authentication Problems

  • Verify the administrator username.
  • Verify the administrator password.
  • Ensure the Magento Admin account is active.
  • Confirm the REST endpoint URL is correct.
  • Clear Magento cache if authentication changes were recently made.
  • Generate a fresh access token after changing the administrator password.
  • Verify that Postman is using the correct environment.

14. Best Practices for Authentication

  • Never hardcode administrator passwords inside your API collection.
  • Always use Environment Variables.
  • Store access tokens securely.
  • Regenerate tokens whenever administrator credentials change.
  • Never publish access tokens in screenshots or blog articles.
  • Use HTTPS on production websites to encrypt API communication.
  • Grant only the minimum required permissions to API users.

Congratulations! Your Magento REST API authentication is now fully configured. In the next section, we will use the generated Bearer Token to retrieve Magento Websites, Store Views, Store Configurations and other system information using secure GET requests.

15. Retrieve Magento Websites

Magento supports multiple websites, stores and store views inside a single installation. Before creating products or assigning inventory, it is useful to understand the website structure configured in your Magento system.

The Magento Websites API returns information about all websites available in the current Magento installation. This may include the default website and any additional websites created for different brands, countries, currencies or business divisions.

HTTP Method

GET

Endpoint

{{baseUrl}}/rest/V1/store/websites

Authorization

Bearer {{adminToken}}

Postman Steps

  1. Create a new request inside the Magento 2 REST API collection.
  2. Name the request Get Magento Websites.
  3. Select the GET method.
  4. Enter the website endpoint.
  5. Confirm that Authorization is inherited from the collection.
  6. Click Send.

Example Response

[
    {
        "id": 0,
        "code": "admin",
        "name": "Admin",
        "default_group_id": 0
    },
    {
        "id": 1,
        "code": "base",
        "name": "Main Website",
        "default_group_id": 1
    }
]

The response contains a list of website objects. The website with the code base is normally the main storefront website in a default Magento installation.

Important Website Fields

Field Description
id Unique numeric website identifier
code Internal website code used by Magento
name Website name displayed in the Admin Panel
default_group_id Default store group connected to the website

16. Retrieve Magento Store Groups

A website may contain one or more store groups. Store groups organize store views and define important settings such as the root category used by the storefront.

HTTP Method

GET

Endpoint

{{baseUrl}}/rest/V1/store/storeGroups

Example Response

[
    {
        "id": 0,
        "website_id": 0,
        "root_category_id": 0,
        "default_store_id": 0,
        "name": "Default",
        "code": "default"
    },
    {
        "id": 1,
        "website_id": 1,
        "root_category_id": 2,
        "default_store_id": 1,
        "name": "Main Website Store",
        "code": "main_website_store"
    }
]

The field root_category_id is especially important because it identifies the category tree used by the store group.

17. Retrieve Magento Store Views

Store views are commonly used to display different languages, currencies or regional content. For example, one Magento website may contain an English store view, a Hindi store view and a Bengali store view.

HTTP Method

GET

Endpoint

{{baseUrl}}/rest/V1/store/storeViews

Example Response

[
    {
        "id": 0,
        "code": "admin",
        "name": "Admin",
        "website_id": 0,
        "store_group_id": 0,
        "is_active": 1
    },
    {
        "id": 1,
        "code": "default",
        "name": "Default Store View",
        "website_id": 1,
        "store_group_id": 1,
        "is_active": 1
    }
]

Important Store View Fields

  • id identifies the store view.
  • code is used in store-specific API URLs.
  • name is the label shown in Magento Admin.
  • website_id connects the store view to a website.
  • store_group_id connects the store view to a store group.
  • is_active indicates whether the store view is enabled.

18. Retrieve Magento Store Configurations

The Store Configuration API provides important information about each Magento store view, including locale, currency, base URL, media URL, time zone, weight unit and other settings.

HTTP Method

GET

Endpoint

{{baseUrl}}/rest/V1/store/storeConfigs

Example Response

[
    {
        "id": 1,
        "code": "default",
        "website_id": 1,
        "locale": "en_US",
        "base_currency_code": "USD",
        "default_display_currency_code": "USD",
        "timezone": "America/Los_Angeles",
        "weight_unit": "lbs",
        "base_url": "http://your-magento.local/",
        "base_link_url": "http://your-magento.local/",
        "base_static_url": "http://your-magento.local/static/",
        "base_media_url": "http://your-magento.local/media/"
    }
]

Configuration Fields Explained

Field Description
locale Language and regional format used by the store view
base_currency_code Main currency used for catalog prices
default_display_currency_code Currency displayed to customers
timezone Time zone configured for the store
weight_unit Default weight measurement unit
base_url Main storefront URL
base_static_url URL used for CSS, JavaScript and static assets
base_media_url URL used for product images and uploaded media

19. Using Store Codes in Magento API URLs

Magento REST endpoints can optionally include a store code. This is useful when retrieving or updating data for a specific store view.

Default REST URL

{{baseUrl}}/rest/V1/products

Store-Specific REST URL

{{baseUrl}}/rest/default/V1/products

In this example, default is the store view code. When the store code is included, Magento processes the request within that store view’s scope.

Common Store Scope Uses

  • Updating translated product names.
  • Updating store-specific product descriptions.
  • Retrieving localized product information.
  • Managing store-view-level configuration.
  • Working with different currencies or regional content.

20. Understand Magento API Request Headers

Headers provide additional information about an API request. Magento commonly requires the Authorization and Content-Type headers.

Common Headers

Header Example Value Purpose
Authorization Bearer {{adminToken}} Authenticates the API request
Content-Type application/json Indicates that the request body contains JSON
Accept application/json Requests a JSON response

For GET requests, the Content-Type header may not always be required because there is usually no request body. However, including the Accept header clearly indicates that the client expects JSON data.

21. Create a Reusable Postman Collection Structure

A well-organized Postman collection saves time and makes API testing easier. Instead of placing every request in one long list, organize requests into logical folders.

Recommended Collection Structure

Magento 2 REST API
│
├── Authentication
│   └── Generate Admin Token
│
├── Store Information
│   ├── Get Websites
│   ├── Get Store Groups
│   ├── Get Store Views
│   └── Get Store Configurations
│
├── Products
│   ├── Create Product
│   ├── Get Product
│   ├── Get Product List
│   ├── Update Product
│   └── Delete Product
│
├── Categories
│
├── Customers
│
├── Orders
│
└── Inventory

Each folder can inherit the collection-level Bearer Token. This keeps authentication centralized and prevents duplicate configuration.

22. Add a Basic Response Test

Postman Tests can automatically check whether an API response is successful. Add the following script to a GET request.

pm.test("Status code is 200", function () {
    pm.response.to.have.status(200);
});

Validate JSON Response

pm.test("Response is valid JSON", function () {
    pm.response.to.be.json;
});

Check Response Time

pm.test("Response time is below 2000ms", function () {
    pm.expect(pm.response.responseTime).to.be.below(2000);
});

These tests help identify failed requests immediately and are especially useful when running an entire Postman collection automatically.

You have now successfully retrieved Magento websites, store groups, store views and configuration details. In the next section, we will begin Product CRUD operations by creating a new simple product using a POST request and a complete JSON payload.

23. Create a Simple Product Using Magento REST API

After configuring authentication and retrieving store information, the next step is to create a product through the Magento REST API. Magento supports several product types, including simple, configurable, grouped, virtual, bundle and downloadable products.

In this section, we will create a simple product. A simple product is a physical or virtual item with a single SKU and no selectable variations. Examples include a book, medicine box, mobile cover, keyboard or T-shirt available in only one size and colour.

Creating a product through the API requires a JSON request body containing the product’s SKU, name, price, status, visibility, product type, attribute set and other optional information.

HTTP Method

POST

Endpoint

{{baseUrl}}/rest/V1/products

Authorization

Bearer {{adminToken}}

Required Header

Content-Type: application/json

24. Basic Product Creation Request

Create a new POST request inside the Products folder of your Postman collection. Select the Body tab, choose Raw, select JSON and paste the following payload.

{
    "product": {
        "sku": "demo-product-001",
        "name": "Demo Magento Product",
        "attribute_set_id": 4,
        "price": 999,
        "status": 1,
        "visibility": 4,
        "type_id": "simple",
        "weight": 0.5
    }
}

Click the Send button. If the request is valid and the SKU does not already exist, Magento creates the product and returns the complete product object.

Example Successful Response

{
    "id": 125,
    "sku": "demo-product-001",
    "name": "Demo Magento Product",
    "attribute_set_id": 4,
    "price": 999,
    "status": 1,
    "visibility": 4,
    "type_id": "simple",
    "created_at": "2026-07-20 12:30:00",
    "updated_at": "2026-07-20 12:30:00",
    "weight": 0.5,
    "extension_attributes": {
        "website_ids": [
            1
        ]
    },
    "product_links": [],
    "options": [],
    "media_gallery_entries": [],
    "tier_prices": [],
    "custom_attributes": []
}

The exact response may contain additional fields depending on the Magento version, installed extensions and configured product attributes.

25. Product Fields Explained

Field Example Description
sku demo-product-001 Unique product identifier used for API and inventory operations
name Demo Magento Product Product name displayed in the storefront and Admin Panel
attribute_set_id 4 Attribute set assigned to the product
price 999 Base product price
status 1 Controls whether the product is enabled or disabled
visibility 4 Controls where the product is visible
type_id simple Defines the Magento product type
weight 0.5 Physical weight used for shipping calculations

26. Understanding Product SKU

SKU stands for Stock Keeping Unit. It is one of the most important product identifiers in Magento. Every product must have a unique SKU.

Valid SKU Examples

shirt-blue-medium
MED-00125
mobile-cover-iphone-15
BOOK-ADV-EXCEL-01

SKU Best Practices

  • Use a consistent naming pattern.
  • Avoid spaces wherever possible.
  • Use letters, numbers, hyphens or underscores.
  • Keep the SKU unique across the catalog.
  • Do not frequently change SKUs after integration.
  • Match the SKU with ERP or inventory software when applicable.

Magento uses the SKU in many product endpoints. For example, retrieving, updating and deleting a product normally requires the SKU in the URL.

27. Understanding Attribute Set ID

An attribute set is a collection of product attributes. Different product types may require different attribute sets. For example, a clothing attribute set may include Size, Colour and Material, while an electronics attribute set may include Brand, Warranty and Model Number.

In many default Magento installations, the Default product attribute set has the ID 4. However, you should not assume that every Magento website uses the same ID.

Retrieve Product Attribute Sets

GET {{baseUrl}}/rest/V1/products/attribute-sets/sets/list?searchCriteria=

Example Response

{
    "items": [
        {
            "attribute_set_id": 4,
            "attribute_set_name": "Default",
            "sort_order": 1,
            "entity_type_id": 4
        }
    ],
    "search_criteria": {
        "filter_groups": []
    },
    "total_count": 1
}

Use the correct attribute_set_id when creating the product. If you provide an invalid attribute set ID, Magento may reject the request.

28. Product Status Values

The product status determines whether a product is enabled or disabled in Magento.

Status Value Meaning
1 Enabled
2 Disabled

Enabled Product

"status": 1

Disabled Product

"status": 2

A disabled product remains available in the Magento Admin Panel and through administrative APIs, but it is generally not displayed to storefront customers.

29. Product Visibility Values

Visibility controls where a product appears in the Magento storefront. Magento uses numeric values for product visibility.

Value Visibility Description
1 Not Visible Individually Usually used for child products of configurable, grouped or bundle products
2 Catalog Visible in category and catalog pages but not search results
3 Search Visible in search results but not category pages
4 Catalog and Search Visible in both catalog pages and search results

For a normal standalone simple product, visibility value 4 is commonly used.

30. Product Type ID

The type_id field tells Magento which product model should be used.

Product Type type_id Value
Simple Product simple
Configurable Product configurable
Virtual Product virtual
Grouped Product grouped
Bundle Product bundle
Downloadable Product downloadable

Each product type has different requirements. A simple product needs basic product information, while configurable products require child products and configurable option attributes.

31. Add Product Description and Custom Attributes

Magento stores many product values as custom attributes. Fields such as description, short description, URL key, meta title, tax class and manufacturer may be added inside the custom_attributes array.

Product Request with Custom Attributes

{
    "product": {
        "sku": "demo-product-002",
        "name": "Premium Demo Product",
        "attribute_set_id": 4,
        "price": 1499,
        "status": 1,
        "visibility": 4,
        "type_id": "simple",
        "weight": 1,
        "custom_attributes": [
            {
                "attribute_code": "description",
                "value": "This is a detailed description of the premium demo product."
            },
            {
                "attribute_code": "short_description",
                "value": "A premium product created using Magento REST API."
            },
            {
                "attribute_code": "url_key",
                "value": "premium-demo-product"
            },
            {
                "attribute_code": "tax_class_id",
                "value": "2"
            }
        ]
    }
}

Custom Attribute Structure

{
    "attribute_code": "description",
    "value": "Product description goes here"
}

The attribute_code must match an existing Magento product attribute code. The value contains the information assigned to that attribute.

32. Assign Product to a Website

In multi-website Magento installations, a product should be assigned to one or more websites. Website assignments can be added using extension attributes.

{
    "product": {
        "sku": "demo-product-003",
        "name": "Website Assigned Product",
        "attribute_set_id": 4,
        "price": 1999,
        "status": 1,
        "visibility": 4,
        "type_id": "simple",
        "weight": 1,
        "extension_attributes": {
            "website_ids": [
                1
            ]
        }
    }
}

The website ID 1 normally represents the Main Website in a default Magento installation. Always retrieve the website list first and verify the correct website ID.

33. Common Product Creation Errors

Error Possible Cause Recommended Solution
SKU already exists A product with the same SKU is already available Use a new SKU or update the existing product
Invalid attribute set The supplied attribute set ID does not exist Retrieve available attribute sets and use a valid ID
Invalid attribute code Custom attribute does not exist Verify the product attribute code in Magento Admin
Unauthorized Missing, invalid or expired token Generate a fresh administrator token
Invalid JSON Missing comma, quote, brace or incorrect data format Validate and format the JSON request body

The next part will explain how to add stock quantity and inventory information, retrieve an individual product by SKU, inspect the product response and verify that the newly created product exists in Magento.

34. Add Stock Quantity to a Product

Creating a product does not always make it immediately available for purchase. Magento also needs inventory information such as stock quantity, stock status, backorder settings and minimum purchase quantity.

Depending on your Magento version and inventory configuration, stock may be managed through the legacy Stock Item API or Magento Multi-Source Inventory, also known as MSI. In this section, we will first use the standard stock item endpoint to assign quantity to a simple product.

HTTP Method

PUT

Endpoint

{{baseUrl}}/rest/V1/products/demo-product-001/stockItems/1

In this endpoint, demo-product-001 is the product SKU and 1 is the stock item ID used by the default stock.

Authorization

Bearer {{adminToken}}

Request Body

{
    "stockItem": {
        "qty": 100,
        "is_in_stock": true,
        "manage_stock": true
    }
}

After sending the request, Magento updates the quantity and marks the product as in stock.

Example Successful Response

1

A response containing 1 normally indicates that the stock item was updated successfully.

35. Important Stock Item Fields

Field Example Description
qty 100 Available product quantity
is_in_stock true Controls whether the product is considered in stock
manage_stock true Enables quantity-based stock management
min_qty 0 Quantity level at which the product becomes out of stock
min_sale_qty 1 Minimum quantity allowed in a customer order
max_sale_qty 10000 Maximum quantity allowed in a customer order
backorders 0 Controls whether customers can order out-of-stock quantities
notify_stock_qty 1 Quantity level used for low-stock notifications

36. Complete Stock Update Request

The following example includes additional stock settings.

{
    "stockItem": {
        "qty": 250,
        "is_in_stock": true,
        "manage_stock": true,
        "use_config_manage_stock": false,
        "min_qty": 0,
        "use_config_min_qty": false,
        "min_sale_qty": 1,
        "use_config_min_sale_qty": false,
        "max_sale_qty": 20,
        "use_config_max_sale_qty": false,
        "backorders": 0,
        "use_config_backorders": false,
        "notify_stock_qty": 5,
        "use_config_notify_stock_qty": false
    }
}

Fields beginning with use_config_ tell Magento whether to use the global inventory configuration or the value provided in the request.

Example

"use_config_max_sale_qty": false,
"max_sale_qty": 20

This means Magento should ignore the global maximum quantity setting and allow a maximum of 20 units per order for this product.

37. Understanding Backorder Values

Value Meaning
0 No Backorders
1 Allow Quantity Below Zero
2 Allow Quantity Below Zero and Notify Customer

Backorders should be enabled carefully because customers may purchase products that are not currently available in physical stock.

38. Magento Multi-Source Inventory

Modern Magento installations may use Multi-Source Inventory. MSI allows stock to be stored in multiple physical locations, such as warehouses, stores, distribution centres or supplier locations.

Instead of updating a single stock item, MSI assigns quantity to a source using the source item endpoint.

HTTP Method

POST

Endpoint

{{baseUrl}}/rest/V1/inventory/source-items

Example MSI Request

{
    "sourceItems": [
        {
            "sku": "demo-product-001",
            "source_code": "default",
            "quantity": 100,
            "status": 1
        }
    ]
}

Source Item Fields

Field Description
sku Product SKU
source_code Inventory source identifier
quantity Available quantity at the selected source
status Source stock status where 1 means in stock and 0 means out of stock

39. Retrieve a Product by SKU

After creating a product and assigning stock, retrieve the product to confirm that it exists and that the main product fields were saved correctly.

HTTP Method

GET

Endpoint

{{baseUrl}}/rest/V1/products/demo-product-001

Authorization

Bearer {{adminToken}}

Postman Steps

  1. Create a new GET request.
  2. Name it Get Product by SKU.
  3. Enter the product endpoint.
  4. Replace the example SKU with your actual product SKU.
  5. Confirm that Bearer Token authorization is inherited.
  6. Click Send.

Example Product Response

{
    "id": 125,
    "sku": "demo-product-001",
    "name": "Demo Magento Product",
    "attribute_set_id": 4,
    "price": 999,
    "status": 1,
    "visibility": 4,
    "type_id": "simple",
    "created_at": "2026-07-20 12:30:00",
    "updated_at": "2026-07-20 12:45:00",
    "weight": 0.5,
    "extension_attributes": {
        "website_ids": [
            1
        ]
    },
    "product_links": [],
    "options": [],
    "media_gallery_entries": [],
    "tier_prices": [],
    "custom_attributes": [
        {
            "attribute_code": "description",
            "value": "This product was created using Magento REST API."
        },
        {
            "attribute_code": "url_key",
            "value": "demo-magento-product"
        }
    ]
}

40. Understand the Product Response

The product response contains both standard properties and custom attributes. Standard properties include SKU, name, price, status and type. Custom attributes contain additional Magento EAV data such as description, tax class, URL key and meta information.

Standard Product Property

"price": 999

Custom Product Attribute

{
    "attribute_code": "description",
    "value": "This product was created using Magento REST API."
}

Magento uses an Entity-Attribute-Value structure for many catalog fields. This makes the catalog flexible because custom product attributes can be created without changing the main product table structure.

41. Retrieve Stock Information

To confirm the product quantity and stock status, use the Stock Item API.

HTTP Method

GET

Endpoint

{{baseUrl}}/rest/V1/stockItems/demo-product-001

Example Response

{
    "item_id": 125,
    "product_id": 125,
    "stock_id": 1,
    "qty": 100,
    "is_in_stock": true,
    "is_qty_decimal": false,
    "show_default_notification_message": false,
    "use_config_min_qty": true,
    "min_qty": 0,
    "use_config_min_sale_qty": 1,
    "min_sale_qty": 1,
    "use_config_max_sale_qty": true,
    "max_sale_qty": 10000,
    "use_config_backorders": true,
    "backorders": 0,
    "use_config_notify_stock_qty": true,
    "notify_stock_qty": 1,
    "manage_stock": true
}

42. Add Postman Tests for Product Retrieval

You can automatically verify that the correct product was returned by adding tests to the Postman request.

Check Status Code

pm.test("Product request returned 200", function () {
    pm.response.to.have.status(200);
});

Check Product SKU

pm.test("Correct product SKU returned", function () {
    const response = pm.response.json();

    pm.expect(response.sku).to.eql("demo-product-001");
});

Check Product Status

pm.test("Product is enabled", function () {
    const response = pm.response.json();

    pm.expect(response.status).to.eql(1);
});

Save Product ID Automatically

const response = pm.response.json();

pm.environment.set("productId", response.id);

This script saves the product ID into a Postman variable named productId. The variable can later be used in other API requests.

43. Product Not Found Error

If the SKU does not exist, Magento normally returns a 404 response.

{
    "message": "The product that was requested doesn't exist. Verify the product and try again."
}

How to Fix the Error

  • Check the SKU spelling.
  • Confirm uppercase and lowercase characters.
  • Make sure the product was created successfully.
  • Verify that special characters are URL encoded.
  • Check that you are connected to the correct Magento environment.

You have now created a product, assigned inventory and retrieved the product using its SKU. In the next part, we will update product information such as name, price, status, weight, description and custom attributes using the Magento Product Update API.

Leave a Reply

Your email address will not be published. Required fields are marked *