---
title: "Exec Command"
method: POST
path: "/v1/sandboxes/{sandbox_id}/exec"
tags: ["Sandboxes"]
---

# Exec Command

`POST /v1/sandboxes/{sandbox_id}/exec`

Run a command in the sandbox. Streams NDJSON lines (application/x-ndjson): {"stdout": ...}/{"stderr": ...} chunks followed by exactly one terminal {"returncode": N} or {"error": msg} line.

## Path parameters

- `sandbox_id` string, required

## Headers

- `xi-api-key` string, nullable
- `x-api-key` string, nullable

## Request body

- SandboxExecIn
  - `command` string[], required
  - `timeout_seconds` integer — Seconds to allow the command to run before it's killed. 0 uses the server default (60s). Capped at 1800s (30 minutes).

## Response `200`

Successful Response

- unknown

## Other responses

- `400` — Bad Request
- `401` — Unauthorized
- `404` — Not Found
- `409` — Conflict
- `422` — Validation Error

---

[API](https://skmtc.net/deepinfra/apis/deepinfra-api.md) · [All operations](https://skmtc.net/deepinfra/apis/deepinfra-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/deepinfra/deepinfra-api/revisions/09b3e4a5d218/schema)
