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

# concurrency_limits

# `prefect.server.api.concurrency_limits`

Routes for interacting with concurrency limit objects.

This module provides a V1 API adapter that routes requests to the V2 concurrency
system. After the migration, V1 limits are converted to V2, but the V1 API
continues to work for backward compatibility.

## Functions

### `create_concurrency_limit` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/concurrency\_limits.py#L43](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/concurrency_limits.py#L43)</sup>

```python theme={null}
create_concurrency_limit(concurrency_limit: schemas.actions.ConcurrencyLimitCreate, response: Response, db: PrefectDBInterface = Depends(provide_database_interface)) -> schemas.core.ConcurrencyLimit
```

Create a task run concurrency limit.

For more information, see [https://www.prefect.io/docs/v3/concepts/tag-based-concurrency-limits](https://www.prefect.io/docs/v3/concepts/tag-based-concurrency-limits).

### `read_concurrency_limit` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/concurrency\_limits.py#L102](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/concurrency_limits.py#L102)</sup>

```python theme={null}
read_concurrency_limit(concurrency_limit_id: UUID = Path(..., description='The concurrency limit id', alias='id'), db: PrefectDBInterface = Depends(provide_database_interface)) -> schemas.core.ConcurrencyLimit
```

Get a concurrency limit by id.

The `active slots` field contains a list of TaskRun IDs currently using a
concurrency slot for the specified tag.

### `read_concurrency_limit_by_tag` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/concurrency\_limits.py#L148](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/concurrency_limits.py#L148)</sup>

```python theme={null}
read_concurrency_limit_by_tag(tag: str = Path(..., description='The tag name', alias='tag'), db: PrefectDBInterface = Depends(provide_database_interface)) -> schemas.core.ConcurrencyLimit
```

Get a concurrency limit by tag.

The `active slots` field contains a list of TaskRun IDs currently using a
concurrency slot for the specified tag.

### `read_concurrency_limits` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/concurrency\_limits.py#L191](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/concurrency_limits.py#L191)</sup>

```python theme={null}
read_concurrency_limits(limit: int = dependencies.LimitBody(), offset: int = Body(0, ge=0), db: PrefectDBInterface = Depends(provide_database_interface)) -> Sequence[schemas.core.ConcurrencyLimit]
```

Query for concurrency limits.

For each concurrency limit the `active slots` field contains a list of TaskRun IDs
currently using a concurrency slot for the specified tag.

### `reset_concurrency_limit_by_tag` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/concurrency\_limits.py#L241](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/concurrency_limits.py#L241)</sup>

```python theme={null}
reset_concurrency_limit_by_tag(tag: str = Path(..., description='The tag name'), slot_override: Optional[List[UUID]] = Body(None, embed=True, description='Manual override for active concurrency limit slots.'), db: PrefectDBInterface = Depends(provide_database_interface)) -> None
```

### `delete_concurrency_limit` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/concurrency\_limits.py#L316](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/concurrency_limits.py#L316)</sup>

```python theme={null}
delete_concurrency_limit(concurrency_limit_id: UUID = Path(..., description='The concurrency limit id', alias='id'), db: PrefectDBInterface = Depends(provide_database_interface)) -> None
```

### `delete_concurrency_limit_by_tag` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/concurrency\_limits.py#L374](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/concurrency_limits.py#L374)</sup>

```python theme={null}
delete_concurrency_limit_by_tag(tag: str = Path(..., description='The tag name'), db: PrefectDBInterface = Depends(provide_database_interface)) -> None
```

### `increment_concurrency_limits_v1` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/concurrency\_limits.py#L440](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/concurrency_limits.py#L440)</sup>

```python theme={null}
increment_concurrency_limits_v1(names: List[str] = Body(..., description='The tags to acquire a slot for'), task_run_id: UUID = Body(..., description='The ID of the task run acquiring the slot'), db: PrefectDBInterface = Depends(provide_database_interface)) -> List[MinimalConcurrencyLimitResponse]
```

Increment concurrency limits for the given tags.

During migration, this handles both V1 and V2 limits to support mixed states.
Post-migration, it only uses V2 with lease-based concurrency.

### `decrement_concurrency_limits_v1` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/concurrency\_limits.py#L575](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/concurrency_limits.py#L575)</sup>

```python theme={null}
decrement_concurrency_limits_v1(names: List[str] = Body(..., description='The tags to release a slot for'), task_run_id: UUID = Body(..., description='The ID of the task run releasing the slot'), db: PrefectDBInterface = Depends(provide_database_interface)) -> List[MinimalConcurrencyLimitResponse]
```

Decrement concurrency limits for the given tags.

Finds and revokes the lease for V2 limits or decrements V1 active slots.
Returns the list of limits that were decremented.

## Classes

### `Abort` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/concurrency\_limits.py#L428](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/concurrency_limits.py#L428)</sup>

### `Delay` <sup>[https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/concurrency\_limits.py#L433](https://github.com/PrefectHQ/prefect/blob/main/src/prefect/server/api/concurrency_limits.py#L433)</sup>
