---
# @generated by sylphx-gen 0.1.0 from contracts@e145cc7cf1bc9605f2b27439e5e17ed76a1a2fd7e7021906a013f7565e4a0cd5. Do not edit.
title: "Mint token on a lease"
description: "`sandboxes.leases.mint_token` (POST /v1/{name}:mintToken): Mints a lease token for the data plane, bound to the current generation."
type: reference
product: sandboxes
summary: "Mints a lease token for the data plane, bound to the current generation."
updated: 2026-09-28
nav: false
---

Mints a lease token for the data plane, bound to the current generation. Hand it to a process that must not hold the Access key.

- **Path** `POST https://api.sylphx.com/v1/orgs/acme/projects/shop/envs/production/leases/lease:mintToken`
- **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. |
| `scopes` | `TokenScope[]` | What the token admits. Required. One of `guest`, `ports`, `cdp`, `computer`. |
| `ttl` | `duration` | At most 1 hour and never past the lease's `expire_time`. |

## Response

| Field | Type | What it is |
| --- | --- | --- |
| `token` | `string` | The lease token; sent as a bearer token to the data plane. Never returned again. |
| `generation` | `int64` | The lease generation the token is bound to. |
| `expire_time` | `timestamp` | When the token stops verifying. |

## 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.
- [`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:mintToken" \
  -H "Authorization: Bearer $SYLPHX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"scopes":["guest"]}'
```

**TypeScript**

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

**Rust**

```rust
let mut req = sylphx::sandboxes::MintLeaseTokenRequest::default();
req.name = "orgs/acme/projects/shop/envs/production/leases/lease".to_string();
req.scopes = vec![sylphx::sandboxes::TokenScope::Guest];
let response = sx.sandboxes().leases().mint_token(req).await?;
```

**CLI**

```bash
sylphx sandboxes leases mint-token orgs/acme/projects/shop/envs/production/leases/lease
```

**MCP**

```json
{ "method_id": "sandboxes.leases.mint_token", "args": {"name":"orgs/acme/projects/shop/envs/production/leases/lease","scopes":["guest"]} }
```
