1. Documentation /
  2. Smart Coupons /
  3. Smart Coupons REST API

Smart Coupons REST API

Smart Coupons REST API allows you to auto-generate a coupon via REST API. This is based on WooCommerce REST API.

Requirement

↑ Back to top

WooCommerce REST API

↑ Back to top

Since Smart Coupons REST API is based on WooCommerce REST API you’ll need WooCommerce REST API setup on your store. Along with this, Smart Coupons REST API also follows the same syntax & structure with some additional features which we are going to learn in this documentation.

Create a store credit

↑ Back to top

WooCommerce REST API allows you to create coupons via API but it requires a coupon code. If you’ll not pass the coupon code, WooCommerce REST API will not work for you. Here Smart Coupons REST API comes to the rescue. It doesn’t require a coupon code to generate a coupon via API.

Let’s see this with an example. In this example, we have used the tool Postman to send the API request.

HTTP request example

↑ Back to top

POST request: https://www.example.com/wp-json/wc/v3/sc/coupons

Authorization: consumer_key:consumer_secret

Smart Coupons REST API Request Header

Header: Content-Type: application/json

Body/Data:

{
    "discount_type": "smart_coupon",
    "amount": "100",
    "email_restrictions": "joe.smith@mailinator.com",
}

Smart Coupons REST API Request Data and Response

JSON response example

↑ Back to top
{
    "id": 3570,
    "code": "4v1g6gw18m",
    "amount": "100.00",
    "date_created": "2021-01-23T19:53:37",
    "date_created_gmt": "2021-01-23T14:23:37",
    "date_modified": "2021-01-23T19:53:37",
    "date_modified_gmt": "2021-01-23T14:23:37",
    "discount_type": "smart_coupon",
    "description": "",
    "date_expires": null,
    "date_expires_gmt": null,
    "usage_count": 0,
    "individual_use": false,
    "product_ids": [],
    "excluded_product_ids": [],
    "usage_limit": null,
    "usage_limit_per_user": null,
    "limit_usage_to_x_items": null,
    "free_shipping": false,
    "product_categories": [],
    "excluded_product_categories": [],
    "exclude_sale_items": false,
    "minimum_amount": "0.00",
    "maximum_amount": "0.00",
    "email_restrictions": [
        "joe.smith@mailinator.com"
    ],
    "used_by": [],
    "meta_data": [],
    "_links": {
        "self": [
            {
                "href": "https://www.example.com/wp-json/wc/v3/coupons/3570"
            }
        ],
        "collection": [
            {
                "href": "https://www.example.com/wp-json/wc/v3/coupons"
            }
        ]
    }
}

Coupon Properties

↑ Back to top

Smart Coupons REST API supports all the coupon properties of WooCommerce REST API. Additionally, it also provides the following coupon properties.

Attribute Type Description
sc_is_send_email string If set to yes the generated coupon will be sent via email to that email address which is set under email_restrictions. Options: yes, no. Default: no
sc_is_html string If set to yes the generated coupon’s HTML will be returned instead of coupon detail in JSON format. Options: yes, no. Default: no

WooCommerce

The most customizable ecommerce platform for building your online business.

  • 30-day money-back guarantee
  • Support teams across the world
  • Safe and secure online payment