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)

Promotion properties

name

"name": "Happy new year"

Name of the promotion.

ends_at

"ends_at": "2022-08-11T09:35:59Z"

The date and time (ISO 8601 format) when the promotion was expired.

id

"id": 1206854680

A unique identifier for the promotion.

starts_at

"starts_at": "2021-05-13T07:29:20.1Z"

The date and time (ISO 8601 format) when the promotion was applied.

value

"value ": 150000

Promotion value.
If promtion_type is "shipping". The value will be the shipping fee. It must be limited to how much shipping charges apply.

discount_type

"discount_type": "fixed_amount"

fixed_amount: Applies a discount of value as a unit of the store's currency.
percentage: Applies a percentage discount of value.
shipping: Free shipping.

applies_to_resource

"applies_to_resource":"product "

null: Apply to all orders.
product: Apply to the product.
collection: Apply to the collection.
product_variant: Apply to product variants.

applies_to_quantity

"applies_to_resource":0

Minimum quantity of items to be applied promotion.

applies_to_id

"applies_to_id":0

The ID of the product to be applied promotion.

order_over

"order_over":100000

Minimum purchase amount to be applied promotion.

promotion_apply_type

"promotion_apply_type":1

1: Minimum quantity of items.

2: Minimum purchase amount.

variants

"variants": [

    {

        "product_id"1028183633,

        "variant_id"1061514629

    },

    {

        "product_id"1028183633,

        "variant_id"1061514630

    }

]

Array to product ids and variant id objects to which the promotion will be applied.

created_at

"created_at": "2021-05-13T07:29:20.1Z"

The date and time (ISO 8601 format) when the promotion was created.

updated_at

"updated_at": "2021-05-13T07:29:20.808Z"

The date and time (ISO 8601 format) when the promotion was last updated.

first_name

"first_name":"John"

The first name of the user created the promotion.

last_name

"last_name":"Smit"

The last name of the user created the promotion.

create_user

"create_user":200000493247

The ID of the user-created the promotion.

status

"status":"enabled"

Status of the promotion. Values are valid:

enabled: The promotion is active.
disabled: The promotion is disabled.

Endpoints

GET https://apis.haravan.com/com/promotions.json

Retrieves a list of enabling discount codes.

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

View response

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

View response

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
                }
            ]
        }
}

View response

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.

PUT https://apis.haravan.com/com/discounts/1024177200/enable.json

{}

View response

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.

PUT https://apis.haravan.com/com/discounts/1017981791/disable.json

{}

View response

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

{}

View response

HTTP/1.1 200 OK
{}