---
title: "Run shell command"
method: POST
path: "/api/shell"
tags: ["shell"]
---

# Run shell command

`POST /api/shell`

## Request

- Base URL: `https://opencode.ai` (the document declares no server; this is the origin it was published from)
- URL: `https://opencode.ai/api/shell`
- Auth: none required

Spawn one non-interactive shell command for a location. Combined stdout/stderr is captured to a file pageable via output.

## Query parameters

- `location` object, nullable
  - `directory` string, nullable

## Request body

- object
  - `command` string, required
  - `cwd` string
  - `timeout` integer
  - `metadata` object

## Response `200`

Success

- object
  - `location` LocationPublicRef, required
    - `directory` string, required
  - `data` ShellInfo, required
    - `id` string, required
    - `status` 'running' | 'exited' | 'timeout' | 'killed', required
    - `command` string, required
    - `cwd` string, required
    - `shell` string, required
    - `file` string, required
    - `pid` integer
    - `exit` number
    - `signal` string
    - `metadata` object, required
    - `time` object, required
      - `started` number, required: Start time in milliseconds since the Unix epoch
      - `completed` number

## Other responses

- `400`: InvalidRequestError
- `401`: UnauthorizedError
- `404`: LocationNotFoundError

---

[API](https://skmtc.dev/kaaass/apis/opencode.md) - [All operations](https://skmtc.dev/kaaass/apis/opencode/llms.txt) - [OpenAPI document](https://skmtc.dev/kaaass/apis/opencode/revisions/4e083d954707?raw)
