Invoke an agent asynchronously. Returns immediately with a task ID and status: "pending". Poll the Get Task endpoint to check when results are ready.
Use this for long-running tasks, background processing, or when you don’t want to block a request.
Path Parameters
Request Body
The request body is identical to Invoke Agent (Sync) .
input.text is required
input.user.id is required
input.user.email is required
user_oidc_token is optional for MCP OAuth-backed tools
The message or prompt to send to the agent.
End user identity. External user ID from your system.
Optional OIDC token for MCP OAuth-authenticated tools.
Thread ID for multi-turn conversations. Pass the id from a previous task to continue the conversation.
disable_attachment_injection
default or harder. Controls reasoning depth.
Additional instructions appended to the system prompt for this invocation only.
Natural-language description of desired output
Query Parameters
Agent version to invoke. Defaults to latest deployed. Use "draft" to test undeployed changes.
Response
Returns immediately with the task object in pending state.
Task ID — use this to poll for results via Get Task
Always pending on initial return. Transitions to executing → completed (or failed/error).
null until the task completes
Basic Example
curl -s -X POST "https://api.xpander.ai/v1/agents/<agent-id>/invoke/async" \
-H "Content-Type: application/json" \
-H "x-api-key: <your-api-key>" \
-d '{"input": {"text": "Analyze competitor pricing for Q1 2026"}}'
Response (immediate):
{
"id" : "81250b20-e9d7-4b3b-9995-07dc72b4bb59" ,
"agent_id" : "<agent-id>" ,
"status" : "pending" ,
"result" : null ,
"created_at" : "2026-02-07T02:13:26.325626Z"
}
Polling for Results
# 1. Start the async task
TASK_ID =$( curl -s -X POST "https://api.xpander.ai/v1/agents/<agent-id>/invoke/async" \
-H "Content-Type: application/json" \
-H "x-api-key: <your-api-key>" \
-d '{"input": {"text": "Generate a market report"}}' | jq -r '.id' )
echo "Task started: $TASK_ID "
# 2. Poll until done
while true ; do
RESPONSE =$( curl -s "https://api.xpander.ai/v1/tasks/ $TASK_ID " \
-H "x-api-key: <your-api-key>" )
STATUS =$( echo " $RESPONSE " | jq -r '.status' )
echo "Status: $STATUS "
if [ " $STATUS " = "completed" ] || [ " $STATUS " = "failed" ] || [ " $STATUS " = "error" ]; then
echo " $RESPONSE " | jq -r '.result'
break
fi
sleep 2
done
Example Response (After Completion)
Poll the task after it finishes to get the full result:
{
"id" : "81250b20-e9d7-4b3b-9995-07dc72b4bb59" ,
"agent_id" : "<agent-id>" ,
"status" : "completed" ,
"input" : {
"text" : "Analyze competitor pricing for Q1 2026" ,
"user" : null
},
"result" : "Based on my analysis, the three main competitors..." ,
"created_at" : "2026-02-07T02:13:26.325626Z" ,
"finished_at" : "2026-02-07T02:13:41.897000Z" ,
"source" : "api"
}
Task Status Flow
pending → executing → completed | failed | error | stopped
For multi-turn conversations, always wait for a task to reach completed before sending the next message with the same id. Sending a follow-up while the previous task is still executing may cause unexpected behavior.
See Also
API Key for authentication
The agent/workflow version to invoke. default = latest
input
AgentExecutionInput · object
required
Pass the id from a previous response to continue a multi-turn conversation with the same agent. Omit for a new conversation.
Example: "02843b37-4d77-48a0-8da7-2c76afe54401"
Unique task identifier. Use this to poll for results when invoking async.
Example: "02843b37-4d77-48a0-8da7-2c76afe54401"
Example: "47c3b020-9a6b-4699-8d94-d92d71929b53"
Example: "91fbe9bc-35b3-41e8-b59d-922fb5a0f031"
pending | executing | completed | error
Available options:
pending,
executing,
completed,
error,
failed,
stopped
The agent's response. Populated when status is 'completed'. Null for async until polling shows completed.
Example: "2026-04-10T19:01:22.898813Z"
Null until the task completes.
Example: "2026-04-10T19:01:33.120590Z"