Magento 2 API Manage Tier Prices

Magento 2 API (Updated 2024): Manage Tier Prices

In pricing strategy, many companies apply tier pricing. Tier pricing offers a quantity discount to members of a specific customer group and website. The tier prices service provides an efficient means to set tier prices for one or more products without requiring detailed information about each product.

Now, I will set tier prices, get tier prices, delete tier prices and replace existing tier prices by Magento 2 API.

Set Tier Prices

You can use REST endpoints to set tier prices for the following product types:

PRODUCT TYPETIER PRICE TYPES
SimpleFixed, discount
BundleDiscount
VirtualFixed, discount
DownloadableFixed, discount

Step 1: Generate Admin Access Token

Endpoint: POST <host>/rest/V1/integration/admin/token

Enter your admin username and password in Body sections, then click Send.

{
  "username": "string",
  "password": "string"
}Code language: JSON / JSON with Comments (json)

Response: access token

Step 2: Set Tier Prices

Create a new request and enter the admin access token

Authorization: Bearer token

Endpoint: POST <host>/rest/<store_code>/V1/products/tier-prices

Payload:

{
  "prices": [
    {
      "price": 39,
      "price_type": "fixed",
      "website_id": 0,
      "sku": "24-MB02",
      "customer_group": "General",
      "quantity": 3
    },
    {
      "price": 29,
      "price_type": "fixed",
      "website_id": 0,
      "sku": "24-MB02",
      "customer_group": "General",
      "quantity": 5
    },
    {
      "price": 19,
      "price_type": "fixed",
      "website_id": 0,
      "sku": "24-MB02",
      "customer_group": "General",
      "quantity": 10
    }
  ]
}Code language: JSON / JSON with Comments (json)

Response:

An empty array.

[]

The response of set tier price call
The response of set tier price call

Step 3: Verify The Tier Prices

In Store, Search 24-MB02 (24-MB02 is SKU of the product I set a tier price for). And look at the Tier price in the price area.

 The result of set tier price call
The result of set tier price call

Get Tier Prices

Magento returns all active tier prices for the specified list of sku.

Step 1: Generate Admin Access Token

Endpoint: POST <host>/rest/V1/integration/admin/token

Enter your admin username and password in Body sections, then click Send.

{
  "username": "string",
  "password": "string"
}Code language: JSON / JSON with Comments (json)

Response: access token

Step 2: Get Tier Prices

Create a new request and enter the admin access token

Authorization: Bearer token

Endpoint: POST <host>/rest/<store_code>/V1/products/tier-prices-information

Payload:

{
  "skus": [
    "24-MB02"
  ]
}Code language: JSON / JSON with Comments (json)

Response:

[
    {
        "price": 39,
        "price_type": "fixed",
        "website_id": 0,
        "sku": "24-MB02",
        "customer_group": "General",
        "quantity": 3
    },
    {
        "price": 29,
        "price_type": "fixed",
        "website_id": 0,
        "sku": "24-MB02",
        "customer_group": "General",
        "quantity": 5
    },
    {
        "price": 19,
        "price_type": "fixed",
        "website_id": 0,
        "sku": "24-MB02",
        "customer_group": "General",
        "quantity": 10
    }
]
Code language: JSON / JSON with Comments (json)
 The response of get tier price call
The response of get tier price call

Delete Tier Prices

Step 1: Generate Admin Access Token

Endpoint: POST <host>/rest/V1/integration/admin/token

Enter your admin username and password in Body sections, then click Send.

{
  "username": "string",
  "password": "string"
}Code language: JSON / JSON with Comments (json)

Response: access token

Step 2: Delete Tier Prices

In this step, you can delete one or multiple tier prices. In this example I will delete the $29 tier price.

Create a new request and enter the admin access token

Authorization: Bearer token

Endpoint: POST <host>/rest/<store_code>/V1/products/tier-prices-delete

Payload

{
  "prices": [
    {
      "price": 29,
      "price_type": "fixed",
      "website_id": 0,
      "sku": "24-MB02",
      "customer_group": "General",
      "quantity": 5
    }
  ]
}Code language: JSON / JSON with Comments (json)

Response:

An empty array.

[]

 The response of delete tier price call
The response of delete tier price call

Step 3: Verify The Result

In Store, Search 24-MB02. As you can see the tier prices have been deleted successfully.

 The result of delete tier price call
The result of delete tier price call

Replace Existing Tier Prices

The replace request removes all existing tier prices for a specified product and adds new rows for this same product instead.

Now I will remove the 39$ tier for SKU 24-MB02 and change the customer group for the SKU’s from general group to not logged in group.

Step 1: Generate Admin Access Token

Endpoint: POST <host>/rest/V1/integration/admin/token

Enter your admin username and password in Body sections, then click Send.

{
  "username": "string",
  "password": "string"
}Code language: JSON / JSON with Comments (json)

Response: access token

Step 2: Replace Existing Tier Prices

Create a new request and enter the admin access token

Authorization: Bearer token

Endpoint: PUT <host>/rest/<store_code>/V1/products/tier-prices

Payload:

{
  "prices": [
    {
      "price": 25,
      "price_type": "fixed",
      "website_id": 0,
      "sku": "24-MB02",
      "customer_group": "NOT LOGGED IN",
      "quantity": 5
    },
    {
      "price": 15,
      "price_type": "fixed",
      "website_id": 0,
      "sku": "24-MB02",
      "customer_group": "NOT LOGGED IN",
      "quantity": 10
    }
  ]
}Code language: JSON / JSON with Comments (json)

Response:

An empty array.

[]

The response of  replace existing tier prices
The response of replace existing tier prices

Step 3: Verify The Result

In the Store, you have to log out then search 24-MB02. Replacing existing tier prices has been created successfully.

 The result of  replace existing tier prices
The result of replace existing tier prices
Magento 2 API: Manage Tier Prices

Above, I have just provided you with many steps to Manage tier prices. I hope it will be helpful for you when managing tier prices using Magento API. For more information, you can refer to Magento DevDocs. If you have any questions or new ideas, feel free to leave a comment below.

Want to Learn More?