Use macros
See how the set endpoint is implemented in our Example app ↗.
Macros allow you to simplify entitlement creation by grouping a predefined set of rules (feature access, usage limits, quotas, etc.) under a named identifier.
Think of them as a pre-designed pricing package with features attached. A blueprint, if you will.
The idea here is that, as a rule of thumb, instead of setting each entitlement property individually, you can apply a macro to speed things up:
// Without macro
gater.post("/set", {
user: "user_123",
feature: "premium_feature",
reset: "month",
quota: 100,
// ...
});
// With macro "premium_plan"
gater.post("/set", { user: "user_123", macro: "premium_plan" }); // predefined values: "premium_feature", "monthly", 100
Create a Macro
To create a macro, send a POST request to the /macros
endpoint with a name and the entitlement details.
gater.post("/macros", {
name: "premium_plan",
feature: "premium_feature",
reset: "month",
quota: 100,
});
You can attach more features to an existing macro by either calling the /macro
again (and again, as needed), or going into your gater dashboard to add new features to a macro manually.
Macros are especially useful when integrating with third-party billing APIs like Stripe. For example, by creating a macro with a Stripe price ID you can effectively map your billing with your entitlements. See the Stripe integration guide for more details.