Smart Coupons REST API allows you to auto-generate a coupon via REST API. This is based on WooCommerce REST API.
Requirement
↑ Back to topWooCommerce REST API
↑ Back to topCreate a store credit
↑ Back to topHTTP request example
↑ Back to tophttps://www.example.com/wp-json/wc/v3/sc/coupons
Authorization: consumer_key:consumer_secret
Header: Content-Type: application/json
Body/Data:
{ "discount_type": "smart_coupon", "amount": "100", "email_restrictions": "joe.smith@mailinator.com", }
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 topAttribute | 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 |