# Run a command

Launch stage: GA

`POST /api/1.2/commands/execute`

Runs a cluster command in the given execution context, using the provided language.

 If successful, it returns an ID for tracking the status of the command's execution. This method
 returns as soon as the command is accepted, so poll __commandStatus__ with the returned ID to wait for
 the command to finish and to read its results.

API scopes: command-execution

## Request body

- `clusterId` (string, optional)
  ID of the cluster that hosts the execution context.
- `contextId` (string, optional)
  ID of the execution context to run the command in, as returned by __Create__.
- `language` (string, optional)
  Language the command is written in.
  Possible values:
  - `python`
  - `scala`
  - `sql`
  - `r`
- `command` (string, optional)
  Code to run, written in the specified language.

## Returns

- `id` (string, optional)
  ID of the new execution context when returned by __Create__, or of the submitted command when
   returned by __execute__. Pass it to the other methods of this API as `contextId` or `commandId`.

## Request

```json
{
  "clusterId": "0123-456789-abcdefg1",
  "contextId": "3f2a9c1e8b7d4a6f9e0c1b2d3a4f5e6d",
  "language": "python",
  "command": "print('Hello, World!')"
}
```

## Response

```json
{
  "id": "5c8e1d2f3a4b8c9d8e0f1a2b3c4d5e6f"
}
```

