Skip to navigation

Preflight Checks

A flag check answers whether a company has access right now. A preflight answers whether an action would be allowed if it ran. Pass the size of the action with the check, and Schematic evaluates the flag as if that usage had already been recorded. A company one use short of its limit comes back false for an action that needs two. Nothing is consumed or reserved, so you still track the usage when the action finishes.

Preflight works against any numeric limit a flag evaluates: a credit balance, an event-based allowance, or a trait-based limit such as seats. A bulk export of 5,000 rows, an agent run budgeted at 200 steps, and an invite that adds 10 seats are each one preflight.

Running a preflight

Run preflights from your server, on a check for a single flag. The multi-flag check endpoints reject them, because one action’s size would land on every flag’s limits.

const result = await client.checkFlagWithEntitlement(
{ company: { id: "northwind" } },
"bulk-export",
{ eventUsage: { eventSubtype: "rows_exported", quantity: rowCount } },
);
if (!result.value) {
return showLimitMessage(result.reason);
}

Calling the API directly, pass the same inputs in preflight on Check flag.

Inputs

InputWhat it simulates
usageA quantity applied to every numeric condition the flag evaluates
event_usageA quantity of one event subtype, applied only to conditions that measure that subtype
credit_costA cost in credits, keyed by credit type ID, for when you have already worked out the cost

Each condition takes the most specific input that applies to it:

ConditionInputs, highest precedence first
Credit balancecredit_cost for that credit, then event_usage when the subtype matches, then usage
Event-based limitevent_usage when the subtype matches, then usage
Trait-based limit, such as seatsusage

A flag with no numeric condition, such as an on/off entitlement, evaluates the same with or without a preflight. The SDKs round a fractional quantity up, so a check never passes on less usage than the action records.

Behaviors to plan around

  • Only the flag value is simulated. The entitlement and usage figures in the response are the company’s current ones, not the figures after the action.
  • Preflighted checks skip the flag check cache. The answer depends on the size you sent, so the SDKs neither serve it from nor write it to their local cache.
  • The size is whatever you send. An undersized value can let through a check the real size would fail. Work out the size on your server from the action you are about to run, never from a value a browser passed you.
  • Prevent Overspend puts preflight alongside reservations and usage controls for credit-metered features, and shows how to turn the same check into a cost preview.
  • Usage Controls sets per-draw limits, which only a sized check can trip.
  • Flags covers how flag rules are evaluated.