Skip to main content
Entities give every user, seat, agent or workspace inside a customer its own budget, so one teammate or runaway agent never drains the whole account’s credits. Create an entity for each with either or both of:
  • 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.
Each entity can also hold a plan of its own, such as Workspace Pro per workspace, billed on the customer’s invoice.
Calling it again updates the entity: fields you leave out keep their values, and 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_reached with capRemaining, and check returns allowed: false with that reason.
  • Balances: with entityId, availableCredits is 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 entityId spends 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, entityId labels the use in the usage log and the customer’s allowance, limit or flag decides it.
To bill per seat, model each seat as a held feature with a seat price. To give each workspace its own plan, attach one to the entity.

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 with entityId 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 itemChangeId and status. 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 with planId, group, status (pending, active or canceling), startsAt and endsAt.
  • Overage stays with the customer’s plan.
Plans per workspace or user walks through the catalog and how it bills.

Rules

  • Entity allowances and caps apply to credits features.
  • Create an entity before it spends: an unknown entityId returns 404 entity_not_found on every feature type, so a typo never bypasses a cap.
  • A request_id belongs to the entity it was first tracked for; retrying it for another entity, or for none, returns 409 request_id_conflict.
  • Creating, changing or deleting an entity needs a key with the billing:write permission, 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_busy means that wait passed 1.5 seconds and nothing changed: retry after Retry-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.