You can use the Discount Code resource to create discount codes that enable specific discounts to be redeemed. Merchants can distribute discount codes to their customers using a variety of means, such as an email or URL, and customers can apply these codes at checkout.
Authenticated access scopes: com.read_discounts, com.write_discounts (Only used by the private app)
What you can do with Discount Code
The Haravan API lets you do the following with the Discount Code resource.
- GET https://apis.haravan.com/com/discounts.json Retrieves a list of enabling discount codes.
- GET https://apis.haravan.com/com/discounts/{discountId}.json Retrieves single the discount code.
- POST https://apis.haravan.com/com/discounts.json Create a discount code.
- PUT https://apis.haravan.com/com/discounts/{discountId}/enable.json Update status enables a discount code.
- PUT https://apis.haravan.com/com/discounts/{discountId}/disable.json Update status enables a discount code.
- DELETE https://apis.haravan.com/com/discounts/{discountId}.json Delete a discount code.
Discount Code properties
Endpoints
limit | Limit of the result. |
page | Page to show the result. |
since_id | Restrict results to after the specified ID |
code | Filter result by the code. |
Retrieves a list of enabling discount codes by page number. By default, the number of resources on the page is 50.
GET https://apis.haravan.com/com/discounts.json?page=1
HTTP/1.1 200 OK { "discounts": [ { "applies_once": false, "applies_to_id": 39550382, "code": "TEST GROUP", "ends_at": null, "id": 1017981560, "minimum_order_amount": 0.0, "starts_at": "2021-07-28T10:12:00Z", "status": "enabled", "usage_limit": 1, "value": 10.0000, "discount_type": "percentage", "times_used": 0, "is_promotion": true, "applies_to_resource": "group_customer", "variants": [], "location_ids": [], "create_user": 200000493247, "first_name": "Trọng", "last_name": "Nhân Lê", "applies_customer_group_id": null, "created_at": "2021-07-28T10:13:35.639Z", "updated_at": "2021-07-28T10:13:35.643Z", "promotion_apply_type": 0, "applies_to_quantity": 0, "order_over": null, "is_new_coupon": false, "channel": null, "max_amount_apply": null, "is_advance_same_price_discount": false, "advance_same_prices": [] }, { "applies_once": false, "applies_to_id": null, "code": "EQWEQWEQWEQWEQWEWEWEQEQWEQWEQWEQWEQWEQWEQWE", "ends_at": null, "id": 1017969576, "minimum_order_amount": 0.0, "starts_at": "2021-07-27T05:49:00Z", "status": "enabled", "usage_limit": 1, "value": 10.0000, "discount_type": "fixed_amount", "times_used": 0, "is_promotion": true, "applies_to_resource": null, "variants": [], "location_ids": [], "create_user": 200000493247, "first_name": "Trọng", "last_name": "Nhân Lê", "applies_customer_group_id": null, "created_at": "2021-07-27T05:49:28.333Z", "updated_at": "2021-07-27T05:49:28.333Z", "promotion_apply_type": 0, "applies_to_quantity": 0, "order_over": null, "is_new_coupon": false, "channel": null, "max_amount_apply": null, "is_advance_same_price_discount": false, "advance_same_prices": [] } ] }
Retrieves a list of enable discount codes by code.
GET https://apis.haravan.com/com/discounts.json?code=GARMIN55
HTTP/1.1 200 OK { "discounts": [ { "applies_once": false, "applies_to_id": null, "code": "GARMIN55", "ends_at": null, "id": 1016875801, "minimum_order_amount": 0.0, "starts_at": "2021-06-22T04:16:00Z", "status": "enabled", "usage_limit": null, "value": 5.0000, "discount_type": "percentage", "times_used": 1, "is_promotion": true, "applies_to_resource": null, "variants": [], "location_ids": [], "create_user": 200000493247, "first_name": "Trọng", "last_name": "Nhân Lê", "applies_customer_group_id": 39550382, "created_at": "2021-06-22T04:17:56.847Z", "updated_at": "2021-06-22T04:17:56.847Z", "promotion_apply_type": 0, "applies_to_quantity": 0, "order_over": null, "is_new_coupon": false, "channel": null, "max_amount_apply": null, "is_advance_same_price_discount": false, "advance_same_prices": [] } ] }
Retrieves single the discount code.
GET https://apis.haravan.com/com/discounts/1016875801.json
HTTP/1.1 200 OK{"discount": {"applies_once": false,"applies_to_id": null,"code": "GARMIN55","ends_at": null,"id": 1016875801,"minimum_order_amount": 0.0,"starts_at": "2021-06-22T04:16:00Z","status": "enabled","usage_limit": 0,"value": 5.0000,"discount_type": "percentage","times_used": 1,"is_promotion": true,"applies_to_resource": null,"variants": null,"location_ids": null,"create_user": 200000493247,"first_name": "Trọng","last_name": "Nhân Lê","applies_customer_group_id": 39550382,"created_at": "2021-06-22T04:17:56.847Z","updated_at": "2021-06-22T04:17:56.847Z","promotion_apply_type": 0,"applies_to_quantity": 0,"order_over": null,"is_new_coupon": false,"channel": null,"max_amount_apply": null,"is_advance_same_price_discount": false,"advance_same_prices": null}}
Create a discount code.
POST https://apis.haravan.com/com/discounts.json
{"discount": {"is_promotion": true,"applies_to_resource": null,"applies_to_id": null,"applies_once": false,"code": "SUMMER_28/07","ends_at": null,"minimum_order_amount": 0,"starts_at": "2021-07-28T10:53:00Z","usage_limit": 10,"value": 100000,"discount_type": "fixed_amount","variants": [{"product_id": 1028183633,"variant_id": 1061514625},{"product_id": 1028183633,"variant_id": 1061514629}],"set_time_active": true,"applies_customer_group_id": "39550400","location_ids": [1007284]}}
HTTP/1.1 200 OK { "discount": { "applies_once": false, "applies_to_id": null, "code": "GARMIN55", "ends_at": null, "id": 1016875801, "minimum_order_amount": 0.0, "starts_at": "2021-06-22T04:16:00Z", "status": "enabled", "usage_limit": 0, "value": 5.0000, "discount_type": "percentage", "times_used": 1, "is_promotion": true, "applies_to_resource": null, "variants": null, "location_ids": null, "create_user": 200000493247, "first_name": "Trọng", "last_name": "Nhân Lê", "applies_customer_group_id": 39550382, "created_at": "2021-06-22T04:17:56.847Z", "updated_at": "2021-06-22T04:17:56.847Z", "promotion_apply_type": 0, "applies_to_quantity": 0, "order_over": null, "is_new_coupon": false, "channel": null, "max_amount_apply": null, "is_advance_same_price_discount": false, "advance_same_prices": null } }
Update status enable a discount code.
Update status enable a discount code.
PUT https://apis.haravan.com/com/discounts/1017981791/enable.json
{}
HTTP/1.1 200 OK { "discount": { "applies_once": false, "applies_to_id": null, "code": "SUMMER_28/07", "ends_at": null, "id": 1017981791, "minimum_order_amount": 0.0, "starts_at": "2021-07-28T03:53:00Z", "status": "disabled", "usage_limit": 10, "value": 100000.0000, "discount_type": "fixed_amount", "times_used": 0, "is_promotion": true, "applies_to_resource": null, "variants": null, "location_ids": [ 1007284 ], "create_user": 200000497867, "first_name": null, "last_name": null, "applies_customer_group_id": 39550400, "created_at": "2021-07-28T11:27:34.029Z", "updated_at": "2021-07-28T11:34:45.9148559Z", "promotion_apply_type": 0, "applies_to_quantity": 0, "order_over": null, "is_new_coupon": false, "channel": null, "max_amount_apply": null, "is_advance_same_price_discount": false, "advance_same_prices": null } }
Update status disables a discount code.
Update status disables a discount code.
PUT https://apis.haravan.com/com/discounts/1017981791/disable.json
{}
HTTP/1.1 200 OK { "discount": { "applies_once": false, "applies_to_id": null, "code": "SUMMER_28/07", "ends_at": null, "id": 1017981791, "minimum_order_amount": 0.0, "starts_at": "2021-07-28T03:53:00Z", "status": "disabled", "usage_limit": 10, "value": 100000.0000, "discount_type": "fixed_amount", "times_used": 0, "is_promotion": true, "applies_to_resource": null, "variants": null, "location_ids": [ 1007284 ], "create_user": 200000497867, "first_name": null, "last_name": null, "applies_customer_group_id": 39550400, "created_at": "2021-07-28T11:27:34.029Z", "updated_at": "2021-07-28T11:34:45.9148559Z", "promotion_apply_type": 0, "applies_to_quantity": 0, "order_over": null, "is_new_coupon": false, "channel": null, "max_amount_apply": null, "is_advance_same_price_discount": false, "advance_same_prices": null } }
Delete a discount code.
DELETE https://apis.haravan.com/com/discounts/1017981791.json
{}
HTTP/1.1 200 OK {}