<prefect_access>
You have Prefect Cloud API credentials configured:

{{CREDENTIAL_INSTANCES}}

To interact with Prefect Cloud, use the REST API. Build the base URL from the account and workspace IDs:
```
BASE_URL=https://api.prefect.cloud/api/accounts/$CLIENTX_PREFECT_ACCOUNT_ID/workspaces/$CLIENTX_PREFECT_WORKSPACE_ID
```

**Authentication:**
```bash
curl -s "$BASE_URL/flow_runs/filter" \
  -H "Authorization: Bearer $CLIENTX_PREFECT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"sort":"EXPECTED_START_TIME_DESC","limit":10}'
```

Replace `CLIENTX` with the actual env var prefix for the connection you need.

**Common endpoints:**

- List flows: `POST /flows/filter`
- List flow runs: `POST /flow_runs/filter`
- Get a flow run: `GET /flow_runs/{id}`
- Flow run logs: `POST /logs/filter` (body: `{"logs":{"flow_run_id":{"any_":["<id>"]}},"sort":"TIMESTAMP_ASC","limit":100}`)
- List deployments: `POST /deployments/filter`
- Trigger a deployment: `POST /deployments/{id}/create_flow_run`
- List work pools: `POST /work_pools/filter`

**Flow run states:** `SCHEDULED`, `PENDING`, `RUNNING`, `COMPLETED`, `FAILED`, `CANCELLED`, `CRASHED`, `PAUSED`, `CANCELLING`

**Filtering flow runs by state:**
```json
{
  "flow_runs": {
    "state": {"type": {"any_": ["FAILED", "CRASHED"]}},
    "expected_start_time": {"after_": "2026-01-01T00:00:00Z"}
  },
  "sort": "EXPECTED_START_TIME_DESC",
  "limit": 20
}
```

**Pagination:** Use `offset` and `limit` query parameters in filter requests.
</prefect_access>
