CLICommandsl4 recommendations

l4 rec execute

l4 rec execute requests execution of a savings recommendation that has already been accepted. It records the implementation method and marks the rollout in progress. The rollout itself runs server-side.

l4 rec execute <id> [flags]

rec and recs are aliases for recommendations.

Accept the recommendation first with l4 rec accept. The one-click methods apply the change through the connected Automated Savings grant, and connecting that grant happens in the dashboard, not from the CLI.

What it changes

The command posts to /api/v1/recommendations/audit/execution-requests with the recommendation id and the chosen implementation_method. On the recommendation:

  • implementation_status becomes in_progress, while status stays pending, so the dashboard keeps the recommendation under Pending with the Implementation column live
  • implementation_method is set to the value you passed
  • the dashboard's Triggered Via card records the method plus saving_accepted_by, the identity that accepted the recommendation rather than the credential that ran this command

Flags

FlagDescription
--method <m>one-click, iac, one-click-plus-iac, or manual. Defaults to one-click
--yes / -ySkip the confirmation prompt

l4 rejects an unrecognized --method locally, before it sends anything. The API enforces the same set.

Global flags apply. See CLI overview.

Methods

MethodMeaning
one-clickLevelFour applies the change in your cloud account using the connected Automated Savings grant
iacLevelFour opens a pull request against your infrastructure-as-code repository
one-click-plus-iacApplies the change and then opens the pull request. Needs both a connected grant and a bound repository
manualYou apply the change yourself. Records the method without triggering an automated rollout

Confirmation

By default the command prompts before sending, and the prompt names the method:

Execute recommendation REC-1234 using the one-click method? [y/N]:

Anything other than y or yes aborts, prints Aborted., and exits 0 without calling the API. Pass --yes to skip the prompt in an interactive shell.

This is the command that starts a change in your cloud account, and two things send it through with no prompt: --yes, and a stdout that is not a TTY. Check the recommendation id and the method before you put this in a pipeline or a CI job.

Requires a read-write key

The endpoint requires the read-write scope, and l4 auth login mints a read-only key. See CLI authentication for how to create one that has it.

Re-running it

Each invocation sends its own Idempotency-Key, which lets the API discard a duplicate delivery of the same request. Re-running execute does not start a second rollout either: the server only sets implementation_status when it is not already set.

Examples

l4 rec execute REC-1234
l4 rec execute REC-1234 --method iac
l4 rec execute REC-1234 --method manual --yes
l4 rec execute REC-1234 --json

Accept and execute in one step, with no prompt at either stage:

l4 rec accept REC-1234 --yes && l4 rec execute REC-1234 --method one-click --yes

Output

Default output is a success line plus the fields the API returned:

Execution requested for recommendation REC-1234
Status    processing
Method    one-click

With --json the whole API envelope is printed. The fields it carries:

.success
.data.recommendation_id
.data.status                     # "processing"
.data.implementation_method
.timestamp
Execution requested for recommendation REC-1234 is the proof the request landed. The rollout runs server-side from there. Track it with l4 recommendations view <id>, or in the dashboard under Status & Logs.

Errors

ExitSymptomCause
4Authentication requiredNo token resolvable; run l4 auth login or set LEVELFOUR_TOKEN
1invalid --methodThe value is not one of the methods the API accepts
1401 authentication failedToken revoked, expired, or from the wrong environment
1403 permission deniedThe key has the read scope. The must-be-accepted-first gate applies to dashboard roles, not to API keys
1404No recommendation with that id in this organization