# l4 rec execute

> Request execution of an accepted savings recommendation from the terminal. Records the implementation method; the rollout itself runs server-side.

Source: https://docs.levelfour.ai/cli/commands/recommendations/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.

```bash
l4 rec execute <id> [flags]
```

`rec` and `recs` are [aliases for `recommendations`](/cli/commands/recommendations).

> **Note**
>
> Accept the recommendation first with [`l4 rec accept`](/cli/commands/recommendations/accept). The `one-click` methods apply the change through the connected [Automated Savings](/connectors/aws/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

| Flag           | Description                                                                    |
| -------------- | ------------------------------------------------------------------------------ |
| `--method <m>` | `one-click`, `iac`, `one-click-plus-iac`, or `manual`. Defaults to `one-click` |
| `--yes` / `-y` | Skip 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](/cli#global-flags).

## Methods

| Method               | Meaning                                                                                                 |
| -------------------- | ------------------------------------------------------------------------------------------------------- |
| `one-click`          | LevelFour applies the change in your cloud account using the connected Automated Savings grant          |
| `iac`                | LevelFour opens a pull request against your infrastructure-as-code repository                           |
| `one-click-plus-iac` | Applies the change and then opens the pull request. Needs both a connected grant and a bound repository |
| `manual`             | You 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:

```text
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.

> **Warning**
>
> 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](/cli/authentication#browser-login-mints-a-read-only-key) 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

```bash
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:

```bash
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:

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

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

```text
.success
.data.recommendation_id
.data.status                     # "processing"
.data.implementation_method
.timestamp
```

> **Success**
>
> `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

| Exit | Symptom                     | Cause                                                                                                     |
| ---- | --------------------------- | --------------------------------------------------------------------------------------------------------- |
| `4`  | Authentication required     | No token resolvable; run `l4 auth login` or set `LEVELFOUR_TOKEN`                                         |
| `1`  | `invalid --method`          | The value is not one of the methods the API accepts                                                       |
| `1`  | `401` authentication failed | Token revoked, expired, or from the wrong environment                                                     |
| `1`  | `403` permission denied     | The key has the `read` scope. The must-be-accepted-first gate applies to dashboard roles, not to API keys |
| `1`  | `404`                       | No recommendation with that id in this organization                                                       |

## Related

* [`l4 rec accept`](/cli/commands/recommendations/accept): accept before executing
* [`l4 rec reject`](/cli/commands/recommendations/reject): reject instead
* [`l4 recommendations`](/cli/commands/recommendations): list and view recommendations
* [CLI authentication](/cli/authentication): read versus read-write keys
* [Automated Savings](/connectors/aws/automated-savings): the grant the `one-click` methods use
* [Webhooks](/webhooks): optimization lifecycle events
