# Edit or delete a budget

Change a budget's amount, period, scope, thresholds or recipients, or delete it with the record of its alerts.

Replace _budget-id_ with the budget's id (`dcloud billing budgets list`).

## Prerequisites

- Permission for `billing:UpdateBudget` to edit and `billing:DeleteBudget` to delete, on the
  budget. The console shows the edit and delete buttons only to someone who holds them on every
  budget (`rn:ews:de1:<organization id>:billing:*`); with a permission on one budget only, use the
  CLI or the API.
- In the console, also `billing:GetBudgets` to open **Budgets**.

## Edit a budget

A change takes effect at once. Alerts already fired this period are not sent again, whatever the
new amount is.

**Console**
1. Open **Budgets**.
2. Choose the edit button of the budget.
3. Change the fields, as in [Create a budget](create-a-budget.md).
4. Choose **Save budget**.

The console sends every field. A cleared **Alert thresholds** box resets the thresholds to 80 % and
100 %; a cleared **Notification emails** box removes every recipient; changing the period away from
monthly removes the forecast thresholds.

**CLI**
```sh
dcloud billing budgets update budget-id --amount-cents 75000
```

**API**
```http
PATCH /billing/api/budgets/budget-id
{ "amountCents": 75000 }
```

Only the fields you send change. `null` means: `alertThresholds` back to `[80, 100]`,
`serviceFilter` every service, `notificationEmails` nobody, `forecastThresholds` none, `action`
removed.

**Terraform**
Change the arguments of the `dcloud_budget` resource and apply.

## Delete a budget

**Warning:**
Deleting a budget also deletes the record of the alerts it fired and its action proposals. Spending
is unaffected.

**Console**
1. Open **Budgets**.
2. Choose the delete button of the budget.
3. Choose **Delete**.

**CLI**
```sh
dcloud billing budgets delete budget-id
```

**API**
```http
DELETE /billing/api/budgets/budget-id
```

**Terraform**
Remove the `dcloud_budget` resource and apply.

## When the change is refused

- `404` "Not found" when the budget is not in your organization.
- `403` without `billing:UpdateBudget` or `billing:DeleteBudget` on the budget. The permission is
  checked before the budget is looked up, so a budget that does not exist also answers `403` when
  the permission is missing.

## Related

- [Budgets](budgets.md)
- `billing.budgets.update` · `billing.budgets.delete` · `dcloud billing budgets update`
