---
title: Run one terminal command in the worktree
description: "Command-at-a-time execution in the run's sandbox worktree (WIBLO-130) — no PTY."
api_method: POST
api_path: "/v1/agent-runs/{runId}/workbench/terminal/commands"
canonical_url: https://wiblo.app/docs/developers/api/agent-workbench/start-workbench-command
last_updated: 2026-07-28T17:31:44+02:00
md_url: https://wiblo.app/docs/developers/api/agent-workbench/start-workbench-command.md
---

# Run one terminal command in the worktree

`POST /v1/agent-runs/{runId}/workbench/terminal/commands`

Command-at-a-time execution in the run's sandbox worktree (WIBLO-130) — no PTY. The response is `text/event-stream`; each `data:` line is one `WorkbenchTerminalChunk` (stdout/stderr slices, an optional `truncated` marker at the 50KB stream cap, then a final `exit` frame). Output is EPHEMERAL: it never enters `agent_events`. Per-user rate-limited at 30/60s.

## Path parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `runId` | `string` | Yes |  |

## Request body

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `command` | `string` | Yes |  |
| `cwd` | `string` | No |  |

## Request

**curl**

```bash
curl https://api.wiblo.app/v1/agent-runs/{runId}/workbench/terminal/commands \
  -X POST \
  -H "Authorization: Bearer $WIBLO_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "command": "..."
}'
```

**TypeScript**

```ts
import { createSdk, startWorkbenchCommand } from "@workspace/sdk"

const sdk = createSdk({ baseUrl: "https://api.wiblo.app" })

const { data, error } = await startWorkbenchCommand({
  client: sdk,
  path: { runId: "..." },
  body: {
    "command": "..."
  },
})
```

## Responses

**`200`** — A command output stream. The body is `text/event-stream`; each `data:` line is one `WorkbenchTerminalChunk` JSON object.

**`400`** — Body failed Zod validation (`VALIDATION_FAILED`) or the `cwd` escaped the worktree (`INVALID_FILE_PATH`). Returns `ApiErrorEnvelope`.

**`401`** — No valid session cookie or `wbl_*` bearer was present. Returns `ApiErrorEnvelope`.

**`404`** — No run visible to the caller with this id (`AGENT_RUN_NOT_FOUND`). Returns `ApiErrorEnvelope`.

**`409`** — No live sandbox session holds the worktree (`AGENT_SANDBOX_UNAVAILABLE`). Returns `ApiErrorEnvelope`.

**`422`** — Path param failed UUID validation (`INVALID_PARAMS`). Returns `ApiErrorEnvelope`.

**`429`** — Rate limit exceeded. The body's `error.code` is `RATE_LIMITED` and `error.details.retry_after` is the same number of seconds as the `Retry-After` header. Returns `ApiErrorEnvelope`.
