Overview
The async API pattern is ideal when you want to submit multiple long-running tasks and check their status later. Instead of waiting for each run to complete, you submit all requests and get back run IDs that you can poll for completion.How It Works
- Submit requests to
/v1/automation/run-async, which returns correspondingrun_ids, which you will need if you want to check the status of a particular run. - Check individual runs with
GET /v1/runs/:idto check status - Or fetch all runs with
GET /v1/runsto monitor batch progress
Basic Example
Submit multiple mino runs and poll for completion:Fire and Forget Pattern
Submit tasks without waiting for completion:When to Use Async vs Sync
| Use Case | API Pattern | Why |
|---|---|---|
| Quick tasks (<30s) | Sync /run | Simpler code, immediate results |
| Long-running tasks | Async /run-async | Don’t block, check later |
| Large batches | Async /run-async | Submit all at once, monitor progress |
| Fire and forget | Async /run-async | No need to wait |
| Real-time feedback | SSE /run-sse | Stream progress events |
Best Practices
Polling Interval
- Short tasks (under 1 min): Poll every 2-3 seconds
- Medium tasks (1-5 min): Poll every 5-10 seconds
- Long tasks (over 5 min): Poll every 30-60 seconds
Error Handling
Always check run status and handle failures:Python