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

# variables

# `prefect.server.api.variables`

Routes for interacting with variable objects

## Functions

### `get_variable_or_404` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/variables.py#L23](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/variables.py#L23)</sup>

```python theme={null}
get_variable_or_404(session: AsyncSession, variable_id: UUID) -> orm_models.Variable
```

Returns a variable or raises 404 HTTPException if it does not exist

### `get_variable_by_name_or_404` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/variables.py#L37](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/variables.py#L37)</sup>

```python theme={null}
get_variable_by_name_or_404(session: AsyncSession, name: str) -> orm_models.Variable
```

Returns a variable or raises 404 HTTPException if it does not exist

### `create_variable` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/variables.py#L56](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/variables.py#L56)</sup>

```python theme={null}
create_variable(variable: actions.VariableCreate, db: PrefectDBInterface = Depends(provide_database_interface)) -> core.Variable
```

Create a variable.

For more information, see [https://www.prefect.io/docs/v3/concepts/variables](https://www.prefect.io/docs/v3/concepts/variables).

### `read_variable` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/variables.py#L80](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/variables.py#L80)</sup>

```python theme={null}
read_variable(variable_id: UUID = Path(..., alias='id'), db: PrefectDBInterface = Depends(provide_database_interface)) -> core.Variable
```

### `read_variable_by_name` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/variables.py#L91](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/variables.py#L91)</sup>

```python theme={null}
read_variable_by_name(name: str = Path(...), db: PrefectDBInterface = Depends(provide_database_interface)) -> core.Variable
```

### `read_variables` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/variables.py#L102](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/variables.py#L102)</sup>

```python theme={null}
read_variables(limit: int = LimitBody(), offset: int = Body(0, ge=0), variables: Optional[filters.VariableFilter] = None, sort: sorting.VariableSort = Body(sorting.VariableSort.NAME_ASC), db: PrefectDBInterface = Depends(provide_database_interface)) -> List[core.Variable]
```

### `count_variables` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/variables.py#L120](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/variables.py#L120)</sup>

```python theme={null}
count_variables(variables: Optional[filters.VariableFilter] = Body(None, embed=True), db: PrefectDBInterface = Depends(provide_database_interface)) -> int
```

### `update_variable` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/variables.py#L132](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/variables.py#L132)</sup>

```python theme={null}
update_variable(variable: actions.VariableUpdate, variable_id: UUID = Path(..., alias='id'), db: PrefectDBInterface = Depends(provide_database_interface)) -> None
```

### `update_variable_by_name` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/variables.py#L148](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/variables.py#L148)</sup>

```python theme={null}
update_variable_by_name(variable: actions.VariableUpdate, name: str = Path(..., alias='name'), db: PrefectDBInterface = Depends(provide_database_interface)) -> None
```

### `delete_variable` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/variables.py#L164](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/variables.py#L164)</sup>

```python theme={null}
delete_variable(variable_id: UUID = Path(..., alias='id'), db: PrefectDBInterface = Depends(provide_database_interface)) -> None
```

### `delete_variable_by_name` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/variables.py#L177](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/variables.py#L177)</sup>

```python theme={null}
delete_variable_by_name(name: str = Path(...), db: PrefectDBInterface = Depends(provide_database_interface)) -> None
```
