Repository navigation
Conversation
`lago v2 apply DIR` makes the product catalog match a folder of YAML files: billable metrics, product categories, products, rate cards with their rates, and plans with their applied rate cards, matched by code. It prints a plan (`--dry-run` stops there), then creates and updates in dependency order with only the changed fields. A change the API cannot make in place is refused before anything is sent. Decimals and timestamps compare by value, so the API's "0.70" and microsecond timestamps do not show up as changes on every run. Nothing is deleted without `--prune`. The objects the folder created or adopted are recorded in DIR/.lago-state/<organization id>.json, and `--prune` only deletes those, after confirmation. A shared organization's other objects are never touched, and neither are active or terminated rates. Plans have no v2 delete route, so a dropped plan is released. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sarkissianraffi
self-requested a review
November 11, 2026 09:33
sarkissianraffi
approved these changes
Nov 11, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
lago v2 apply DIRmakes an organization's product catalog match a folder of YAML files, so the catalog can live in git and be reviewed like code. It covers billable metrics, product categories, products, rate cards with their rates, and plans with their applied rate cards, all matched by code.create,updatewith the changed fields,unchanged,delete), then writes in dependency order and sends only the fields that changed.product_type."0.70"matches0.7, and2026-11-11T00:00:00.000000Zmatches2026-11-11T00:00:00Z. Without this, each run would try to update every active rate, and the API refuses that.--pruneand a confirmation. The objects the folder created or adopted are recorded inDIR/.lago-state/<organization id>.json, and only those can be deleted, so another team's objects in a shared org are never touched. A declared plan's applied rate cards and a declared rate card's pending rates match the files exactly. Active and terminated rates are history and are kept. Plans have no v2 delete route, so a dropped plan is released from the state instead.The reasoning is in DECISIONS.md ("
lago v2 apply").API and spec gaps found on the way
descriptionout of the update bodies for products, product categories, rate cards and plans, but lago-api accepts it. apply takes its field lists from the controllers' strong params for now; the spec should be fixed upstream.effective_fromcan't be before today (must_not_be_before_today), even inside a new rate card, so the dates in the Notion example payloads no longer work as-is.QA
Run against a local lago-api (org with the
product_catalogflag), using the Lago for Lago billing configuration from the self-serve spec:product_type, unknown field, unknown category code.--prunethey were listed as skipped. Without--confirmit was refused. With both, 5 deletes ran in reverse dependency order. The org's other objects (growth,standard_usd,platform_fee,catalog_api_calls) were untouched, and the active rate was kept.make test, lint, moneycheck, the coverage floors (internal/cli 90.1%) andmake generate-checkpass. The new tests use an in-memory fake of the v2 catalog API with cursor pagination.🤖 Generated with Claude Code