Skip to main content

The problem

You need AI to do real work — not just generate text, but search your vaults, run legal research, compile reports, and upload results. But LLM API calls are stateless: no file system, no tools, no persistence.

The solution

An agent is a reusable AI executor that runs in an isolated sandbox with the full Case.dev platform. Define it once with instructions, then create runs against it with different prompts. Each run spins up a dedicated container with OpenCode (AI coding agent) and the casedev CLI pre-authenticated. The agent can search vaults, run legal research, process documents, write files, and upload results — autonomously.
┌─────────────────────────────────────────────────────────────────┐
│  1. DEFINE                                                      │
│     Create an agent with a name and instructions                │
│                           ↓                                     │
│  2. RUN                                                         │
│     Submit a prompt → a sandbox spins up automatically          │
│     The AI works through the task using all available tools     │
│                           ↓                                     │
│  3. RESULTS                                                     │
│     Get the output, every tool call, and token usage            │
│     Files uploaded to vaults persist after the sandbox exits    │
└─────────────────────────────────────────────────────────────────┘

Quick start

# 1. Create an agent
AGENT=$(curl -s -X POST https://api.case.dev/agent/v1/agents \
  -H "Authorization: Bearer $CASEDEV_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Contract Reviewer",
    "instructions": "You review contracts and flag risky clauses. Use the casedev CLI to search vaults and analyze documents."
  }')
AGENT_ID=$(echo $AGENT | jq -r '.id')

# 2. Create a run
RUN=$(curl -s -X POST https://api.case.dev/agent/v1/run \
  -H "Authorization: Bearer $CASEDEV_API_KEY" \
  -H "Content-Type: application/json" \
  -d "{
    \"agentId\": \"$AGENT_ID\",
    \"prompt\": \"Review the NDA in vault vault_xxx for liability issues\"
  }")
RUN_ID=$(echo $RUN | jq -r '.id')

# 3. Execute the run
curl -s -X POST "https://api.case.dev/agent/v1/run/$RUN_ID/exec" \
  -H "Authorization: Bearer $CASEDEV_API_KEY"

# 4. Poll for results
curl -s "https://api.case.dev/agent/v1/run/$RUN_ID/status" \
  -H "Authorization: Bearer $CASEDEV_API_KEY"

# 5. Get full results when complete
curl -s "https://api.case.dev/agent/v1/run/$RUN_ID/details" \
  -H "Authorization: Bearer $CASEDEV_API_KEY"

How it works

  1. Define an agent with a name, instructions, and optional model/vault restrictions
  2. Create a run with a prompt — this queues it without executing
  3. Execute the run — a durable workflow spins up a sandbox and starts the AI
  4. Poll or watch — check status or register a callback URL for completion notifications
  5. Get results — full output plus every tool call, token count, and execution logs
Create and execute are separate steps by design. This lets you register a watcher callback before execution starts, or batch-create multiple runs and execute them on a schedule.

Next steps