Skip to content

Variant Coupon

As the name suggests, this coupon can only be applied on a certain variant if they are present in a cart / order.

Variant Coupon Object

Below is the json representation of the Variant Coupon object, followed by a data table

Variant Coupon Object
{
  "id": "46bfd3e7-5392-4d4a-85cb-816cb7029e82",
  "code": "PREVpqZKi",
  "status": "active",
  "starts_at": "2023-05-22T10:39:47.780Z",
  "ends_at": "2023-05-22T10:49:47.780Z",
  "max_count": 3,
  "used_count": 0,
  "min_cart_value": null,
  "discount_type": "flat",
  "discount_value": 500,
  "variant_id": "c8c4bebe-873d-4249-84e7-6f9dacc4c0f7",
  "coupon_campaign_id": "c8c4bebe-873d-4249-84e7-6f9dacc4c0f1",
  "extradata": null,
  "created_at": "2023-05-22T10:39:47.784Z",
  "updated_at": "2023-05-22T10:39:47.792Z",
  "account_id": "b303a002-899c-40d5-9897-d5bf62a5486f"
}

All Fields

Field Data Type Description
id string UUID of the Variant Coupon.
code string The value that the customer enters for availing the coupon. Automatically generated as a combination of the associated CouponCampaign's prefix and 6 random alphanumeric characters.
status string Represents the current status of the coupon.
starts_at string UTC timestamp that represents the time at which the Coupon can be active & be ready to be used.
ends_at string UTC timestamp that represents the time at which the Coupon will cease to be active & hence can't be used no more.
max_count integer Number of times this coupon can be used.
used_count integer Represents the number of times this coupon has been used so far. Once this becomes equal to max_count, the coupon can't be used anymore.
min_cart_value integer Irrelevant for Variant Coupon. Check Cart Coupon description.
dicount_type string The type of discount this coupon offers. Should be either percentage or flat.
discount_value string The value of discount this coupon offers. Will be calculated based on discount_type.
variant_id string UUID of the variant that this coupon belongs to, and hence can be applied on.
coupon_campaign_id string UUID of the associated Coupon Campaign. See coupon campaign page for more details.
extradata object NA
created_at string UTC timestamp at which the Coupon was created.
updated_at string UTC timestamp at which the Coupon was last updated.
account_id string UUID of the account. See accounts page for more details.

Status State Machine

The status field represents whether or not a coupon is currently active and hence whether or not the customers are able to avail it. The initial state is inactive during which a coupon can't be used and an active state represents a coupon that can be used. As the name itself suggests, the time_expired & count_expired statuses represents coupons that have their ends_at past and their used_count having reached their max_count respectively.

Possible values: inactive, active, time_expired and count_expired. Below diagram shows possible transitions on the Variant Coupon status.

graph LR
  A[inactive] --> |activate| B[active];
  B --> |deactivate| A;
  B --> |expire_time| C[time_expired];
  B --> |expire_count| D[count_expired];
  C --> |activate| B;
  D --> |activate| B;
  A --> |reconcile_count_status| D;
  D --> |reconcile_count_status| B;
  A --> |reconcile_count_status| A;
  D --> |reconcile_count_status| D;
  B --> |reconcile_count_status| B;
  C --> |extend_expiry_and_activate| B;
  B --> |extend_expiry_and_activate| B;
  A --> |extend_expiry_and_activate| B;
  A --> |extend_expiry_and_activate| D;
  D --> |extend_expiry_and_activate| D;

API

List Coupons

GET /api/platform/v1/coupon_campaigns/{coupon_campaign_id}/coupons

Returns a list of Coupons associated with the CouponCampaign defined by coupon_campaign_id.

Query Params

TODO

curl command

TODO

Response Body

TODO

Create Coupon

POST /api/platform/v1/coupon_campaigns/{coupon_campaign_id}/coupons

Creates a Coupon of either Cart or Variant type under the CouponCampaign defined by coupon_campaign_id.

Request Body

TODO

curl command

TODO

Response Body

TODO

Get Coupon

GET /api/platform/v1/coupon_campaigns/{coupon_campaign_id}/coupons/{id}

Fetches the Coupon identified by id, that is under the CouponCampaign defined by coupon_campaign_id.

curl command

TODO

Response Body

TODO

Update Coupon

PATCH /api/platform/v1/coupon_campaigns/{coupon_campaign_id}/coupons/{id}

Updates the Coupon identified by id, that is under the CouponCampaign defined by coupon_campaign_id. Use the /transition endpoint for updating status.

Request Body

TODO

curl command

TODO

Response Body

TODO

Delete Coupon

DELETE /api/platform/v1/coupon_campaigns/{coupon_campaign_id}/coupons/{id}

Deletes the Coupon identified by id, that is under the CouponCampaign defined by coupon_campaign_id.

curl command

TODO

Response Body

TODO

Transition Coupon Status

POST /api/platform/v1/coupon_campaigns/{coupon_campaign_id}/coupons/{id}

Transitions the Coupon identified by id, that is under the CouponCampaign defined by coupon_campaign_id, into states defined in the state machine.

Request Body

TODO

curl command

TODO

Response Body

TODO