Execute a published agent asynchronously
POSThttps://platform.docana.com/api/v1/agents/:agentId/execute/
Validates the request, schedules a background run of the published agent version and returns immediately with both the executionId and assistantMessageId handles the run will use. Output content is populated asynchronously. Body: { prompt: string, threadId?: string, context?: object, waitSeconds?: number, deliverToChannel?: boolean }. With deliverToChannel: true and a threadId, the run's output (and any follow-up it schedules) is also sent through the channel the thread came in on, to the sender of its latest inbound message; without it the reply is only stored. Poll getAgentExecution with the returned id for status, node outputs and the threadId. An agent whose published spec has workflow.dispatch: "queued", or any run above the application's concurrency limit, is handed to the workers instead: the acknowledgement carries executionStatus: "QUEUED" and the execution row exists right away, waiting for a worker. For an in-process run the row appears once the background run starts, so a brief 404 right after scheduling means "not started yet" while a persistent one means the run failed to start. Optional bounded wait: waitSeconds (1-120) holds the response until the run settles or the window elapses; the response then carries waitOutcome (completed, failed or timeout) and, when the run settled, executionStatus. A timeout never cancels the run — keep polling getAgentExecution with the same executionId. Supports the Idempotency-Key header: a retry with the same key and body replays the stored ack (same executionId) instead of running the agent a second time. waitSeconds is a delivery preference, not part of the request identity: it is excluded from the idempotency payload hash, and replays return the stored asynchronous ack immediately without waiting.
Request
Responses
- 200
- 400
- 401
- 403
- 404
- 409
- 422
- 429
- 500
- 503
The run was scheduled
Invalid JSON body, missing prompt, invalid waitSeconds, deliverToChannel without threadId, or agent without application
The API key or session is missing, expired, or malformed.
No access to the application or thread
Agent or thread not found
Agent not published, or Idempotency-Key conflict/in-progress
deliverToChannel was set but the thread has no inbound channel message to deliver to
The application already has its maximum number of executions in flight and the execution queue is off; retry after the Retry-After seconds
Unexpected server error.
The execution could not be accepted or handed to the workers (a transient database or queue failure); retry after the Retry-After seconds with the same Idempotency-Key