CLICommandsl4 tags

l4 tags preview

l4 tags preview runs a tag file against your recent costs and prints what each value would take. It saves nothing, so you can try a rule, read the result and edit the file as many times as you like before l4 tags apply.

l4 tags preview -f <file> [--start <date> --end <date>]

The command posts the file to /api/v1/tags/virtual/preview. It reads the same file format as apply, and name may be empty.

Preview evaluates the file you pass, not the saved key. effective_from has no effect here: the window is --start to --end, or the last 30 complete days, and Limits caps its length.

Flags

FlagDescription
-f <file>Tag file to evaluate. Required
--start <date> / --end <date>Window. See Dates

Global flags apply. See CLI overview.

Examples

l4 tags preview -f teams.yaml
l4 tags preview -f teams.yaml --start 2026-08-01 --end 2026-08-31
l4 tags preview -f teams.yaml --jq '.data.unallocated_spend'
l4 tags preview -f teams.yaml --jq '.data.values[] | [.name, .spend]'

Output

Default output is a table of values with their spend and resource count, followed by the unallocated and shadowed spend. With --json the whole API envelope is printed. The fields it carries:

.data.window.start
.data.window.end
.data.total_spend
.data.unallocated_spend
.data.shadowed_spend         # spend a lower config also matches, already taken by a higher one
.data.values[].name
.data.values[].spend
.data.values[].resource_count
.data.values[].sample_resources[]

shadowed_spend points at order problems. A config you expected to claim spend, showing little of it while shadowed_spend is high, sits below a broader config that takes its lines first. Move it up.

Errors

ExitSymptomCause
4Authentication requiredNo token resolvable; run l4 auth login or set LEVELFOUR_TOKEN
1The file does not parse, or has an unknown fieldFix the file. File format lists the fields
1401 authentication failedToken revoked, expired, or from the wrong environment
1422 validation_failedThe file breaks a rule. Validation problems lists the codes