---
title: "Run one non-interactive sandboxed command (e.g. wp, composer, php, artisan) inside a site"
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.hostedez.com/llms.txt
> Use this file to discover all available pages before exploring further.

Path: Hosted EZ REST API

`POST /v1/sites/{siteId}/terminal/exec`

## Authentication

- `sessionCookie`, apiKey, in cookie

## Path parameters

- `execSiteTerminalCommand.path.siteId` (string, required) — Site slug (sit_...) or UUID.

## Header parameters

- `execSiteTerminalCommand.header.Idempotency-Key` (string, optional) — Optional idempotency key (1 to 255 printable ASCII characters) scoped to caller and route.
  - minLength 1; maxLength 255

## Request body

_Required._

- `execSiteTerminalCommand.command` (string, required)
  - minLength 1; maxLength 2048
- `execSiteTerminalCommand.cwd` (string, optional)
  - maxLength 512; default `"public_html"`
- `execSiteTerminalCommand.timeoutSeconds` (integer, optional)
  - min 5; max 300; default `60`

## Example request

```json
{
  "command": "string",
  "cwd": "public_html",
  "timeoutSeconds": 60
}
```

## Code samples

### cURL

```curl
curl --request POST \
  --url https://api.hostedez.com/v1/sites/string/terminal/exec \
  --header 'Content-Type: application/json' \
  --header '__Secure-better-auth.session_token: <value>' \
  --data '
{
  "command": "string",
  "cwd": "public_html",
  "timeoutSeconds": 60
}
'
```

### TypeScript

```typescript
const url = 'https://api.hostedez.com/v1/sites/string/terminal/exec';
const options = {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    '__Secure-better-auth.session_token': '<value>'
  },
  body: JSON.stringify({command: 'string', cwd: 'public_html', timeoutSeconds: 60})
};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://api.hostedez.com/v1/sites/string/terminal/exec"

payload = {
    "command": "string",
    "cwd": "public_html",
    "timeoutSeconds": 60
}
headers = {
    "Content-Type": "application/json",
    "__Secure-better-auth.session_token": "<value>"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
```

## Responses

### 200

Command execution result and bounded output

#### Example

```json
{
  "run": {
    "command": "string",
    "createdAt": "2019-08-24T14:15:22Z",
    "cwd": "string",
    "durationMs": 0,
    "exitCode": 0,
    "finishedAt": "2019-08-24T14:15:22Z",
    "id": "string",
    "output": "string",
    "outputTruncated": true,
    "siteId": "string",
    "source": "mcp",
    "startedAt": "2019-08-24T14:15:22Z",
    "status": "running"
  }
}
```

- `execSiteTerminalCommand.response.200.run` (object, required)
  - `execSiteTerminalCommand.response.200.run.command` (string, required)
  - `execSiteTerminalCommand.response.200.run.createdAt` (string, required)
    - format `date-time`
  - `execSiteTerminalCommand.response.200.run.cwd` (string, required)
  - `execSiteTerminalCommand.response.200.run.durationMs` (integer | null, required)
    - min 0
  - `execSiteTerminalCommand.response.200.run.exitCode` (integer | null, required)
  - `execSiteTerminalCommand.response.200.run.finishedAt` (string | null, required)
    - format `date-time`
  - `execSiteTerminalCommand.response.200.run.id` (string, required) — Terminal run ID (trm_...).
  - `execSiteTerminalCommand.response.200.run.output` (string | null, required)
  - `execSiteTerminalCommand.response.200.run.outputTruncated` (boolean, required)
  - `execSiteTerminalCommand.response.200.run.siteId` (string, required)
  - `execSiteTerminalCommand.response.200.run.source` (string, required)
    - one of `"mcp"`, `"api"`
  - `execSiteTerminalCommand.response.200.run.startedAt` (string, required)
    - format `date-time`
  - `execSiteTerminalCommand.response.200.run.status` (string, required)
    - one of `"running"`, `"succeeded"`, `"failed"`, `"timed_out"`, `"cancelled"`

### 400

Invalid command, cwd, or timeoutSeconds

#### Example

```json
{
  "error": {
    "code": "string",
    "issues": [
      {
        "message": "string",
        "path": "string"
      }
    ],
    "message": "string"
  }
}
```

- `execSiteTerminalCommand.response.400.error` (object, required)
  - `execSiteTerminalCommand.response.400.error.code` (string, required)
  - `execSiteTerminalCommand.response.400.error.message` (string, required)
  - `execSiteTerminalCommand.response.400.error.issues` (array<object>, optional)
    - `execSiteTerminalCommand.response.400.error.issues.message` (string, required)
    - `execSiteTerminalCommand.response.400.error.issues.path` (string, required)

### 401

Unauthenticated

#### Example

```json
{
  "error": {
    "code": "string",
    "issues": [
      {
        "message": "string",
        "path": "string"
      }
    ],
    "message": "string"
  }
}
```

- `execSiteTerminalCommand.response.401.error` (object, required)
  - `execSiteTerminalCommand.response.401.error.code` (string, required)
  - `execSiteTerminalCommand.response.401.error.message` (string, required)
  - `execSiteTerminalCommand.response.401.error.issues` (array<object>, optional)
    - `execSiteTerminalCommand.response.401.error.issues.message` (string, required)
    - `execSiteTerminalCommand.response.401.error.issues.path` (string, required)

### 403

Invalid Origin, site suspended, or active paid plan required

#### Example

```json
{
  "error": {
    "code": "string",
    "issues": [
      {
        "message": "string",
        "path": "string"
      }
    ],
    "message": "string"
  }
}
```

- `execSiteTerminalCommand.response.403.error` (object, required)
  - `execSiteTerminalCommand.response.403.error.code` (string, required)
  - `execSiteTerminalCommand.response.403.error.message` (string, required)
  - `execSiteTerminalCommand.response.403.error.issues` (array<object>, optional)
    - `execSiteTerminalCommand.response.403.error.issues.message` (string, required)
    - `execSiteTerminalCommand.response.403.error.issues.path` (string, required)

### 404

Site not found

#### Example

```json
{
  "error": {
    "code": "string",
    "issues": [
      {
        "message": "string",
        "path": "string"
      }
    ],
    "message": "string"
  }
}
```

- `execSiteTerminalCommand.response.404.error` (object, required)
  - `execSiteTerminalCommand.response.404.error.code` (string, required)
  - `execSiteTerminalCommand.response.404.error.message` (string, required)
  - `execSiteTerminalCommand.response.404.error.issues` (array<object>, optional)
    - `execSiteTerminalCommand.response.404.error.issues.message` (string, required)
    - `execSiteTerminalCommand.response.404.error.issues.path` (string, required)

### 409

Site not ready or idempotency conflict

#### Example

```json
{
  "error": {
    "code": "string",
    "issues": [
      {
        "message": "string",
        "path": "string"
      }
    ],
    "message": "string"
  }
}
```

- `execSiteTerminalCommand.response.409.error` (object, required)
  - `execSiteTerminalCommand.response.409.error.code` (string, required)
  - `execSiteTerminalCommand.response.409.error.message` (string, required)
  - `execSiteTerminalCommand.response.409.error.issues` (array<object>, optional)
    - `execSiteTerminalCommand.response.409.error.issues.message` (string, required)
    - `execSiteTerminalCommand.response.409.error.issues.path` (string, required)

### 429

Concurrent command already running or rate limit exceeded

#### Example

```json
{
  "error": {
    "code": "string",
    "issues": [
      {
        "message": "string",
        "path": "string"
      }
    ],
    "message": "string"
  }
}
```

- `execSiteTerminalCommand.response.429.error` (object, required)
  - `execSiteTerminalCommand.response.429.error.code` (string, required)
  - `execSiteTerminalCommand.response.429.error.message` (string, required)
  - `execSiteTerminalCommand.response.429.error.issues` (array<object>, optional)
    - `execSiteTerminalCommand.response.429.error.issues.message` (string, required)
    - `execSiteTerminalCommand.response.429.error.issues.path` (string, required)

### 503

Hosting node offline

#### Example

```json
{
  "error": {
    "code": "string",
    "issues": [
      {
        "message": "string",
        "path": "string"
      }
    ],
    "message": "string"
  }
}
```

- `execSiteTerminalCommand.response.503.error` (object, required)
  - `execSiteTerminalCommand.response.503.error.code` (string, required)
  - `execSiteTerminalCommand.response.503.error.message` (string, required)
  - `execSiteTerminalCommand.response.503.error.issues` (array<object>, optional)
    - `execSiteTerminalCommand.response.503.error.issues.message` (string, required)
    - `execSiteTerminalCommand.response.503.error.issues.path` (string, required)


Source: https://docs.hostedez.com/api/execSiteTerminalCommand/index.md
