API
Core Resources

Discounts

Discounts can be applied to a 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

  • idinteger
    Unique numeric identifier for the discount in Recharge.
  • application_methodstring · nullableNew
    How the discount is applied. code discounts are applied with a discount code and automatic discounts are applied without one.
    Possible values
    codeautomatic
  • An object encompassing data that limits discount application on the basis of an associated record (such as customer, products, etc.).
    Show child attributesHide child attributes3
    • idsarray
      A 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.
    • An indicator of whether the discount applies to onetimes, subscriptions, or all purchase item types.
      Possible values
      ALLONETIMESUBSCRIPTION
    • resourcestring
      An 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 false for automatic discounts.
  • A 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
    • apiobject
      An object containing api channel settings.
      Show child attributesHide child attributes1
      • can_applyboolean
        A boolean to indicate if the discount may be applied using the associated channel (defaults to true for all channels).
        Default true
    • An object containing customer portal channel settings.
      Show child attributesHide child attributes1
      • can_applyboolean
        A boolean to indicate if the discount may be applied using the associated channel (defaults to true for all channels).
        Default true
    • An object containing merchant portal channel settings.
      Show child attributesHide child attributes1
      • can_applyboolean
        A boolean to indicate if the discount may be applied using the associated channel (defaults to true for all channels).
        Default true
    • An object containing checkout channel settings.
      Show child attributesHide child attributes1
      • can_applyboolean
        A boolean to indicate if the discount may be applied using the associated channel (defaults to true for all channels).
        Default true
  • codestring
    The code used to apply the discount.
  • customer_segmentsarray of objectsNew
    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
  • external_discount_sourcestring · nullableNew
    The external platform that the external_discount_id belongs to.
    Possible values
    big_commerceshopifyrechargeheadlessmagento
  • titlestring · nullableNew
    The title of the discount. For automatic discounts the title is also returned as the code.
  • created_atdatetime
    The date and time when the discount was created.
  • ends_atdatetime
    The expiration timestamp of the discount. Past this time the Discount can no longer be redeemed. After ends_at the status of the Discount will go from active to disabled.
    Recurring discounts applied prior to their ends_at time will still apply.
  • An object containing external ids of the discount.
    Show child attributesHide child attributes1
    • ecommercestring
      The discount id as it appears in the external e-commerce platform.
  • The minimum cart subtotal needed for the discount to be applicable.
  • starts_atdatetime
    The date when the discount becomes active.
    When not specified on creation starts_at will default to null which translates into no restrictions.
  • statusstring
    The status of the discount. Value can be:
    * enabled discount is active to be applied
    * disabled discount can’t be applied on new purchases. Discount will remain on existing charges to which it has already been applied.
    * fully_disabled discount can no longer be applied. In addition, Discount is removed from every queued charge.
    Possible values
    enableddisabledfully_disabled
    disabled and fully_disabled can both be reverted to enabled. However once a Discount has been updated to fully_disabled it will be removed from all Charges it had been applied to. This removal from Charges is irreversible.
  • An object containing limitations on a discount based on usage_counts results
    Show child attributesHide child attributes51 new
    • The 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.
    • The number of Charges the Discount will apply to besides the initial redemption for a given Customer. For example, if you want a discount to apply for 5 consecutive charges max_subsequent_redemptions should be 4.
    • Sets 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 Charges the Discount applies to for a given Customer. 0 means the discount is single use and null means it applies to all future charges.
  • updated_atdatetime
    The date and time when the discount was last updated.
  • valuestring
    The discounted value to be applied.
  • Type of discount mechanic.
    Possible values
    fixed_amountpercentageshipping
The discount object
{
  "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.
Scopewrite_discounts

Body parameters

  • An object encompassing data that limits discount application on the basis of an associated record (such as customer, products, etc.)
    Show child attributesHide child attributes3
    • idsarray
      A 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.
    • An indicator of whether the discount applies to onetimes, subscriptions, or all purchase item types.
      Possible values
      ALLONETIMESUBSCRIPTION
    • resourcestring
      An indicator of the type of resource to which applies_to_id refers.
      Possible values
      shopify_productshopify_collection_idcollection_id
  • A 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
    • apiobject
      An object containing api channel settings.
      Show child attributesHide child attributes1
      • can_applyboolean
        A boolean to indicate if the discount may be applied using the associated channel (defaults to true for all channels).
        Default true
    • An object containing customer portal channel settings.
      Show child attributesHide child attributes1
      • can_applyboolean
        A boolean to indicate if the discount may be applied using the associated channel (defaults to true for all channels).
        Default true
    • An object containing merchant portal channel settings.
      Show child attributesHide child attributes1
      • can_applyboolean
        A boolean to indicate if the discount may be applied using the associated channel (defaults to true for all channels).
        Default true
    • An object containing checkout channel settings.
      Show child attributesHide child attributes1
      • can_applyboolean
        A boolean to indicate if the discount may be applied using the associated channel (defaults to true for all channels).
        Default true
  • codestringRequired
    The code used to apply the discount.
  • ends_atdatetime
    The expiration timestamp of the discount. Past this time the Discount can no longer be redeemed. After ends_at the status of the Discount will go from active to disabled.
    Recurring discounts applied prior to their ends_at time will still apply.
  • An object containing external ids of the discount.
    Show child attributesHide child attributes11 new
    • ecommercestringNew
      The discount id as it appears in the external e-commerce platform. Maximum 188 characters.
  • The external platform that the external_discount_id belongs to. The combination of external_discount_source and external_discount_id must be unique.
    Possible values
    big_commerceshopifyrechargeheadlessmagento
  • The minimum cart subtotal needed for the discount to be applicable.
  • starts_atdatetime
    The date when the discount becomes ACTIVE.
    When not specified on creation starts_at will default to null which translates into no restrictions.
  • statusstring
    The status of the discount.
    Possible values
    enableddisabled
  • titlestringNew
    The title of the discount. Maximum 255 characters.
  • Sets the limit on the number of times a discount can be used by all customers.
    Show child attributesHide child attributes51 new
    • The 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.
    • The number of Charges the Discount will apply to besides the initial redemption for a given Customer. For example, if you want a discount to apply for 5 consecutive charges max_subsequent_redemptions should be 4.
    • Sets 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 redemptions is not enabled by default. Contact us to enable support for this attribute.
    • The total number of Charges the Discount applies to for a given Customer. 0 or 1 makes the discount single use and null applies it to all future charges. Ignored when max_subsequent_redemptions is also passed.
  • valuestringRequired
    The discounted value to be applied.
  • value_typestringRequired
    The discount type.
    Possible values
    fixed_amountpercentageshipping
POST/discounts
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"
}'
Response
{
  "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"
  }
}

#Retrieve a discount

GET/discounts/{id}
Retrieve a single Recharge Discount
Scoperead_discounts
GET/discounts/{id}
curl 'https://api.rechargeapps.com/discounts/1234567' \
  -H 'X-Recharge-Version: v2' \
  -H 'X-Recharge-Access-Token: your_api_token'
Response
{
  "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.
Scopewrite_discounts
Once 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

  • An object encompassing data that limits discount application on the basis of an associated record (such as customer, products, etc.)
    Show child attributesHide child attributes3
    • idsarray
      A 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.
    • An indicator of whether the discount applies to onetimes, subscriptions, or all purchase item types.
      Possible values
      ALLONETIMESUBSCRIPTION
    • resourcestring
      An indicator of the type of resource to which applies_to_id refers.
      Possible values
      shopify_productshopify_collection_idcollection_id
  • A 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
    • apiobject
      An object containing api channel settings.
      Show child attributesHide child attributes1
      • can_applyboolean
        A boolean to indicate if the discount may be applied using the associated channel (defaults to true for all channels).
        Default true
    • An object containing customer portal channel settings.
      Show child attributesHide child attributes1
      • can_applyboolean
        A boolean to indicate if the discount may be applied using the associated channel (defaults to true for all channels).
        Default true
    • An object containing merchant portal channel settings.
      Show child attributesHide child attributes1
      • can_applyboolean
        A boolean to indicate if the discount may be applied using the associated channel (defaults to true for all channels).
        Default true
    • An object containing checkout channel settings.
      Show child attributesHide child attributes1
      • can_applyboolean
        A boolean to indicate if the discount may be applied using the associated channel (defaults to true for all channels).
        Default true
  • codestring
    The code used to apply the discount..
  • commitbooleanNew
    Only used when status is set to fully_disabled. If true, the discount is removed from the addresses and queued charges it is applied to before the response is returned. Defaults to false, which removes it in the background.
  • ends_atdatetime
    The expiration timestamp of the discount. Past this time the Discount can no longer be redeemed. After ends_at the status of the Discount will go from active to disabled.
    Recurring discounts applied prior to their ends_at time will still apply.
  • An object containing external ids of the discount.
    Show child attributesHide child attributes11 new
    • ecommercestringNew
      The discount id as it appears in the external e-commerce platform. Maximum 188 characters.
  • The external platform that the external_discount_id belongs to. The combination of external_discount_source and external_discount_id must be unique.
    Possible values
    big_commerceshopifyrechargeheadlessmagento
  • The minimum cart subtotal needed for the discount to be applicable.
  • starts_atdatetime
    The date when the discount becomes active.
  • statusstring
    The status of the discount. Value can be:
    * enabled discount is active to be applied
    * disabled discount can’t be applied on new purchases. Discount will remain on existing charges to which it has already been applied.
    * fully_disabled discount can no longer be applied. In addition, Discount is removed from every queued charge.
    Possible values
    enableddisabledfully_disabled
    disabled and fully_disabled can both be reverted to enabled. However once a Discount has been updated to fully_disabled it will be removed from all Charges it had been applied to. This removal from Charges is irreversible.
  • Sets the limit on the number of times a discount can be used by all customers.
    Show child attributesHide child attributes51 new
    • The 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.
    • The number of Charges the Discount will apply to besides the initial redemption for a given Customer. For example, if you want a discount to apply for 5 consecutive charges max_subsequent_redemptions should be 4.
    • Sets 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 redemptions is not enabled by default. Contact us to enable support for this attribute.
    • The total number of Charges the Discount applies to for a given Customer. 0 or 1 makes the discount single use and null applies it to all future charges. Ignored when max_subsequent_redemptions is also passed.
  • valuestring
    The discounted value to be applied.
  • The discount type.
    Possible values
    fixed_amountpercentageshipping
PUT/discounts/{id}
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"
}'
Response
{
  "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 fully_disabled.
Scopewrite_discounts

Body parameters

  • commitbooleanNew
    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. If false, it is removed in the background.
DELETE/discounts/{id}
curl -X DELETE 'https://api.rechargeapps.com/discounts/12081717' \
  -H 'X-Recharge-Access-Token: your_api_token' \
  -H 'X-Recharge-Version: v2'
Response
{}

#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=Discount

GET /discounts?discount_type=percentage

GET /discounts?updated_at_min=2017-10-01
Scoperead_discounts

Query parameters

  • Filter discounts by how they are applied.
    Possible values
    codeautomatic
    Only applied for stores that have automatic discounts enabled.
  • Get all discounts created before a specified date.
  • Get all discounts created after a specified date.
  • cursorstringNew
    Return either the next or previous page of discounts using the next_cursor or previous_cursor value from a previous response. Only limit can be passed together with cursor.
  • Search for a particular discount code.
  • Search for a particular discount title. Combine with wildcard_search to match titles that start with the given value.
    Only applied for stores that have automatic discounts enabled.
  • discount_typestringNew
    Filter based on type of discount.
    Possible values
    percentagefixed_amountshipping
  • sort_bystringNew
    Sort listed Discounts in a specific order. Available sort options: id-asc, id-desc, created_at-asc, created_at-desc, updated_at-asc, updated_at-desc. Defaults to id-desc.
    Possible values
    id-ascid-desccreated_at-asccreated_at-descupdated_at-ascupdated_at-desc
  • idsstring
    Filter discounts by id. If passing multiple values, must be comma separated. Non-integer values will result in a 422 error
  • limitstring
    Number of results to return.
    Default 50Maximum 250
  • pagestringDeprecated
    Page to show.
    Default 1
    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.
  • statusstring
    Returns all discounts with status enabled, disabled or fully_disabled.
    Possible values
    enableddisabledfully_disabled
  • Get all discounts updated before a specified date.
  • Get all discounts updated after a specified date.

Response attributes

  • idinteger
    Unique numeric identifier for the Customer.
  • An object containing analytics data associated with the customer.
    Show child attributesHide child attributes1
  • A boolean that indicates whether Recharge credits will be applied to the next recurring charge.
  • created_atdatetime
    The date and time when the customer was created.
  • emailstring
    The email address of the customer.
  • An object containing external ids for the customer record.
    Show child attributesHide child attributes1
    • ecommercestring
      The customer ID as it appears in the external e-commerce platform.
  • Date when first charge was processed for the customer.
  • The customer’s first name.
  • A boolean that indicates if the customer has a payment method that is in dunning (failed charge).
  • Is the payment method valid or not.
  • hashstring
    The unique string identifier used in a customers portal link.
  • last_namestring
    The customer’s last name.
  • phonestring
    The customer's phone number.
  • The number of active subscriptions on addresses associated with the customer.
  • The total number of subscriptions created on addresses associated with the customer.
  • tax_exemptboolean
    Whether the customer tax exempt or not.
  • updated_atdatetime
    The date and time when the customer was last updated.
GET/discounts
curl 'https://api.rechargeapps.com/discounts' \
  -H 'X-Recharge-Version: v2' \
  -H 'X-Recharge-Access-Token: your_api_token'
Response
{
  "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"
    }
  ]
}