Skip to main content
lago v2 apply DIR makes the organization’s product catalog match a folder of YAML files. The catalog can live in git and be reviewed like code. Requires CLI v1.2.1 or later.

Files

apply reads every .yml and .yaml file under DIR. Split and nest them however you like. A file is a map whose keys are among: Each object takes the fields of its v2 create request and is matched by code. Numbers are sent as written and compared as decimals, so "0.7" and 0.70 match. Product filters, Contracts and customers are not managed by apply.

How a run works

  1. apply reads the files and the current catalog, then prints the plan: one row per object, with the action and the changed fields.
  2. It refuses, before sending anything, a change the API cannot make in place. Examples: a product’s product_type, the billing fields of a rate card that has rates, the frozen fields of an active or terminated rate, the currency of a plan with applied rate cards, or a billable metric a v1 plan charges. Rate dates are checked too, and applied rate card changes on a plan with a live Contract are refused.
  3. It creates and updates in dependency order, sending only the fields that changed. A failed write stops the run. Rerunning picks up where it stopped.

State and pruning

apply deletes nothing unless you pass --prune. It records the objects it manages in DIR/.lago-state/<organization lago_id>.json, or the path given by --state. Commit that file with the YAML. A run holds a .lock file next to the state while it writes. --prune deletes the managed objects the files no longer declare. It never touches an object the folder did not create or adopt. When a declared plan lists applied_rate_cards, or a declared rate card lists rates (even an empty list), those children belong to the file, so --prune also removes the ones the file dropped. Without the key, they are left alone.
  • Rates are history. Active and terminated rates are kept. To change a price, add a rate with a later effective_from. Only pending rates are pruned.
  • Plans are released, not deleted. The v2 API has no plan delete. A dropped plan leaves the state and stays in Lago.
  • Cascades are refused. --prune refuses, before any write, a delete that Lago would cascade to objects the run keeps: the products of a category, the rate cards and filters of a product, the v1 charges on a billable metric, or a rate card a plan still applies.
Deleting asks for confirmation. In scripts, pass --confirm prune.
apply writes to the organization of the active profile. Run --dry-run first, review the plan, and use lago whoami to confirm the organization before applying to live.