Price formulas
A formula lets a tier compute its rate instead of stating it. Where a normal
tier says 109.00, a formula says cost * 1.15 and works the number
out at billing time.
Reach for one when the rate depends on something that moves: an upstream cost you re-negotiate, a rate you look up in a rate table, or a margin you want to change in one place rather than across forty tiers.
What an expression is
An expression is arithmetic over named values. Two kinds of name appear in it.
Costs, by key
cost * 1.15 reads the cost named cost and adds 15%. If your
upstream price is CHF 100, the tier charges CHF 115. Re-negotiate to CHF 92 and
every tier using this formula follows, with no price edits.
Variables, with defaults
{margin} is a variable the formula declares, with a default you can override
per tier. One formula, cost * {margin}, then serves every tier:
Code
That is the point of variables. The shape of the calculation is written once; each tier supplies only the number that differs.
Create one in the dashboard
-
Open the catalog
In the sidebar under Advanced, click Pricing Catalog, then the Formulas tab.
-
Create the formula
Create Formula, then give it a name and the expression. Declare any
{variable}the expression uses, with a sensible default. -
Use it on a tier
On a price, set a tier's FORMULA column to your formula instead of Flat, and override the variables that differ for that tier.
Create one with the API
name and expression are required. Formulas are versioned, so changing one
that is in use creates a new version rather than silently repricing live
subscriptions; GET /v1/price-formulas/{id}/versions/{version}/referrers shows
what would be affected.
Dashboard and API names
| In the dashboard | In the API |
|---|---|
| Expression | expression |
| Variables | variables[], each a name and a default |
| a tier's FORMULA column | tiers[].formula_id |
| per-tier override | tiers[].formula_defaults |
| Custom / System filter | formulas you wrote, versus built-in ones |
Going deeper
| Topic | What it adds |
|---|---|
| Costs | The values an expression reads by key |
| Rate tables | Looking a rate up rather than calculating it |
| Pricing models | How the resulting rates are applied across tiers |
Reference
| Topic | When you need it |
|---|---|
| Prices | Where a formula is attached to a tier |
| Price formulas API | Every field, plus versions and referrers |