Elizon Docs
Agents

Run Agent (Async)

POST /api/v1/agents/:agentId/run-async — queue an agent run and poll for the result.

Queues an agent run and returns immediately with a job ID, instead of blocking for up to 30 seconds like /run. Use this for anything that might run long, or when you'd rather not hold a connection open.

POST /api/v1/agents/{agentId}/run-async

Path parameters

ParameterTypeDescription
agentIdstring (UUID)The agent to run.

Request body

Identical to /run: message (required), session_id, user_id, tag, tool_context.

Response

202 Accepted

{
  "jobId": "9c4e2a1b-...",
  "agentId": "3f9c...",
  "status": "queued",
  "createdAt": 1732550123
}

Lifecycle

  1. POST /agents/:agentId/run-async → receive a jobId, status queued.
  2. GET /jobs/:jobId (poll) → status moves through queuedrunning → a terminal state.
  3. A terminal state is reached: completed, failed, timeout, or cancelled.
  4. Optionally, POST /jobs/:jobId/cancel at any point before it reaches a terminal state.
Terminal stateMeaning
completedFinished successfully — result is populated on the job.
failedThe run errored — error is populated on the job.
timeoutThe run didn't finish in time.
cancelledCancelled via /jobs/:jobId/cancel before it finished.

See Agent jobs for the full job response shape and cancellation.

  • Poll every 2 seconds for the first 30 seconds — most jobs finish inside that window.
  • After 30 seconds, back off to every 5 seconds until you see a terminal state.
  • Don't poll more than once per second — it burns your rate limit budget for no benefit.

Python example

import asyncio
import httpx

async def run_and_poll(agent_id: str, message: str, api_key: str) -> dict:
    base = "https://api.elizon.com/api/v1"
    headers = {"X-API-Key": api_key, "Content-Type": "application/json"}

    async with httpx.AsyncClient() as client:
        # Submit async job
        r = await client.post(f"{base}/agents/{agent_id}/run-async",
                              headers=headers, json={"message": message})
        job_id = r.json()["jobId"]

        # Poll until terminal
        interval, elapsed = 2, 0
        while True:
            await asyncio.sleep(interval)
            elapsed += interval
            if elapsed > 30:
                interval = 5
            r = await client.get(f"{base}/jobs/{job_id}", headers=headers)
            job = r.json()
            if job["status"] in ("completed", "failed", "timeout", "cancelled"):
                return job

Errors

StatuserrorWhen
400validation error ({ "errors": [...] })message missing/empty, or another field fails validation
403forbiddenThe agent belongs to a different project than your project-scoped key
404agent_not_foundNo agent with that ID exists in your organization
502enqueue_failedThe job couldn't be queued (transient infrastructure error) — safe to retry

Example

curl -X POST https://api.elizon.com/api/v1/agents/{agentId}/run-async \
  -H "X-API-Key: elz_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{"message": "Summarise the Q3 report"}'