Back to Prefect

api

docs/v3/api-ref/python/prefect-cli-api.mdx

3.8.01.1 KB
Original Source

prefect.cli.api

API command — native cyclopts implementation.

Make direct requests to the Prefect API.

Functions

api_request <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/prefect/cli/api.py#L130" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

python
api_request(method: Annotated[str, cyclopts.Parameter(help='HTTP method (GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS)')], path: Annotated[str, cyclopts.Parameter(help='API path (e.g., /flows, /flows/filter)')])

Make a direct request to the Prefect API.

Examples:

bash
# GET request
$ prefect api GET /flows/abc-123

# POST request with data
$ prefect api POST /flows/filter --data '{"limit": 10}'

# POST to filter endpoint (defaults to empty object)
$ prefect api POST /flows/filter

# Custom headers
$ prefect api POST /flows/filter -H "X-Custom: value" --data '{}'

# Verbose output
$ prefect api GET /flows --verbose

# Account-level operation (Cloud)
$ prefect api GET /workspaces --account

# API root level (Cloud only)
$ prefect api GET /me --root