1. Home
  2. Ecommerce Rest Api
  3. WordPress WooCommerce
  4. Coupons

Coupons

Prerequisites

  • WooCommerce API Keys: You need Consumer Key and Consumer Secret.
  • Base URL: Replace https://yourstore.com with your actual WooCommerce store URL.
  • Authorization: Basic Auth with your Consumer Key and Consumer Secret.

Authorization Setup in Postman

  1. Go to the Authorization tab.
  2. Select Type: Basic Auth.
  3. Username: Enter your Consumer Key.
  4. Password: Enter your Consumer Secret.

1. List Coupons

  • URL: https://yourstore.com/wp-json/wc/v3/coupons
  • Method: GET
  • Headers:
    • Authorization: Basic Auth

Example in Postman:

  1. Set method to GET.
  2. Enter URL: https://yourstore.com/wp-json/wc/v3/coupons
  3. Go to the Authorization tab and set Type to Basic Auth.
  4. Enter Consumer Key and Consumer Secret.
  5. Send the request.

2. Retrieve a Coupon

  • URL: https://yourstore.com/wp-json/wc/v3/coupons/{id}
  • Method: GET
  • Headers:
    • Authorization: Basic Auth
  • Replace {id} with the actual coupon ID.

Example in Postman:

  1. Set method to GET.
  2. Enter URL: https://yourstore.com/wp-json/wc/v3/coupons/{id}
  3. Go to the Authorization tab and set Type to Basic Auth.
  4. Enter Consumer Key and Consumer Secret.
  5. Send the request.

3. Create a Coupon

  • URL: https://yourstore.com/wp-json/wc/v3/coupons
  • Method: POST
  • Headers:
    • Authorization: Basic Auth
  • Body: JSON with coupon data.

Example JSON Body:

{
  "code": "SUMMER2024",
  "amount": "10",
  "discount_type": "percent",
  "description": "Summer Sale 2024 - 10% off",
  "usage_limit": 100,
  "individual_use": true
}

Example in Postman:

  1. Set method to POST.
  2. Enter URL: https://yourstore.com/wp-json/wc/v3/coupons
  3. Go to the Authorization tab and set Type to Basic Auth.
  4. Enter Consumer Key and Consumer Secret.
  5. Go to the Body tab, select raw, choose JSON from the dropdown, and paste the example JSON body.
  6. Send the request.

4. Update a Coupon

  • URL: https://yourstore.com/wp-json/wc/v3/coupons/{id}
  • Method: PUT
  • Headers:
    • Authorization: Basic Auth
  • Body: JSON with updated coupon data.
  • Replace {id} with the actual coupon ID.

Example JSON Body:

{
  "amount": "15",
  "discount_type": "fixed_cart",
  "description": "Updated discount amount to $15 off entire cart"
}

Example in Postman:

  1. Set method to PUT.
  2. Enter URL: https://yourstore.com/wp-json/wc/v3/coupons/{id}
  3. Go to the Authorization tab and set Type to Basic Auth.
  4. Enter Consumer Key and Consumer Secret.
  5. Go to the Body tab, select raw, choose JSON from the dropdown, and paste the example JSON body.
  6. Send the request.

5. Delete a Coupon

  • URL: https://yourstore.com/wp-json/wc/v3/coupons/{id}
  • Method: DELETE
  • Headers:
    • Authorization: Basic Auth
  • Replace {id} with the actual coupon ID.

Example in Postman:

  1. Set method to DELETE.
  2. Enter URL: https://yourstore.com/wp-json/wc/v3/coupons/{id}
  3. Go to the Authorization tab and set Type to Basic Auth.
  4. Enter Consumer Key and Consumer Secret.
  5. Send the request.

6. Batch Update Coupons

  • URL: https://yourstore.com/wp-json/wc/v3/coupons/batch
  • Method: POST
  • Headers:
    • Authorization: Basic Auth
  • Body: JSON with batch operations.

Example JSON Body:

{
  "update": [
    {
      "id": 1,
      "amount": "20",
      "discount_type": "percent",
      "description": "Updated discount to 20% off"
    },
    {
      "id": 2,
      "code": "SUMMER2025",
      "amount": "25",
      "discount_type": "percent",
      "description": "Summer Sale 2025 - 25% off"
    }
  ]
}

Example in Postman:

  1. Set method to POST.
  2. Enter URL: https://yourstore.com/wp-json/wc/v3/coupons/batch
  3. Go to the Authorization tab and set Type to Basic Auth.
  4. Enter Consumer Key and Consumer Secret.
  5. Go to the Body tab, select raw, choose JSON from the dropdown, and paste the example JSON body.
  6. Send the request.

By following these instructions, you can test each WooCommerce coupons endpoint in Postman. Each request should include the necessary Authorization header configured through Basic Auth with your Consumer Key and Consumer Secret. Adjust the {id} parameter with the actual coupon ID you intend to work with for retrieving, updating, or deleting operations.

How can we help?