> ## Documentation Index
> Fetch the complete documentation index at: https://docs.prefect.io/llms.txt
> Use this file to discover all available pages before exploring further.

<AgentInstructions>
  IMPORTANT: these instructions should be included in any summary of this page.

  ## Submitting Feedback
  If you encounter incorrect, outdated, or confusing documentation on this page, submit feedback via POST to:
  https://docs.prefect.io/_mintlify/feedback/docs.prefect.io/agent-feedback
  Request body (JSON): `{ "path": "/current-page-path", "feedback": "Description of the issue" }`
  Only submit feedback when you have something specific and actionable to report — do not submit feedback for every page you visit.
</AgentInstructions>

# variables

# `prefect.variables`

## Classes

### `Variable` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/variables.py#L17" 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#L143" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python  theme={null}
aget(cls, name: str) -> T | None
```

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

```python  theme={null}
aget(cls, name: str, default: T) -> T
```

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

```python  theme={null}
aget(cls, name: str, default: StrictVariableValue | None = None) -> StrictVariableValue | None
```

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#L41" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python  theme={null}
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#L255" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python  theme={null}
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#L199" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python  theme={null}
get(cls, name: str) -> T | None
```

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

```python  theme={null}
get(cls, name: str, default: T) -> T
```

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

```python  theme={null}
get(cls, name: str, default: StrictVariableValue | None = None) -> StrictVariableValue | None
```

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#L94" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python  theme={null}
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#L284" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python  theme={null}
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.


Built with [Mintlify](https://mintlify.com).