Create a conversation with a question, start an agent run, and follow the execution to its result.
Before you start
You need curl, jq, uuidgen, an API credential with permission to create and read runs, and a runnable project agent. This example uses triage-agent in support-assistant.
Create the agent and deploy its project to an available environment first. Set PROJECT_ID to the project's UUID and ENVIRONMENT_ID to that environment's UUID. Replace the project reference in the examples if you use another project.
1. Store the question
Call POST /conversations with an initial user message:
The response contains the conversation ID. The message is stored, but the agent has not executed yet.
2. Start the run
Set the environment ID, then call POST /runs. The run reads its input from the conversation's stored messages.
Expect HTTP 202 and a run object with a top-level id. Keep RUN_ID for subsequent requests. Acceptance does not mean execution has finished.
Reuse the same idempotency key and request body when retrying this creation request. Use a new key for a separate run. A credential without read access receives only run_id and status. Use a credential with read access for this walkthrough.
3. Follow progress
Call GET /runs/{run_id}/stream to replay and follow the run's events:
If the connection drops, reconnect with Last-Event-ID set to the last received SSE event ID. Do not create another run merely to reconnect.
4. Read the result
Call GET /runs/{run_id}:
Repeat the read while status is pending or running. A completed run has status: "completed". Inspect output and the associated conversation messages to verify the response. For a failed run, inspect error and its events.
A waiting run needs the input or resume condition recorded for it. See run lifecycle before submitting a response or resuming execution.
Cancel active work
To stop an active run, call POST /runs/{run_id}/cancel, then read its status again. Reuse the cancellation key when retrying this request:
API references
- Create a conversation, create a run, and read a run.
- Execution GraphQL operations and MCP tools expose their supported execution operations.