can()economics: a point-in-time estimate of cost, revenue and margin for one call, with the status and the costs it leaves out. See The can() endpoint.- A margin policy: a versioned policy (
mode,on_unavailable, thresholds) thatcan()applies to that estimate. Indenymode it denies the call witheconomic_policy_denied. Inwarnmode it returnsdecision: "warn"and the call stays allowed.on_unavailable(allow,warnordeny) decides what happens when the estimate isunavailableorstale. A policy never notifies anyone: it only changes the response of the call. - The Cost Intelligence report: ledger-backed costs per Feature and customer, built from your Cost Sheets. See Cost Intelligence report.
Check the margin of one call
Callcan() from your backend before protected work and act on the estimate. Check status first: only estimated carries a margin.
can() estimates one call. It excludes shared_period_costs and finalized_invoice_adjustments, so it is not a customer or plan margin.
Watch costs over a period
Poll the Cost Intelligence report on a schedule you run, and comparesummary.total_cost with a limit you keep in your own code. The report returns cost only. It does not return revenue or margin.
summary.total_cost, summary.currency, and the per-customer customers breakdown. To compare cost with revenue, read the revenue of the same period from your finalized invoices. Check the uncosted array too: usage without a Cost Sheet rule is listed there instead of being counted as zero.
The key needs analytic:read when API key permissions are on.
Usage alerts in React
Usage alerts are separate from margin. TheUsageAlert component shows a warning when usage approaches a limit: