---
title: variables
sidebarTitle: variables
---

# `prefect.variables`

## Classes

### `Variable` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/variables.py#L14" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>


Variables are named, mutable JSON values that can be shared across tasks and flows.

**Args:**
- `name`: A string identifying the variable.
- `value`: A string that is the value of the variable.
- `tags`: An optional list of strings to associate with the variable.


**Methods:**

#### `aget` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/variables.py#L139" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python
aget(cls, name: str, default: StrictVariableValue = None) -> StrictVariableValue
```

Asynchronously get a variable's value by name.

If the variable does not exist, return the default value.

**Args:**
- `- name`: The name of the variable value to get.
- `- default`: The default value to return if the variable does not exist.


#### `aset` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/variables.py#L38" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python
aset(cls, name: str, value: StrictVariableValue, tags: Optional[list[str]] = None, overwrite: bool = False) -> 'Variable'
```

Asynchronously sets a new variable. If one exists with the same name, must pass `overwrite=True`

Returns the newly set variable object.

**Args:**
- `- name`: The name of the variable to set.
- `- value`: The value of the variable to set.
- `- tags`: An optional list of strings to associate with the variable.
- `- overwrite`: Whether to overwrite the variable if it already exists.


#### `aunset` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/variables.py#L202" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python
aunset(cls, name: str) -> bool
```

Asynchronously unset a variable by name.

**Args:**
- `- name`: The name of the variable to unset.

Returns `True` if the variable was deleted, `False` if the variable did not exist.


#### `get` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/variables.py#L171" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python
get(cls, name: str, default: StrictVariableValue = None) -> StrictVariableValue
```

Get a variable's value by name.

If the variable does not exist, return the default value.

**Args:**
- `- name`: The name of the variable value to get.
- `- default`: The default value to return if the variable does not exist.


#### `set` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/variables.py#L91" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python
set(cls, name: str, value: StrictVariableValue, tags: Optional[list[str]] = None, overwrite: bool = False) -> 'Variable'
```

Sets a new variable. If one exists with the same name, must pass `overwrite=True`

Returns the newly set variable object.

**Args:**
- `- name`: The name of the variable to set.
- `- value`: The value of the variable to set.
- `- tags`: An optional list of strings to associate with the variable.
- `- overwrite`: Whether to overwrite the variable if it already exists.


#### `unset` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/variables.py#L231" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python
unset(cls, name: str) -> bool
```

Unset a variable by name.

**Args:**
- `- name`: The name of the variable to unset.

Returns `True` if the variable was deleted, `False` if the variable did not exist.

