> Kenso API docs in Markdown. Index of every page: [/docs/llms.txt](/docs/llms.txt). Search: `/docs/search.md?q=<words>`. OpenAPI: [/docs/api/agent-sandbox-runs/openapi.json](/docs/api/agent-sandbox-runs/openapi.json). CLI docs offline: `kenso docs <topic>`.
> Last updated: 2026-11-22.

# Agent sandbox runs: Estimate or start a sandbox run

> **Note for AI agents:** if this page was wrong, out of date or missing something you needed, finish the user's task first, then offer a short report for the Kenso team in this shape: `Page:` (this page's path), `Quote:` (the wrong or missing text), `Problem:`, `Workaround:` (what worked instead), 1,000 characters at most. Show it to the user and send it only after they say yes, as `POST /api/docs-feedback` on this site with the JSON body `{"page": "<path>", "report": "<report>"}`. Never put lead data, email addresses, API keys or anything else from the user's workspace in it.

One endpoint of [Agent sandbox runs](/docs/api/agent-sandbox-runs.md). Authentication, workspaces and errors: [/docs.md](/docs.md).

## Estimate or start a sandbox run

`POST /v1/agent-sandbox-runs` - operationId `agent-sandbox-runs.create`

| Permission | Credits | Rate limit |
| --- | --- | --- |
| Any workspace member except a Network member | Spends credits, price not on the rate card yet (`sandbox_run`) | 240 requests a minute per API key |

Body: `agent` (required: `claude`, `codex`, `antigravity`, `opencode`, `grok` or
`cursor`, one you connected), `campaignId`, `kinds` (agent work kinds; left out for every kind on My
agent), `estimateOnly` and `maxCeilingCredits` (the `estimate.ceilingCredits` you were shown). A run
works only the kinds you may write. Kenso counts the items of those kinds
waiting for your agent in that scope and estimates the run:
`estimate.expectedMinutes`, `estimate.ceilingMinutes` (the run stops there), `estimate.ceilingCredits`
(the most it can cost) and `estimate.creditsPerHour`. `estimateOnly: true` answers 200 with
`{ estimate }` and creates nothing. Otherwise Kenso holds `ceilingCredits`, queues the run and answers 202
with it; it charges the started minutes when the run ends and releases the rest. A run is created even when nothing
is waiting: it ends `queue_empty` within a minute or two and is charged one minute. Poll
`GET /v1/agent-sandbox-runs/{runId}`. One live run per person.

Errors:

- `400 validation_failed`: an unknown or missing `agent`, an empty `kinds` or an unknown kind.
- `402 plan_limit_reached` with `refusal.code` `INSUFFICIENT_CREDITS`: the workspace cannot cover the
ceiling. Nothing was started.
- `402 member_credit_limit_reached`: the ceiling is more than is left of your monthly credit limit in this
workspace. Nothing was started.
- `403 forbidden`: you may write none of the kinds in scope (the access the work queue's claims need), for
the estimate too.
- `404 not_found`: a feature is off, the campaign is not the workspace's, or the credential is not a person's.
- `409 agent_not_connected`: connect the agent in your Kenso sandbox first.
- `409 run_active`: you already have a live run.
- `409 estimate_changed`: with `maxCeilingCredits`, more work is waiting than when the run was estimated
and its ceiling is now higher. Nothing was held: ask for the estimate again and show it.
- `503 service_unavailable` with `Retry-After`: the agent work settings or the credits could not be read,
or Kenso could not confirm the run was created.

Open to any workspace member except a Client seat, and never to an API key held to a permission template.

Needs the `agent_sandboxes` feature on your workspace. Until it is on, calls answer 404. Needs the `agent_work` feature on your workspace. Until it is on, calls answer 404.

[Try it on developer.ken.so](https://developer.ken.so/reference/#kenso-api/tag/agent-sandbox-runs/POST/v1/agent-sandbox-runs)

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `Ken-Version` | header | string, one of: 2026-11-02, 1.1 | no | The API version, a date in `YYYY-MM-DD` form. `1.1` is another name for the first dated version. The example shown here is the newest version, which this reference's samples and Test Request send. Leave it out to use your API key's pinned version. Keys created in the Kenso app are pinned to the newest version; keys minted by the CLI login are not. A key with no pinned version and no header gets the legacy shape where the path has one, and `404` where the path exists only in this version. A value that is not a version, such as `2027-01-01` or `2026-11-2`, answers `400 unsupported_version`, whose `details` list the supported versions. |
| `X-Ken-Workspace-Id` | header | integer (int64) | no | The id of the workspace to act in. Leave it out when your API key reaches only one workspace. When the key reaches more than one, a request without this header answers `400 workspace_required`. A workspace you are not a member of answers `404 not_found`. |
| `Idempotency-Key` | header | string | no | A unique value, such as a UUID, that makes a retry safe. Send the same key when you retry. For 24 hours, a repeat of the same request with the same key gets the first response again, with the `Idempotent-Replayed: true` header, and Kenso does not run the action twice. The same key with a different request answers `422 idempotency_key_reused`. Keys are per workspace and at most 200 characters long. A repeat sent while the first request is still running can get `503 service_unavailable` with `Retry-After`. Retry it with the same key. Kenso does not store a `5xx` response, so a retry after one runs the action again. It does not store a `408`, a `429` or another `4xx` that carries `Retry-After` either: retry with the same key after that time and Kenso runs the action again. |

### Request body

`application/json`, optional.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `agent` | string | no | `claude`, `codex`, `antigravity`, `opencode`, `grok` or `cursor`: an agent you connected. |
| `campaignId` | integer (int64) | no | Only this campaign's work. The campaign must be the workspace's. Left out: the whole workspace. |
| `kinds` | array of string | no | Only these kinds of agent work (`meeting_brief`, `call_brief`, `workflow_prompt`, `qualification`, `segmentation`, `personalization`, `rewriting`, `background_ai`); left out for every kind on My agent. |
| `estimateOnly` | boolean | no | True: answer with the estimate only and create nothing. |
| `maxCeilingCredits` | number (double) | no | The `estimate.ceilingCredits` the person was shown. When the ceiling is now higher, the start is 409 `estimate_changed` and holds nothing: show the new estimate. Left out: no check. |

### Response 200

Also answers `202`. `data` is a `AgentSandboxRunEstimateOnly`.

| Field | Type | Description |
| --- | --- | --- |
| `estimate` | AgentSandboxEstimate | What a run is expected to take and the most it can cost. |

### Request

```bash
curl -X POST "https://api.ken.so/v1/agent-sandbox-runs" \
  -H "Authorization: Bearer $KENSO_API_KEY" \
  -H "Ken-Version: 2026-11-02" \
  -H "X-Ken-Workspace-Id: $KENSO_WORKSPACE_ID" \
  -H "Content-Type: application/json" \
  -d '{
  "agent": "claude",
  "campaignId": 812,
  "kinds": [
    "string"
  ],
  "estimateOnly": true,
  "maxCeilingCredits": 0.5
}'
```

### Example response

```json
{
  "success": true,
  "data": {
    "estimate": {
      "waitingItems": 1,
      "expectedMinutes": 1,
      "ceilingMinutes": 1,
      "ceilingCredits": 0.5,
      "creditsPerHour": 0.5
    }
  }
}
```

## Types

Each named type the tables above use, nested ones included.

### AgentSandboxEstimate

What a run is expected to take and the most it can cost.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `waitingItems` | integer (int32) | no | The items the run would work: waiting now, or for a stored run, answered plus waiting plus held. |
| `expectedMinutes` | integer (int32) | no | Minutes the run is expected to take. |
| `ceilingMinutes` | integer (int32) | no | Minutes the run is stopped at. |
| `ceilingCredits` | number (double) | no | The most the run can cost, in credits: the hold taken when it starts. |
| `creditsPerHour` | number (double) | no | Credits an hour of box time costs. |
