---
# @generated by sylphx-gen 0.1.0 from contracts@e145cc7cf1bc9605f2b27439e5e17ed76a1a2fd7e7021906a013f7565e4a0cd5. Do not edit.
title: "Exec a lease"
description: "`sandboxes.leases.exec` (POST /v1/{name}:exec): Runs one command in the lease to completion and returns its output, capped at 1 MiB per stream."
type: reference
product: sandboxes
summary: "Runs one command in the lease to completion and returns its output, capped at 1 MiB per stream."
updated: 2026-09-28
nav: false
---

Runs one command in the lease to completion and returns its output, capped at 1 MiB per stream. Long-running or interactive processes use the guest protocol at `status.endpoints.guest_uri`.

- **Path** `POST https://api.sylphx.com/v1/orgs/acme/projects/shop/envs/production/leases/lease:exec`
- **Scope** `sandboxes:exec`
- **Effect** `write` — a successful call changes state.
- **Collection** [leases](/docs/api/leases)

## Request

| Field | Type | What it is |
| --- | --- | --- |
| `name` | `string` | The name of the lease. Required. |
| `command` | `string[]` | The program and its arguments. Use `["bash", "-lc", "…"]` for a shell. Required. |
| `working_directory` | `string` | The working directory; default the user's home. |
| `env` | `map<string, string>` | Extra environment variables. |
| `stdin` | `bytes` | Bytes written to standard input. |
| `timeout` | `duration` | Kill the process after this long; default 60 seconds, at most 10 minutes. |
| `user` | `string` | The guest user; default `user`. `root` is allowed: the whole machine belongs to the lessee. |

## Response

| Field | Type | What it is |
| --- | --- | --- |
| `exit_code` | `int32` | The exit code; -1 when killed. |
| `stdout` | `bytes` | Standard output. |
| `stderr` | `bytes` | Standard error. |
| `truncated` | `bool` | Whether either stream exceeded the cap. |
| `timed_out` | `bool` | Whether the process was killed at `timeout`. |

## Errors

- [`UNAUTHENTICATED`](/docs/api/errors/UNAUTHENTICATED) — No valid key or token was presented.
- [`PERMISSION_DENIED`](/docs/api/errors/PERMISSION_DENIED) — The key lacks the method's permission.
- [`RESOURCE_NOT_FOUND`](/docs/api/errors/RESOURCE_NOT_FOUND) — The named Resource does not exist or is not visible.
- [`INVALID_STATE`](/docs/api/errors/INVALID_STATE) — The Resource is in a state that forbids the call.
- [`STALE_GENERATION`](/docs/api/errors/STALE_GENERATION) — The call named a lease generation or control epoch that is no longer current.
- [`IDEMPOTENCY_KEY_REUSED`](/docs/api/errors/IDEMPOTENCY_KEY_REUSED) — An Idempotency-Key was reused with another body.
- [`IDEMPOTENCY_IN_PROGRESS`](/docs/api/errors/IDEMPOTENCY_IN_PROGRESS) — The first call with this Idempotency-Key is still running.

Every error arrives in the body [Errors](/docs/platform/errors) describes.

## Examples

**cURL**

```curl
curl -X POST "https://api.sylphx.com/v1/orgs/acme/projects/shop/envs/production/leases/lease:exec" \
  -H "Authorization: Bearer $SYLPHX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"command":["…"]}'
```

**TypeScript**

```ts
const response = await sylphx.sandboxes.leases.exec({ command: ['…'], name: 'orgs/acme/projects/shop/envs/production/leases/lease' })
```

**Rust**

```rust
let mut req = sylphx::sandboxes::ExecLeaseRequest::default();
req.command = vec!["…".to_string()];
req.name = "orgs/acme/projects/shop/envs/production/leases/lease".to_string();
let response = sx.sandboxes().leases().exec(req).await?;
```

**CLI**

```bash
sylphx sandboxes leases exec orgs/acme/projects/shop/envs/production/leases/lease
```

**MCP**

```json
{ "method_id": "sandboxes.leases.exec", "args": {"command":["…"],"name":"orgs/acme/projects/shop/envs/production/leases/lease"} }
```
