Core Resources
Discounts
Discounts can be applied to a
Often discounts can be used in combination with webhooks, such that when a specific event occurs, it can apply a discount dependent on custom business logic.
There are various options that can be utilized for discounts such as minimum price, single use, recurring for a set number of charges, or ongoing. You can also set the date from which time the discount will become applicable and when it can no longer be applied to a new subscription.
Checkout, or can be applied directly to an Address. Depending on configuration they allow for single use, or recurring discounts. More details on how to add or remove discounts from an Address can be found at Update an address.Often discounts can be used in combination with webhooks, such that when a specific event occurs, it can apply a discount dependent on custom business logic.
There are various options that can be utilized for discounts such as minimum price, single use, recurring for a set number of charges, or ongoing. You can also set the date from which time the discount will become applicable and when it can no longer be applied to a new subscription.
24 additions in V2, marked New
Everything marked New also works when you send X-Recharge-Version: 2021-11.
#The discount object
Attributes
- idintegerUnique numeric identifier for the discount in Recharge.
- How the discount is applied.
codediscounts are applied with a discount code andautomaticdiscounts are applied without one.Possible valuescodeautomatic - applies_toobjectAn object encompassing data that limits discount application on the basis of an associated record (such as customer, products, etc.).
Show child attributesHide child attributes3
- idsarrayA list of ids of the type indicated in applies_to.resource for which the discount can be applied. Currently only supports a list with one value.
- purchase_item_typestringAn indicator of whether the discount applies to onetimes, subscriptions, or all purchase item types.Possible values
ALLONETIMESUBSCRIPTION - resourcestringAn indicator of the type of resource to which applies_to_id refers.Possible values
shopify_productshopify_collection_idcollection_id
- Whether the discount applies to addresses that already exist. Can only be
falseforautomaticdiscounts. - channel_settingsobjectA list of channel objects containing information regarding discount behaviors for each.
If you're on the SCI Platform, checkout channel will not apply during Shopify checkouts.Show child attributesHide child attributes4
- apiobjectAn object containing api channel settings.
Show child attributesHide child attributes1
- can_applybooleanA boolean to indicate if the discount may be applied using the associated channel (defaults to true for all channels).
- customer_portalobjectAn object containing customer portal channel settings.
Show child attributesHide child attributes1
- can_applybooleanA boolean to indicate if the discount may be applied using the associated channel (defaults to true for all channels).
- merchant_portalobjectAn object containing merchant portal channel settings.
Show child attributesHide child attributes1
- can_applybooleanA boolean to indicate if the discount may be applied using the associated channel (defaults to true for all channels).
- checkout_pageobjectAn object containing checkout channel settings.
Show child attributesHide child attributes1
- can_applybooleanA boolean to indicate if the discount may be applied using the associated channel (defaults to true for all channels).
- codestringThe code used to apply the discount.
- A list of the customer segments linked to the discount. Empty when the discount is not linked to any customer segment.
Show child attributesHide child attributes11 new
- Unique numeric identifier for the customer segment.
- The external platform that the
external_discount_idbelongs to.Possible valuesbig_commerceshopifyrechargeheadlessmagento - The title of the discount. For
automaticdiscounts the title is also returned as thecode. - created_atdatetimeThe date and time when the discount was created.
- ends_atdatetimeThe expiration timestamp of the discount. Past this time the
Discountcan no longer be redeemed. Afterends_atthestatusof theDiscountwill go fromactivetodisabled.Recurring discounts applied prior to theirends_attime will still apply. - external_discount_idobjectAn object containing external ids of the discount.
Show child attributesHide child attributes1
- ecommercestringThe discount id as it appears in the external e-commerce platform.
- The minimum cart subtotal needed for the discount to be applicable.
- starts_atdatetimeThe date when the discount becomes active.When not specified on creation
starts_atwill default tonullwhich translates into no restrictions. - statusstringThe status of the discount. Value can be:
*enableddiscount is active to be applied
*disableddiscount can’t be applied on new purchases. Discount will remain on existing charges to which it has already been applied.
*fully_disableddiscount can no longer be applied. In addition,Discountis removed from every queued charge.Possible valuesenableddisabledfully_disableddisabledandfully_disabledcan both be reverted toenabled. However once aDiscounthas been updated tofully_disabledit will be removed from allChargesit had been applied to. This removal fromChargesis irreversible. - usage_limitsobjectAn object containing limitations on a discount based on usage_counts results
Show child attributesHide child attributes51 new
- one_application_per_customerbooleanThe discount can only be used once for a given customer checkout or manually applied once on the customer portal (irrespective of which address). Once applied, it will continue being re-applied to each new charge on the address.
- Discount can be used on checkout for customer that still don’t exist in Recharge database.
- max_subsequent_redemptionsintegerThe number of
ChargestheDiscountwill apply to besides the initial redemption for a givenCustomer. For example, if you want a discount to apply for 5 consecutive chargesmax_subsequent_redemptionsshould be 4. - redemptionsintegerSets the limit on the number of times a discount can be used by all customers. Only returned for stores that have legacy discount usage limits enabled.Only returned for stores that have legacy discount usage limits enabled.
- The total number of
ChargestheDiscountapplies to for a givenCustomer.0means the discount is single use andnullmeans it applies to all future charges.
- updated_atdatetimeThe date and time when the discount was last updated.
- valuestringThe discounted value to be applied.
- value_typestringType of discount mechanic.Possible values
fixed_amountpercentageshipping
{
"discount": {
"application_method": "code",
"applies_to": {
"ids": [],
"purchase_item_type": "ALL",
"resource": null
},
"applies_to_existing_addresses": true,
"channel_settings": {
"api": {
"can_apply": true
},
"checkout_page": {
"can_apply": true
},
"customer_portal": {
"can_apply": true
},
"merchant_portal": {
"can_apply": true
}
},
"code": "TEST_DISCOUNT",
"created_at": "2021-04-01T16:13:53+00:00",
"customer_segments": [],
"ends_at": null,
"external_discount_id": {
"ecommerce": "1642443555555"
},
"external_discount_source": null,
"id": 25463058,
"prerequisite_subtotal_min": null,
"starts_at": null,
"status": "enabled",
"title": null,
"updated_at": "2021-04-13T22:24:59+00:00",
"usage_limits": {
"first_time_customer_restriction": false,
"max_subsequent_redemptions": null,
"one_application_per_customer": false,
"automatic_redemptions_per_customer": null
},
"value": "20.00",
"value_type": "percent"
}
}#Create a discount
POST/discounts
Create a new discount.
Scope
write_discountsBody parameters
- applies_toobjectAn object encompassing data that limits discount application on the basis of an associated record (such as customer, products, etc.)
Show child attributesHide child attributes3
- idsarrayA list of ids of the type indicated in applies_to.resource for which the discount can be applied. Currently only supports a list with one value.
- purchase_item_typestringAn indicator of whether the discount applies to onetimes, subscriptions, or all purchase item types.Possible values
ALLONETIMESUBSCRIPTION - resourcestringAn indicator of the type of resource to which applies_to_id refers.Possible values
shopify_productshopify_collection_idcollection_id
- channel_settingsobjectA list of channel objects containing information regarding discount behaviors for each.
* can_apply: a boolean to indicate if the discount may be applied using the associated channel (defaults to true for all channels).Show child attributesHide child attributes4
- apiobjectAn object containing api channel settings.
Show child attributesHide child attributes1
- can_applybooleanA boolean to indicate if the discount may be applied using the associated channel (defaults to true for all channels).
- customer_portalobjectAn object containing customer portal channel settings.
Show child attributesHide child attributes1
- can_applybooleanA boolean to indicate if the discount may be applied using the associated channel (defaults to true for all channels).
- merchant_portalobjectAn object containing merchant portal channel settings.
Show child attributesHide child attributes1
- can_applybooleanA boolean to indicate if the discount may be applied using the associated channel (defaults to true for all channels).
- checkout_pageobjectAn object containing checkout channel settings.
Show child attributesHide child attributes1
- can_applybooleanA boolean to indicate if the discount may be applied using the associated channel (defaults to true for all channels).
- The code used to apply the discount.
- ends_atdatetimeThe expiration timestamp of the discount. Past this time the
Discountcan no longer be redeemed. Afterends_atthestatusof theDiscountwill go fromactivetodisabled.Recurring discounts applied prior to theirends_attime will still apply. - An object containing external ids of the discount.
Show child attributesHide child attributes11 new
- The discount id as it appears in the external e-commerce platform. Maximum 188 characters.
- The external platform that the
external_discount_idbelongs to. The combination ofexternal_discount_sourceandexternal_discount_idmust be unique.Possible valuesbig_commerceshopifyrechargeheadlessmagento - The minimum cart subtotal needed for the discount to be applicable.
- starts_atdatetimeThe date when the discount becomes
ACTIVE.When not specified on creationstarts_atwill default tonullwhich translates into no restrictions. - statusstringThe status of the discount.Possible values
enableddisabled - The title of the discount. Maximum 255 characters.
- usage_limitsobjectSets the limit on the number of times a discount can be used by all customers.
Show child attributesHide child attributes51 new
- one_application_per_customerbooleanThe discount can only be used once for a given customer checkout or manually applied once on the customer portal (irrespective of which address). Once applied, it will continue being re-applied to each new charge on the address.
- Discount can be used on checkout for customer that still don’t exist in Recharge database.
- max_subsequent_redemptionsintegerThe number of
ChargestheDiscountwill apply to besides the initial redemption for a givenCustomer. For example, if you want a discount to apply for 5 consecutive chargesmax_subsequent_redemptionsshould be 4. - redemptionsintegerSets the limit on the number of times a discount can be used by all customers. Only accepted for stores that have legacy discount usage limits enabled; otherwise the value is ignored.Only accepted for stores that have legacy discount usage limits enabled.The
redemptionsis not enabled by default. Contact us to enable support for this attribute. - The total number of
ChargestheDiscountapplies to for a givenCustomer.0or1makes the discount single use andnullapplies it to all future charges. Ignored whenmax_subsequent_redemptionsis also passed.
- The discounted value to be applied.
- The discount type.Possible values
fixed_amountpercentageshipping
curl -X POST 'https://api.rechargeapps.com/discounts' \
-H 'Content-Type: application/json' \
-H 'X-Recharge-Version: v2' \
-H 'X-Recharge-Access-Token: your_api_token' \
-d '{
"applies_to": {
"purchase_item_type": "ALL"
},
"channel_settings": {
"api": {
"can_apply": true
},
"checkout_page": {
"can_apply": true
},
"customer_portal": {
"can_apply": true
},
"merchant_portal": {
"can_apply": true
}
},
"code": "Discount1",
"status": "enabled",
"usage_limits": {
"first_time_customer_restriction": false,
"one_application_per_customer": false
},
"value": "100.00",
"value_type": "percentage"
}'{
"discount": {
"id": 59568555,
"application_method": "code",
"applies_to": {
"ids": [],
"purchase_item_type": "ALL",
"resource": null
},
"applies_to_existing_addresses": true,
"channel_settings": {
"api": {
"can_apply": true
},
"checkout_page": {
"can_apply": true
},
"customer_portal": {
"can_apply": true
},
"merchant_portal": {
"can_apply": true
}
},
"code": "Discount1",
"created_at": "2021-07-26T19:16:17+00:00",
"customer_segments": [],
"ends_at": null,
"external_discount_id": {
"ecommerce": null
},
"external_discount_source": null,
"prerequisite_subtotal_min": null,
"starts_at": null,
"status": "enabled",
"title": null,
"updated_at": "2021-07-26T19:16:17+00:00",
"usage_limits": {
"first_time_customer_restriction": false,
"max_subsequent_redemptions": null,
"one_application_per_customer": false,
"automatic_redemptions_per_customer": null
},
"value": "100.00",
"value_type": "percentage"
}
}curl 'https://api.rechargeapps.com/discounts/1234567' \
-H 'X-Recharge-Version: v2' \
-H 'X-Recharge-Access-Token: your_api_token'{
"discount": {
"id": 59568555,
"application_method": "code",
"applies_to": {
"ids": [],
"purchase_item_type": "ALL",
"resource": null
},
"applies_to_existing_addresses": true,
"channel_settings": {
"api": {
"can_apply": true
},
"checkout_page": {
"can_apply": true
},
"customer_portal": {
"can_apply": true
},
"merchant_portal": {
"can_apply": true
}
},
"code": "Discount1",
"created_at": "2021-07-26T19:16:17+00:00",
"customer_segments": [],
"ends_at": null,
"external_discount_id": {
"ecommerce": null
},
"external_discount_source": null,
"prerequisite_subtotal_min": null,
"starts_at": null,
"status": "enabled",
"title": null,
"updated_at": "2021-07-26T19:16:17+00:00",
"usage_limits": {
"first_time_customer_restriction": false,
"max_subsequent_redemptions": null,
"one_application_per_customer": false,
"automatic_redemptions_per_customer": null
},
"value": "100.00",
"value_type": "percentage"
}
}#Update a discount
PUT/discounts/{id}
You can modify an existing discount to match the specified parameters.
Scope
write_discountsOnce a discount has been used, only
channel_settings, ends_at, external_discount_id, external_discount_source, status and usage_limits can be updated; other fields in the request are ignored.Body parameters
- applies_toobjectAn object encompassing data that limits discount application on the basis of an associated record (such as customer, products, etc.)
Show child attributesHide child attributes3
- idsarrayA list of ids of the type indicated in applies_to.resource for which the discount can be applied. Currently only supports a list with one value.
- purchase_item_typestringAn indicator of whether the discount applies to onetimes, subscriptions, or all purchase item types.Possible values
ALLONETIMESUBSCRIPTION - resourcestringAn indicator of the type of resource to which applies_to_id refers.Possible values
shopify_productshopify_collection_idcollection_id
- channel_settingsobjectA list of channel objects containing information regarding discount behaviors for each.
* can_apply: a boolean to indicate if the discount may be applied using the associated channel (defaults to true for all channels).Show child attributesHide child attributes4
- apiobjectAn object containing api channel settings.
Show child attributesHide child attributes1
- can_applybooleanA boolean to indicate if the discount may be applied using the associated channel (defaults to true for all channels).
- customer_portalobjectAn object containing customer portal channel settings.
Show child attributesHide child attributes1
- can_applybooleanA boolean to indicate if the discount may be applied using the associated channel (defaults to true for all channels).
- merchant_portalobjectAn object containing merchant portal channel settings.
Show child attributesHide child attributes1
- can_applybooleanA boolean to indicate if the discount may be applied using the associated channel (defaults to true for all channels).
- checkout_pageobjectAn object containing checkout channel settings.
Show child attributesHide child attributes1
- can_applybooleanA boolean to indicate if the discount may be applied using the associated channel (defaults to true for all channels).
- codestringThe code used to apply the discount..
- Only used when
statusis set tofully_disabled. Iftrue, the discount is removed from the addresses and queued charges it is applied to before the response is returned. Defaults tofalse, which removes it in the background. - ends_atdatetimeThe expiration timestamp of the discount. Past this time the
Discountcan no longer be redeemed. Afterends_atthestatusof theDiscountwill go fromactivetodisabled.Recurring discounts applied prior to theirends_attime will still apply. - An object containing external ids of the discount.
Show child attributesHide child attributes11 new
- The discount id as it appears in the external e-commerce platform. Maximum 188 characters.
- The external platform that the
external_discount_idbelongs to. The combination ofexternal_discount_sourceandexternal_discount_idmust be unique.Possible valuesbig_commerceshopifyrechargeheadlessmagento - The minimum cart subtotal needed for the discount to be applicable.
- starts_atdatetimeThe date when the discount becomes active.
- statusstringThe status of the discount. Value can be:
*enableddiscount is active to be applied
*disableddiscount can’t be applied on new purchases. Discount will remain on existing charges to which it has already been applied.
*fully_disableddiscount can no longer be applied. In addition,Discountis removed from every queued charge.Possible valuesenableddisabledfully_disableddisabledandfully_disabledcan both be reverted toenabled. However once aDiscounthas been updated tofully_disabledit will be removed from allChargesit had been applied to. This removal fromChargesis irreversible. - usage_limitsobjectSets the limit on the number of times a discount can be used by all customers.
Show child attributesHide child attributes51 new
- one_application_per_customerbooleanThe discount can only be used once for a given customer checkout or manually applied once on the customer portal (irrespective of which address). Once applied, it will continue being re-applied to each new charge on the address.
- Discount can be used on checkout for customer that still don’t exist in Recharge database.
- max_subsequent_redemptionsintegerThe number of
ChargestheDiscountwill apply to besides the initial redemption for a givenCustomer. For example, if you want a discount to apply for 5 consecutive chargesmax_subsequent_redemptionsshould be 4. - redemptionsintegerSets the limit on the number of times a discount can be used by all customers. Only accepted for stores that have legacy discount usage limits enabled; otherwise the value is ignored.Only accepted for stores that have legacy discount usage limits enabled.The
redemptionsis not enabled by default. Contact us to enable support for this attribute. - The total number of
ChargestheDiscountapplies to for a givenCustomer.0or1makes the discount single use andnullapplies it to all future charges. Ignored whenmax_subsequent_redemptionsis also passed.
- valuestringThe discounted value to be applied.
- value_typestringThe discount type.Possible values
fixed_amountpercentageshipping
curl -X PUT 'https://api.rechargeapps.com/discounts/11127406' \
-H 'Content-Type: application/json' \
-H 'X-Recharge-Version: v2' \
-H 'X-Recharge-Access-Token: your_api_token' \
-d '{
"usage_limits": {},
"starts_at": "2021-11-01T00:00:00+00:00"
}'{
"discount": {
"id": 59568555,
"application_method": "code",
"applies_to": {
"ids": [],
"purchase_item_type": "ALL",
"resource": null
},
"applies_to_existing_addresses": true,
"channel_settings": {
"api": {
"can_apply": true
},
"checkout_page": {
"can_apply": true
},
"customer_portal": {
"can_apply": true
},
"merchant_portal": {
"can_apply": true
}
},
"code": "Discount1",
"created_at": "2021-07-26T19:16:17+00:00",
"customer_segments": [],
"ends_at": null,
"external_discount_id": {
"ecommerce": null
},
"external_discount_source": null,
"prerequisite_subtotal_min": null,
"starts_at": null,
"status": "enabled",
"title": null,
"updated_at": "2021-07-26T19:16:17+00:00",
"usage_limits": {
"first_time_customer_restriction": false,
"max_subsequent_redemptions": null,
"one_application_per_customer": false,
"automatic_redemptions_per_customer": null
},
"value": "100.00",
"value_type": "percentage"
}
}#Delete a discount
DELETE/discounts/{id}
Delete a discount
For safety reasons, to delete a discount you will need to set its status to
For safety reasons, to delete a discount you will need to set its status to
fully_disabled.Scope
write_discountsBody parameters
- Controls how the discount is removed from the addresses and queued charges it is applied to. If
true(default), it is removed before the response is returned. Iffalse, it is removed in the background.
curl -X DELETE 'https://api.rechargeapps.com/discounts/12081717' \
-H 'X-Recharge-Access-Token: your_api_token' \
-H 'X-Recharge-Version: v2'{}#List discounts
GET/discounts
Return a list of discounts in your store.
HTTP request examples
GET /discounts GET /discounts?created_at_max=2017-10-01 GET /discounts?created_at_max=2017-10-01 GET /discounts?created_at_min=2017-10-01 GET /discounts?discount_code=DiscountGET /discounts?discount_type=percentage GET /discounts?updated_at_min=2017-10-01Scope
read_discountsQuery parameters
- Filter discounts by how they are applied.Possible values
codeautomaticOnly applied for stores that have automatic discounts enabled. - created_at_maxstringGet all discounts created before a specified date.
- created_at_minstringGet all discounts created after a specified date.
- Return either the next or previous page of discounts using the
next_cursororprevious_cursorvalue from a previous response. Onlylimitcan be passed together withcursor. - discount_codestringSearch for a particular discount code.
- Search for a particular discount title. Combine with
wildcard_searchto match titles that start with the given value.Only applied for stores that have automatic discounts enabled. - Filter based on type of discount.Possible values
percentagefixed_amountshipping - Sort listed
Discountsin a specific order. Available sort options:id-asc,id-desc,created_at-asc,created_at-desc,updated_at-asc,updated_at-desc. Defaults toid-desc.Possible valuesid-ascid-desccreated_at-asccreated_at-descupdated_at-ascupdated_at-desc - idsstringFilter discounts by id. If passing multiple values, must be comma separated. Non-integer values will result in a 422 error
- limitstringNumber of results to return.
- Page to show.Page-based pagination has been deprecated but still available to use for pages up to a 100. If you need data past this point, use cursor pagination.
- statusstringReturns all discounts with status
enabled,disabledorfully_disabled.Possible valuesenableddisabledfully_disabled - updated_at_maxstringGet all discounts updated before a specified date.
- updated_at_minstringGet all discounts updated after a specified date.
- If
true,discount_codereturns all discounts whose code starts with the given value instead of requiring an exact match.
Response attributes
- idintegerUnique numeric identifier for the
Customer. - analytics_dataobjectAn object containing analytics data associated with the customer.
Show child attributesHide child attributes1
- utm_paramsarray of objectsAn array containing
utm_paramobjects.Show child attributesHide child attributes7
- utm_campaignstringThe UTM campaign.
- utm_contentstringThe UTM content.
- utm_data_sourcestringThe source of the campaign parameter.
- utm_sourcestringThe UTM source.
- utm_mediumstringThe UTM medium.
- utm_termstringThe UTM term.
- utm_timestampstringThe UTM timestamp.
- A boolean that indicates whether Recharge credits will be applied to the next recurring charge.
- created_atdatetimeThe date and time when the customer was created.
- emailstringThe email address of the customer.
- external_customer_idobjectAn object containing external ids for the customer record.
Show child attributesHide child attributes1
- ecommercestringThe customer ID as it appears in the external e-commerce platform.
- first_charge_processed_atdatetimeDate when first charge was processed for the customer.
- first_namestringThe customer’s first name.
- A boolean that indicates if the customer has a payment method that is in dunning (failed charge).
- has_valid_payment_methodbooleanIs the payment method valid or not.
- hashstringThe unique string identifier used in a customers portal link.
- last_namestringThe customer’s last name.
- phonestringThe customer's phone number.
- subscriptions_active_countintegerThe number of active subscriptions on addresses associated with the customer.
- subscriptions_total_countintegerThe total number of subscriptions created on addresses associated with the customer.
- tax_exemptbooleanWhether the customer tax exempt or not.
- updated_atdatetimeThe date and time when the customer was last updated.
curl 'https://api.rechargeapps.com/discounts' \
-H 'X-Recharge-Version: v2' \
-H 'X-Recharge-Access-Token: your_api_token'{
"next_cursor": null,
"previous_cursor": null,
"discounts": [
{
"id": 59568555,
"application_method": "code",
"applies_to": {
"ids": [],
"purchase_item_type": "ALL",
"resource": null
},
"applies_to_existing_addresses": true,
"channel_settings": {
"api": {
"can_apply": true
},
"checkout_page": {
"can_apply": true
},
"customer_portal": {
"can_apply": true
},
"merchant_portal": {
"can_apply": true
}
},
"code": "Discount1",
"created_at": "2021-07-26T19:16:17+00:00",
"customer_segments": [],
"ends_at": null,
"external_discount_id": {
"ecommerce": null
},
"external_discount_source": null,
"prerequisite_subtotal_min": null,
"starts_at": null,
"status": "enabled",
"title": null,
"updated_at": "2021-07-26T19:16:17+00:00",
"usage_limits": {
"first_time_customer_restriction": false,
"max_subsequent_redemptions": null,
"one_application_per_customer": false,
"automatic_redemptions_per_customer": null
},
"value": "100.00",
"value_type": "percentage"
}
]
}