- An allowance (
allowanceCredits): credits per billing period that only this entity can spend, used before the shared pool. Granted for the customer’s plan period while the customer has a plan. - A cap (
capCredits): the most it may draw from the shared pool (shared credits and overage) per billing period.
null clears one.
Then pass entityId to check, track and reservations to spend as the entity:
How entities spend
- Order: the entity’s own credits first (its allowance and its plans’ own grants), then the shared pool in spend order and overage, with the entity’s cap limiting everything after the allowance.
- Caps: the customer’s own overage cap still applies; whichever cap is tighter refuses first. A request past the entity’s cap returns
409 entity_cap_reachedwithcapRemaining, and check returnsallowed: falsewith that reason. - Balances: with
entityId,availableCreditsis what that entity can still spend. Get an entity shows its allowance left, the shared credits it drew this period and what its cap still allows. - Shared pool: a request without
entityIdspends the shared pool and never an entity’s own credits. - Periods: allowances and caps reset with the customer’s billing period, and monthly inside an annual plan. An upgrade starts a new period, and the entity’s allowance and cap start again with it; the old period’s allowance ends then.
- Deleted entities: a reservation made for an entity that is deleted before the work ends still settles, from the shared pool, for at most the credits it held. Settling for more returns
404 entity_not_found. - Other feature types: on a metered, held or boolean feature, the customer’s plans and the entity’s own plans decide it together. An entity spends its own metered grants first, then the customer’s. Without entity plans,
entityIdlabels the use in the usage log and the customer’s allowance, limit or flag decides it.
Entity plans
An entity can hold plans of its own: each workspace on Workspace Pro, billed on the customer’s one invoice. Attach the plan withentityId and an Idempotency-Key:
- One invoice: a paid entity plan is a prorated change on the customer’s Stripe bill of the plan’s interval, answered like an add-on attach with
itemChangeIdandstatus. Entities on the same plan share one Stripe item, its quantity counting them. - Grants: with
entityGrants: "own"(the default), the plan’s credits and allowances belong to the entity and are spent before the shared pool. With"pooled", they join the customer’s shared pool. The first period is prorated from the attach; each renewal grants in full. - Free entity plans change nothing in Stripe. They ride on the customer’s bill and are granted with each of its periods.
- Upgrades: move an entity to a pricier plan with upgrade, passing
entityId. It’s prorated, the period is kept, and other entities on the old plan stay on it. - Reading: Get an entity lists its
plans, each withplanId,group,status(pending,activeorcanceling),startsAtandendsAt. - Overage stays with the customer’s plan.
Rules
- Entity allowances and caps apply to credits features.
- Create an entity before it spends: an unknown
entityIdreturns404 entity_not_foundon every feature type, so a typo never bypasses a cap. - A
request_idbelongs to the entity it was first tracked for; retrying it for another entity, or for none, returns409 request_id_conflict. - Creating, changing or deleting an entity needs a key with the
billing:writepermission, because an allowance is credits on top of the plan. - Entity changes wait behind the customer’s other billing changes, as track does.
503 customer_busymeans that wait passed 1.5 seconds and nothing changed: retry afterRetry-After(1 second). - An entity holds one plan per group (
409 subscription_exists). - A paid entity plan joins a paid bill of its interval: attach the customer’s own paid plan first (
409 entity_plan_needs_paid_bill). A free entity plan needs the customer to hold a plan (409 entity_plan_needs_bill). - An entity plan has a Stripe Price of its own, apart from the customer’s plan (
409 entity_plan_shares_base_price), and renews monthly or yearly (400 entity_plan_must_recur). - An entity’s plan moves by upgrade (
409 downgrade_unavailable_for_item). - An entity is deleted once it holds no plan (
409 entity_has_plan), so a delete never changes what the customer pays. Its plans end with the customer’s bill.