Submit a new long-running agent task for asynchronous execution.
Unique key to prevent duplicate job submissions. If a job with this key already exists, the existing job is returned.
The task prompt or instruction for the agent to execute.
Path to the agent configuration YAML file. Defaults to agents.yaml.
Framework to use for execution. Defaults to praisonai.
Maximum execution time in seconds. Defaults to 3600 (1 hour).
URL to receive a callback when the job completes. The callback includes the job result.
Group related jobs together with a session identifier.
Response
Unique identifier for the submitted job (e.g., run_abc123).
Initial job status, typically queued.
ISO 8601 timestamp of job creation.
URL to poll for job status updates.
URL for SSE streaming of job progress.
| Header | Description |
|---|
Location | URL to poll for job status |
Retry-After | Recommended seconds before first poll |
curl -X POST http://127.0.0.1:8005/api/v1/runs \
-H "Content-Type: application/json" \
-H "Idempotency-Key: unique-key-123" \
-d '{
"prompt": "Analyze the quarterly sales data",
"timeout": 3600,
"webhook_url": "https://example.com/callback",
"session_id": "project-alpha"
}'
{
"job_id": "run_abc123",
"status": "queued",
"created_at": "2025-01-01T00:00:00Z",
"poll_url": "http://127.0.0.1:8005/api/v1/runs/run_abc123",
"stream_url": "http://127.0.0.1:8005/api/v1/runs/run_abc123/stream"
}
Idempotency
Use the Idempotency-Key header to ensure a job is only created once, even if the request is retried:
import httpx
# Safe to retry - same key returns existing job
for attempt in range(3):
try:
response = httpx.post(
"http://127.0.0.1:8005/api/v1/runs",
json={"prompt": "Process data"},
headers={"Idempotency-Key": "unique-operation-id"},
timeout=10
)
break
except httpx.TimeoutException:
continue
Webhook Callback
When webhook_url is provided, the server sends a POST request to that URL when the job completes:
{
"job_id": "run_abc123",
"status": "succeeded",
"result": "Task output here",
"duration_seconds": 45.2
}
Error Responses
| Status | Description |
|---|
400 | Bad request - missing or invalid prompt |
409 | Conflict - duplicate idempotency key |
422 | Validation error - invalid request body |
500 | Internal server error |
See Also