You can use the Promotion resource to create a promotion.
Authenticated access scopes: com.read_discounts, com.write_discounts (Only used by the private app)
What you can do with Promotion
The Haravan API lets you do the following with the Promotion resource.
- GET https://apis.haravan.com/com/promotions.json Retrieves a list of enabling promotions.
- GET https://apis.haravan.com/com/promotions/{promotion_id}.json Retrieves single the promotion.
- POST https://apis.haravan.com/com/promotions.json Create a promotion.
- PUT https://apis.haravan.com/com/discounts/{promotion_id}/enable.json Update status enable a promotion.
- PUT https://apis.haravan.com/com/discounts/{promotion_id}/disable.json Update status disable a promotion.
- DELETE https://apis.haravan.com/com/promotions/{promotion_id}.json Delete a promotion.
Promotion 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/promotions.json?page=1
HTTP/1.1 200 OK { "promotions": [ { "name": "Happy new year", "ends_at": "2022-03-04T16:59:59Z", "id": 1024173229, "starts_at": "2022-03-04T03:54:00Z", "value": 10000.0000, "discount_type": "fixed_amount", "applies_to_resource": "product_variant", "applies_to_quantity": 0, "applies_to_id": 0, "set_time_active": false, "order_over": 1000000, "promotion_apply_type": 2, "variants": [ { "product_id": 1028183633, "variant_id": 1061514629 }, { "product_id": 1028183633, "variant_id": 1061514630 } ], "created_at": "2022-03-04T03:56:37.215Z", "updated_at": "2022-03-04T03:56:37.215Z", "first_name": null, "last_name": null, "create_user": 200000493247, "applies_customer_group_id": null, "status": "enabled" }, { "name": "Vallentine", "ends_at": "2022-08-11T09:35:59Z", "id": 1022775866, "starts_at": "2021-08-11T08:35:00Z", "value": 10.0000, "discount_type": "percentage", "applies_to_resource": "product", "applies_to_quantity": 1, "applies_to_id": 1028183633, "set_time_active": false, "order_over": null, "promotion_apply_type": 1, "variants": [], "created_at": "2022-01-25T12:07:59.374Z", "updated_at": "2022-01-25T12:07:59.374Z", "first_name": null, "last_name": null, "create_user": 200000497867, "applies_customer_group_id": null, "status": "enabled" } ] }
Retrieves single the discount code.
GET https://apis.haravan.com/com/promotions/1024173229.json
HTTP/1.1 200 OK { "promotion": { "name": "Happy new year", "ends_at": "2022-03-04T16:59:59Z", "id": 1024173229, "starts_at": "2022-03-04T03:54:00Z", "value": 10000.0000, "discount_type": "fixed_amount", "applies_to_resource": "product_variant", "applies_to_quantity": 0, "applies_to_id": 0, "set_time_active": false, "order_over": 1000000, "promotion_apply_type": 2, "variants": [ { "product_id": 1028183633, "variant_id": 1061514629 }, { "product_id": 1028183633, "variant_id": 1061514630 } ], "created_at": "2022-03-04T03:56:37.215Z", "updated_at": "2022-03-04T03:56:37.215Z", "first_name": null, "last_name": null, "create_user": 200000493247, "applies_customer_group_id": null, "status": "enabled" } }
Create a promotion.
POST https://apis.haravan.com/com/promotions.json
{ "promotion": { "name": "Happy new year", "ends_at": "2022-03-04T16:59:59Z", "id": 1024173229, "starts_at": "2022-03-04T03:54:00Z", "value": 10000.0000, "discount_type": "fixed_amount", "applies_to_resource": "product_variant", "applies_to_quantity": 0, "applies_to_id": 0, "order_over": 1000000, "promotion_apply_type": 2, "variants": [ { "product_id": 1028183633, "variant_id": 1061514629 }, { "product_id": 1028183633, "variant_id": 1061514630 } ] } }
HTTP/1.1 200 OK { "promotion": { "name": "Happy new year", "ends_at": "2022-03-04T16:59:59Z", "id": 1024177200, "starts_at": "2022-03-03T17:00:00Z", "value": 10000.0, "discount_type": "fixed_amount", "applies_to_resource": "product_variant", "applies_to_quantity": 0, "applies_to_id": 0, "order_over": 1000000, "promotion_apply_type": 2, "variants": [ { "product_id": 1028183633, "variant_id": 1061514629 }, { "product_id": 1028183633, "variant_id": 1061514630 } ], "created_at": "2022-03-04T07:58:40.7724222Z", "updated_at": "2022-03-04T07:58:40.7724287Z", "first_name": null, "last_name": null, "create_user": 200000497867, "applies_customer_group_id": null, "status": "enabled" } }
Update status enable a promotion.
Update status enable a promotion.
PUT https://apis.haravan.com/com/discounts/1024177200/enable.json
{}
HTTP/1.1 200 OK { "discount": { "applies_once": false, "applies_to_id": null, "code": "Happy new year", "ends_at": "2022-03-04T16:59:59Z", "id": 1024177200, "minimum_order_amount": 1000000.0, "starts_at": "2022-03-03T17:00:00Z", "status": "enabled", "usage_limit": 0, "value": 10000.0000, "discount_type": "fixed_amount", "times_used": 0, "is_promotion": false, "applies_to_resource": "product_variant", "variants": [ { "product_id": 1028183633, "variant_id": 1061514629 }, { "product_id": 1028183633, "variant_id": 1061514630 } ], "location_ids": null, "create_user": 200000497867, "first_name": null, "last_name": null, "applies_customer_group_id": null, "created_at": "2022-03-04T07:58:40.772Z", "updated_at": "2022-03-04T08:04:57.1469947Z", "promotion_apply_type": 2, "applies_to_quantity": 0, "order_over": 1000000, "is_new_coupon": true, "channel": null, "max_amount_apply": null, "is_advance_same_price_discount": false, "advance_same_prices": null, "once_per_customer": false } }
Update status disables a promotion.
Update status disables a promotion.
PUT https://apis.haravan.com/com/discounts/1017981791/disable.json
{}
HTTP/1.1 200 OK { "discount": { "applies_once": false, "applies_to_id": null, "code": "Happy new year", "ends_at": "2022-03-04T16:59:59Z", "id": 1024177200, "minimum_order_amount": 1000000.0, "starts_at": "2022-03-03T17:00:00Z", "status": "disabled", "usage_limit": 0, "value": 10000.0000, "discount_type": "fixed_amount", "times_used": 0, "is_promotion": false, "applies_to_resource": "product_variant", "variants": [ { "product_id": 1028183633, "variant_id": 1061514629 }, { "product_id": 1028183633, "variant_id": 1061514630 } ], "location_ids": null, "create_user": 200000497867, "first_name": null, "last_name": null, "applies_customer_group_id": null, "created_at": "2022-03-04T07:58:40.772Z", "updated_at": "2022-03-04T08:06:28.493101Z", "promotion_apply_type": 2, "applies_to_quantity": 0, "order_over": 1000000, "is_new_coupon": true, "channel": null, "max_amount_apply": null, "is_advance_same_price_discount": false, "advance_same_prices": null, "once_per_customer": false } }
Delete a promotion.
DELETE https://apis.haravan.com/com/promotions/1024177200.json
{}
HTTP/1.1 200 OK {}