Hooks API
Web HookCreateDiscount4
Set up a discount code that implements Bubblehouse rewards and discounts.
| Kind | Mutation Hook |
|---|---|
| Method | POST |
| URL | The webhook URL you specify, with :name replaced by CreateDiscount4 |
| Authentication | JWT HS256 Bearer token |
Note that Bubblehouse will generate the discount codes on our end, and then will call this hook to set up the code. The customer may already see the code by that time. The expectation is that CreateDiscount hook can complete in the time it takes the customer to use the code.
A zero-amount, zero-percents discount code is valid, and will be used for referral tracking if the referred user is to be rewarded in loyalty points. If you cannot support this, referrals will need to be rewarded with a monetary discount.
All codes created by Bubblehouse should be configured to allow combining with other discount codes as much as possible.
Input
-
codestring requiredThe discount code string generated by Bubblehouse.
-
titlestring requiredA human-readable description of the discount.
-
Expiration time for this discount code, after which it cannot be used.
Expiration is optional in case you cannot support it, but it's highly recommended to avoid surprises in the future. If you do support it, though, make sure you can handle expiration one year into the future.
Omitted if no expiration date is configured for coupons.
-
A fixed amount of the discount.
-
A percentage discount.
-
A minimum order amount that this discount code can apply to.
-
max_usesinteger? optionalA maximum number of times this code can be used.
In many cases, will be 1.
-
customer_idstring? optionalA customer to limit the discount to. Missing or null means unlimited.
-
customer_emailstring? optionalThe email of the customer to limit the discount to, if any.
-
The information on the kind of .
Together with
subject_slugs, this property allows you to identify the specific discount coupon being created, in case you want to give some coupons an extra-special treatment beyond the properties provided to this hook. -
subject_slugsarray of string optionalThe slugs identifying the object (vendible or achievement) that resulted in this coupon.
Together with
context, this property allows you to identify the specific discount coupon being created, in case you want to give some coupons an extra-special treatment beyond the properties provided to this hook.You can identify Bubblehouse objects by slug. Slugs are human-readable and derived from customer-visible titles, but are stable (do not get invalidated as the title changes) and use a restricted URL-friendly character set. E.g. an object named "Oh My, Great Vendible!" might get
oh-my-great-vendibleslug. Slugs only contain lowercase latin letters, numbers and dashes. You can see an object's slug in the admin panel.Slugs are always unique for a given type of object across their entire history. A numeric suffix like -2 is appended when necessary to make it unique (e.g. great-vendible-2). Bubblehouse keeps a history of slugs that have ever been associated with a given object, and allows using any of them to identify it. So when you rename "Great Milestone" to "Best Savings Month", it gets multiple slugs:
["best-savings-month", "great-milestone"]. The current slug always comes first, followed by older slugs.This means that you can manually get a slug from the admin console, put it into your system's configuration, and have your system match it against the list of slugs returned by Bubblehouse. This will continue to operate correctly going forward, regardless of any future renames, and across multiple environments.
Example:
["free-hat","slippers"] -
subject_typestring optionalThe type of the object idenfitied by subject_slugs.
You typically don't need to care about this property;
contextshould be enough to know the subject type. -
product_idsarray of string optionalLimit this discount to only apply to the specified products.
-
collection_idsarray of string optionalLimit this discount to only apply to the products in specified collections.
-
is_per_productboolean optionalWhether the discount applies to the products or the orders.
If true, the discount applies to the price of the product, i.e. should reduce the price of each order item matching the product IDs or collection IDs.
If false, the discount applies once to the entire order, even if multiple items match the product or collection IDs.
This distinction is only relevant if product or collection IDs are specified. Otherwise, it will always be false.
-
applies_to_one_time_purchasesboolean one of applies_to_... must be trueWhether the discount can be used with one-time purchases, aka the normal ones.
-
applies_to_subscription_purchasesboolean one of applies_to_... must be trueWhether the discount can be used when purchasing a new subscription.
Ignore if your ecommerce shop does not use subscriptions.
-
applies_to_subscription_renewalsboolean one of applies_to_... must be trueWhether the discount can apply to subsequent subscription cycles.
Ignore if your ecommerce shop does not use subscriptions.
-
max_subscription_cyclesinteger? optionalLimit the number of subscription cycles this discount is effective for.
When 1, applies to just one cycle. When null, applies to every cycle of a subscription going forward.
Only relevant when applying the code to a subscription purchase. Ignore if your ecommerce shop does not use subscriptions.
Output
A successful response has no meaningful properties and only contains an ok property always set to true:{"ok": true}