Skip to main content
A run is a single execution of an agent with a specific prompt. You create a run, execute it, and then retrieve the results.
This page covers the run lifecycle APIs. If you want the simpler one-call execute flow that returns the final answer directly, see Execute.

Run lifecycle

List runs

Endpoint
Retrieve runs for your organization with optional filters and cursor-based pagination.

Query parameters

Response

The prompt field is truncated to 200 characters in list responses. Use the details endpoint to get the full prompt.

Step 1: Create a run

Endpoint
Creating a run queues it — it does not start execution. This lets you register watchers before the agent starts working.

Run parameters

Guidance vs. instructions

The agent’s instructions define its general behavior. The run’s guidance adds context for a specific execution:

Model override

Use a different model for a specific run without changing the agent:

Object ID scoping

Restrict a run to specific vault objects at runtime. This is useful when you want a general-purpose agent to only work with specific documents for a particular task:
Object scoping is applied at runtime, not at agent creation. This means the same agent can work with different sets of documents on each run. The agent’s vaultIds restriction (set at creation) is still enforced — objectIds adds a further narrowing within allowed vaults.

Step 2: Execute the run

Endpoint
Execution starts a durable workflow that spins up a sandbox and runs the agent. The endpoint returns immediately — the work happens in the background.
Response
Exec is a one-shot operation. Calling exec on a run that’s already been started returns 409 Conflict. Each run can only be executed once.

Step 3: Wait for completion

Two options: poll the status endpoint, or register a watcher before executing.

Option A: Poll

Option B: Watch (webhook callback)

Register a callback URL before executing. You’ll receive a POST when the run completes:
See Monitoring & Analysis for details on webhook payloads and polling patterns.

Step 4: Stream run events

Endpoint
The run events endpoint streams SSE for run execution with server-side replay buffering. It includes synthetic terminal events emitted by Case.dev:
  • run.completed
  • run.failed
  • run.cancelled
Use this endpoint to drive live progress UI and to recover from disconnects.

Replay after reconnect

You can replay from a sequence number using either:
  • Query param: lastEventId
  • Header: Last-Event-ID
Example SSE events
If the run is already terminal when you connect, the endpoint returns buffered events and then sends a close event.

Cancel a run

Endpoint
Cancel a queued or running run. Cancelling a completed run returns the current status without error.

Complete example

Create an agent, run a complex multi-step task, and get the results:

Typical run times

Most of the run time is the AI thinking and making API calls — sandbox startup is under 10 seconds.

Next: Monitor and analyze

Learn how to get detailed results, audit trails, and set up webhooks →