How to implement seat based entitlements
To implement seat-based entitlements using the gater API, you can represent each seat allocation as a consumable entitlement (e.g. seats).
You'll use the /set
endpoint to define how many total seats a user (usually an organization or team owner) is entitled to.
Since seat counts are managed by your application manually—e.g. when a team admin adds or removes users—there’s no need to define a reset interval on the entitlement.
Each time a team member is assigned a seat, use the /increment
endpoint to reserve one unit.
To determine whether more seats can be filled (i.e. if there are unused seats), you can use the /check
endpoint before assigning a new seat.
const gater = axios.create({
baseURL: "https://api.gater.dev",
headers: { "X-Api-Key": process.env.GATER_SECRET },
});
await axios.post("/set", {
user: "user_123",
feature: "seats",
quota: 10,
});
// entity joins group...
const response = await gater.post("/increment", {
user: "user_123",
feature: "seats",
});
if (response.data.ok) {
const { usage, quota } = response.data;
console.log(`Seat assigned. Usage: ${usage}/${quota}`); // 1/10
} else {
console.log("No seats available. Please upgrade the plan."); // 10/10
}