# Change a budget

> Change a Budgets budget's amount, filter or thresholds, pause it, or delete it, without overwriting someone else's change.

This guide raises a budget's amount, pauses it, and deletes it. It also explains what happens when
two people change the same budget at once.

## Before you begin

You need a budget to change. See [Create a budget](/budgets/guides/create-a-budget). For the Python examples, create the
[Python client](/budgets/guides/use-the-python-client).

## 1. Change the amount or thresholds

The CLI changes only the options you give it and keeps the rest:

```sh
openstack budget set compute-monthly --amount 1500
```

`--threshold` replaces all of the budget's thresholds, so repeat every threshold you want to keep.
`--no-service`, `--no-region` and `--no-usage-type` clear a filter.

The API and Python client replace the whole budget, and the request carries the `revision` you
read. Read the budget, change it, and write it back:

<CodeBlockTabs defaultValue="Python">
  <CodeBlockTabsList>
    <CodeBlockTabsTrigger value="Python">
      Python
    </CodeBlockTabsTrigger>

    <CodeBlockTabsTrigger value="API">
      API
    </CodeBlockTabsTrigger>
  </CodeBlockTabsList>

  <CodeBlockTab value="Python">
    ```python
    from budgetclient.v1.budgets import to_update_spec

    current = budgets.budgets.find("compute-monthly")
    spec = to_update_spec(current)
    spec["amount"] = "1500"
    budgets.budgets.update(current["id"], **spec)
    ```
  </CodeBlockTab>

  <CodeBlockTab value="API">
    ```sh
    curl --request PUT https://budget.public.global.vexxhost.net/v1/budgets/c7e1a5b3-9d2f-4e8c-a6b4-1f3d5e7c9a2b \
      --header "X-Auth-Token: $TOKEN" \
      --header "Content-Type: application/json" \
      --data '{
        "revision": 1,
        "name": "compute-monthly",
        "amount": "1500",
        "period": "monthly",
        "filter": {"services": ["compute"]},
        "thresholds": [
          {"name": "warn", "basis": "actual", "unit": "percentage", "value": "80",
           "channels": ["3f9c1e7a-2b4d-4c6e-8a1f-5d7b9e2c4a6f"]},
          {"name": "overrun", "basis": "forecasted", "unit": "percentage", "value": "100",
           "channels": ["3f9c1e7a-2b4d-4c6e-8a1f-5d7b9e2c4a6f"]}
        ]
      }'
    ```
  </CodeBlockTab>
</CodeBlockTabs>

If someone changed the budget after you read it, the API refuses the update with `409 Conflict`
instead of overwriting their change. Read the budget again and reapply yours. The CLI reads the
budget for you, so this only happens when two changes land within moments of each other.

## 2. Pause or resume it

A budget that is turned off is not checked and sends no alerts, but keeps its settings and
history:

```sh
openstack budget set compute-monthly --disable
openstack budget set compute-monthly --enable
```

Turning a budget off and on again in the same window does not repeat an alert it already sent.

## 3. Delete it

Deleting a budget also deletes its window and alert history:

```sh
openstack budget delete compute-monthly
```

## Verify

```sh
openstack budget show compute-monthly -c amount -c enabled -c revision
```

```
+----------+-------+
| Field    | Value |
+----------+-------+
| amount   | 1500  |
| enabled  | True  |
| revision | 2     |
+----------+-------+
```

Each change increases `revision` by one.

## Next steps

* Review what a budget has sent with `openstack budget notification list compute-monthly`.
* See every option of `budget set` in the [CLI reference](/budgets/cli/budget/budget-set).
