Shopify API 2026 – Create, Update, and Delete A Discount Code With Postman In Shopify

Table of Contents

In a previous article, I showed you how to create a Price Rule with Postman, Price rule is a necessary condition to create a discount code. You can define the parameters for a discount with the Price Rule resource, but you’ll need to create associated discount codes for customers. I will show you how to create, update and delete a discount code with Postman In Shopify. 

Create A Discount Code Using Postman In Shopify

Step 1: Generate API credentials from the Shopify admin

Generate API credentials from the Shopify admin

 

Generate API credentials from the Shopify admin

 

The Admin API section displays the app’s API key and password when you save the app’s details. 

Step 2: Create a discount code using Postman in Shopify

Before creating a discount code using Postman, you must create a Price Rule. Remember that Price Rule ID is to use in this step. 

 

https://{username}:{password}@{shop}.myshopify.com/admin/api/{api-version}/{resource}.json

Or you can copy this example in the Shopify Admin, remember to change {resource} to {price_rules/price rule ID/discount_codes}:

<a href="https://33a72f01e02987636e1c1a9a4e95c840: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@hexasync.myshopify.com/admin/api/2021-10/price_rules/1001616998463/discount_codes.json">https://33a72f01e02987636e1c1a9a4e95c840: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@hexasync.myshopify.com/admin/api/2021-10/price_rules/1001616998463/discount_codes.json</a>

Example URL

 

Post

In the body section, enter this code, then click Send.

{
    "discount_code": {
        "code": "SUMMERSALE10OFF"
    }
}

Response:

The API will return all information about the created discount code.

{
    "discount_code": {
        "id": 12231414743103,
        "price_rule_id": 1001616998463,
        "code": "SUMMERSALE10OFF",
        "usage_count": 0,
        "created_at": "2021-12-16T16:44:57+09:00",
        "updated_at": "2021-12-16T16:44:57+09:00"
    }
}

Response

Step 3: Verify The Result

In the Shopify Admin, Choose Discounts 

Result

As you can see, the discount code has been created successfully.

Update An Existing Discount Code Using Postman In Shopify

Step1: Update An Existing Discount Code Using Postman In Shopify

https://{username}:{password}@{shop}.myshopify.com/admin/api/{api-version}/{resource}.json

Or you can copy this example in the Shopify Admin,

Remember to change {resource} to {price_rules/price rule ID/discount_codes/discount code ID}:

https://33a72f01e02987636e1c1a9a4e95c840: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@hexasync.myshopify.com/admin/api/2021-10/price_rules/1001616998463/discount_codes/12231414743103.json

Example URL

 

Put

In the body section, enter this code, then click Send.

{
    "discount_code": {
        "Id":12231414743103,
        "code": "WINTERSALE10OFF"
    }
}

Response:

The API will return all information about the updated discount code.

{
    "discount_code": {
        "id": 12231414743103,
        "price_rule_id": 1001616998463,
        "code": "WINTERSALE10OFF",
        "usage_count": 0,
        "created_at": "2021-12-16T16:44:57+09:00",
        "updated_at": "2021-12-16T16:46:26+09:00"
    }
}

Response

Step 2: Verify the Updated Discount Code

In Admin, choose Discounts 

Result

As you can see, the discount code has been updated. 

Delete A Discount Code Using Postman In Shopify

Step 1: Delete A Discount Code Using Postman In Shopify

 

https://{username}:{password}@{shop}.myshopify.com/admin/api/{api-version}/{resource}.json

Or you can copy this example in the Shopify Admin, remember to change {resource} to {price_rules/price rule ID/discount_codes/discount code ID}:

https://33a72f01e02987636e1c1a9a4e95c840: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@hexasync.myshopify.com/admin/api/2021-10/price_rules/1001616998463/discount_codes/12231414743103.json

Example URL

 

Delete

Then Click SEND

Response:

An empty array

Step 2: Verify the Result

In Admin, choose Discounts 

Result

As you can see, the discount code has been deleted. 

I have shown you all steps to create, update and delete a discount code with Shopify API using Postman. If you have any questions, please leave a comment below or refer to our blog: What is an API?. Besides, you can see more Shopify API documentation in the developer docs.

If you still do not understand the tutorial’s content, you can watch the video below for a more overview.

YouTube video

Hopefully, you can do it!

Last updated: