---
title: "Exec command"
method: POST
path: "/boxes/{boxId}/commands"
tags: ["Command"]
---

# Exec command

`POST /boxes/{boxId}/commands`

Execute a command on a running box. This endpoint allows you to send commands to the box and receive the output

## Path parameters

- `boxId` string, required

## Request body

- Command — Command execution request parameters
  - `command` string, required — The command to run
  - `envs` object — The environment variables to run the command
  - `workingDir` string — The working directory of the command. It not provided, the command will be run in the `box.config.workingDir` directory.
  - `timeout` string — The timeout of the command. If the command times out, the exit code will be 124. For example: 'timeout 5s sleep 10s' will result in exit code 124. Supported time units: ms (milliseconds), s (seconds), m (minutes), h (hours) Example formats: "500ms", "30s", "5m", "1h" Default: 30s

## Response `200`

- CommandResult — Result of command execution
  - `exitCode` number, required — The exit code of the command
  - `stdout` string, required — The standard output of the command
  - `stderr` string, required — The standard error output of the command

---

[API](https://skmtc.dev/babelcloud/apis/gbox-open-api.md) · [All operations](https://skmtc.dev/babelcloud/apis/gbox-open-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/babelcloud/gbox-open-api/revisions/d655577fa915/schema)
