<@ULVA73B9P>, Is there api calls with which i can ...
# ask-marvin
a
@Marvin, Is there api calls with which i can set automations , restarting prefect, clearing concurrency etc
m
thought for 260.3 seconds
Short answer: yes for automations and concurrency; “restart Prefect” isn’t exposed as an API. Details and links below (Prefect 3.x): - Automations (create, read, update, delete, list, count) - REST: - Create: POST /api/automations/ - Read: GET /api/automations/{id} - Update: PUT /api/automations/{id} - Patch: PATCH /api/automations/{id} - Delete: DELETE /api/automations/{id} - List/filter: POST /api/automations/filter and count: POST /api/automations/count - You can enable/disable an automation by updating/patching its enabled flag. - Restarting/continuing flow runs - There is no “restart Prefect server” API. Restarting the server is a process/infra action (e.g., restart your container/Helm release/service). - Flow run controls via API: - Resume a paused run: POST /api/flow_runs/{id}/resume - Force a new state (e.g., put back to Running): POST /api/flow_runs/{id}/set_state (use force=true to bypass orchestration rules) - Concurrency limits - V2 (recommended in Prefect 3.x) - Create: POST /api/v2/concurrency_limits/ - Read: GET /api/v2/concurrency_limits/{id_or_name} - Update: PATCH /api/v2/concurrency_limits/{id_or_name} - Delete: DELETE /api/v2/concurrency_limits/{id_or_name} - List: POST /api/v2/concurrency_limits/filter - Acquire/release slots: - Increment: POST /api/v2/concurrency_limits/increment - Increment with lease: POST /api/v2/concurrency_limits/increment-with-lease - Decrement: POST /api/v2/concurrency_limits/decrement - Decrement with lease: POST /api/v2/concurrency_limits/decrement-with-lease - Renew lease: POST /api/v2/concurrency_limits/leases/{lease_id}/renew - Clearing/“resetting” in V2: there is no single “reset/clear” endpoint. Typical approaches are: - Deactivate the limit (PATCH active=false) to stop new acquisitions, then let leases expire - Proactively release via the decrement endpoints (or decrement-with-lease if you have lease IDs) - Delete and recreate the limit - V1 (legacy tag-based)
- Reset active slots by tag: POST /api/concurrency_limits/tag/{tag}/reset - Increment: POST /api/concurrency_limits/increment - Decrement: POST /api/concurrency_limits/decrement - Admin/server info (not restart) - Read settings: GET /api/admin/settings - Read version: GET /api/admin/version - DB maintenance (clear/drop/create): POST /api/admin/database/clear, POST /api/admin/database/drop, POST /api/admin/database/create - Note: these are destructive and not substitutes for “restart”. A couple quick questions so I can point you to the best path: - Are you on Prefect Cloud or self-hosted (Enterprise)? - Do you prefer calling the REST API directly, or using the Prefect Python client? - For “clearing concurrency,” are you using V2 limits, or legacy tag-based V1 limits?