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

# Secret

### Secret

Module for managing E2B secrets and workload identity helpers.

Secret values are write-only: they are accepted by Secret.create
and Secret.update but never returned by any read surface.

#### Constructors

```ts theme={"theme":"css-variables"}
new Secret(): Secret
```

###### Returns

`Secret`

#### Methods

### create()

```ts theme={"theme":"css-variables"}
static create(
   name: string, 
   value: string, 
opts?: SecretCreateOpts): Promise<SecretInfo>
```

Create a new secret and its first value.

###### Parameters

| Parameter | Type | Description |
| - | - | - |
| `name` | `string` | name of the secret, unique within the project. |
| `value` | `string` | secret value. Write-only — never returned by the API. |
| `opts?` | `SecretCreateOpts` | connection options. |

###### Returns

`Promise<SecretInfo>`

the secret's ID, name, current version (`1` for a new secret),
metadata, and creation and update times.

### destroy()

```ts theme={"theme":"css-variables"}
static destroy(secret: string, opts?: ConnectionOpts): Promise<boolean>
```

Destroy a secret, making all its versions inaccessible.

###### Parameters

| Parameter | Type | Description |
| - | - | - |
| `secret` | `string` | secret ID or name. |
| `opts?` | `ConnectionOpts` | connection options. |

###### Returns

`Promise<boolean>`

`true` if the secret was destroyed, `false` if it was not found.

### exists()

```ts theme={"theme":"css-variables"}
static exists(secret: string, opts?: ConnectionOpts): Promise<boolean>
```

Check whether a secret exists.

###### Parameters

| Parameter | Type | Description |
| - | - | - |
| `secret` | `string` | secret ID or name. |
| `opts?` | `ConnectionOpts` | connection options. |

###### Returns

`Promise<boolean>`

`true` if the secret exists, `false` otherwise.

### fill()

```ts theme={"theme":"css-variables"}
static fill(secret: string): string
```

Format a placeholder that the runtime resolves to the secret's current
value.

This is a local formatting helper and makes no network call — it does
not check whether the named secret exists. An unknown reference fails
server-side when the placeholder is resolved.

###### Parameters

| Parameter | Type | Description |
| - | - | - |
| `secret` | `string` | secret name. |

###### Returns

`string`

placeholder string resolving to the secret's value.

###### Example

```ts theme={"theme":"css-variables"}
Secret.fill('openai-api-key')
// '${e2b.secrets.openai-api-key}'
```

### getInfo()

```ts theme={"theme":"css-variables"}
static getInfo(secret: string, opts?: ConnectionOpts): Promise<SecretInfo>
```

Get a secret's metadata.

###### Parameters

| Parameter | Type | Description |
| - | - | - |
| `secret` | `string` | secret ID or name. |
| `opts?` | `ConnectionOpts` | connection options. |

###### Returns

`Promise<SecretInfo>`

the secret's ID, name, current version, metadata, and creation
and update times.

### iamToken()

```ts theme={"theme":"css-variables"}
static iamToken(token: SandboxIamToken): SandboxIamToken
```

Define a workload identity token to pass to `iam.tokens` when creating
a sandbox.

###### Parameters

| Parameter | Type | Description |
| - | - | - |
| `token` | `SandboxIamToken` | workload token definition. |

###### Returns

`SandboxIamToken`

a token definition passable to `iam.tokens`.

###### Example

```ts theme={"theme":"css-variables"}
const sandbox = await Sandbox.create({
  iam: {
    tokens: {
      aws: Secret.iamToken({
        audience: 'sts.amazonaws.com',
        tokenType: 'JWT-SVID',
      }),
    },
  },
})
```

### list()

```ts theme={"theme":"css-variables"}
static list(opts?: SecretListOpts): SecretPaginator
```

List the project's secrets.

###### Parameters

| Parameter | Type | Description |
| - | - | - |
| `opts?` | `SecretListOpts` | connection options. |

###### Returns

`SecretPaginator`

paginator over the project's secrets. Drain it page by page:
`while (paginator.hasNext) { const secrets = await paginator.nextItems() }`.

###### Example

```ts theme={"theme":"css-variables"}
const paginator = Secret.list({ limit: 50 })
while (paginator.hasNext) {
  const secrets = await paginator.nextItems()
}
```

### update()

```ts theme={"theme":"css-variables"}
static update(
   secret: string, 
   value: string, 
opts?: SecretUpdateOpts): Promise<SecretInfo>
```

Update a secret's value by storing it as the secret's new version.

###### Parameters

| Parameter | Type | Description |
| - | - | - |
| `secret` | `string` | secret ID or name. |
| `value` | `string` | new secret value. Write-only — never returned by the API. |
| `opts?` | `SecretUpdateOpts` | connection options. |

###### Returns

`Promise<SecretInfo>`

the secret's ID, name, new current version, metadata, and
creation and update times.

***

### SecretPaginator

Paginator for listing secrets.

#### Example

```ts theme={"theme":"css-variables"}
const paginator = Secret.list()
while (paginator.hasNext) {
  const secrets = await paginator.nextItems()
  console.log(secrets)
}
```

#### Constructors

```ts theme={"theme":"css-variables"}
new SecretPaginator(opts?: SecretListOpts): SecretPaginator
```

###### Parameters

| Parameter | Type |
| - | - |
| `opts?` | `SecretListOpts` |

###### Returns

`SecretPaginator`

#### Accessors

### hasNext

###### Get Signature

```ts theme={"theme":"css-variables"}
get hasNext(): boolean
```

Returns true if there are more items to fetch.

###### Returns

`boolean`

### nextToken

###### Get Signature

```ts theme={"theme":"css-variables"}
get nextToken(): undefined | string
```

Returns the next token to use for pagination.

###### Returns

`undefined | string`

#### Methods

### nextItems()

```ts theme={"theme":"css-variables"}
nextItems(opts?: ConnectionOpts): Promise<SecretInfo[]>
```

Get the next page of items.

###### Parameters

| Parameter | Type | Description |
| - | - | - |
| `opts?` | `ConnectionOpts` | per-call connection options. When provided, this call uses these options (e.g. `apiKey`, `domain`, `headers`, `requestTimeoutMs`, `signal`) instead of the ones the paginator was constructed with. Aborting a page via `signal` does not affect subsequent Paginator.nextItems calls — pass a fresh signal each call you want to be cancellable. |

###### Returns

`Promise<SecretInfo[]>`

List of items

###### Throws

Error if there are no more items to fetch. Call this method only if `hasNext` is `true`.

## Interfaces

### SecretCreateOpts

#### Properties

### apiHeaders?

```ts theme={"theme":"css-variables"}
optional apiHeaders: Record<string, string>;
```

Additional headers to send with E2B API requests.

### apiKey?

```ts theme={"theme":"css-variables"}
optional apiKey: string;
```

E2B API key to use for authentication.

###### Default

```ts theme={"theme":"css-variables"}
E2B_API_KEY // environment variable
```

### domain?

```ts theme={"theme":"css-variables"}
optional domain: string;
```

Domain to use for the API.

###### Default

E2B\_DOMAIN // environment variable or `e2b.app`

### ~~headers?~~

```ts theme={"theme":"css-variables"}
optional headers: Record<string, string>;
```

Additional headers to send with the request.

###### Deprecated

Use `apiHeaders` instead.

### httpVersion?

```ts theme={"theme":"css-variables"}
optional httpVersion: HttpVersion;
```

HTTP version for requests to the E2B API and to sandboxes (commands,
filesystem, PTY). `'2'` multiplexes streams over shared connections;
`'1.1'` pins them to HTTP/1.1 with one connection per concurrent
request — for example when an intermediary on the path retires or
mishandles long-lived HTTP/2 connections. Only applies in Node.

###### Default

E2B\_HTTP\_VERSION // environment variable or `'2'`

### logger?

```ts theme={"theme":"css-variables"}
optional logger: Logger;
```

Logger to use for logging messages. It can accept any object that implements `Logger` interface—for example, console.

### metadata?

```ts theme={"theme":"css-variables"}
optional metadata: Record<string, string>;
```

Customer metadata to store with the secret.

### proxy?

```ts theme={"theme":"css-variables"}
optional proxy: string;
```

Proxy URL to use for requests. In case of a sandbox it applies to all
requests made to the returned sandbox.

###### Example

```ts theme={"theme":"css-variables"}
'http://user:pass@127.0.0.1:8080'
```

### requestTimeoutMs?

```ts theme={"theme":"css-variables"}
optional requestTimeoutMs: number;
```

Timeout for requests to the API in **milliseconds**.

###### Default

```ts theme={"theme":"css-variables"}
60_000 // 60 seconds
```

### retries?

```ts theme={"theme":"css-variables"}
optional retries: number;
```

Number of control-plane API retries for responses marked `Should-Retry: true`,
or 429/502/503/504 responses without that header. `Should-Retry: false` is
never retried. Waits for a valid `Retry-After` delta-seconds value, otherwise
exponential backoff with jitter from 100 ms to 10 s. Also retries failures
to establish the connection; network errors after the request is sent are
not retried.
A retry is skipped when its wait would exhaust the request timeout.
Retry waits use a 60-second total limit when request timeouts are disabled.
Set to `0` to disable retries. Defaults to 3 retries.

###### Default

```ts theme={"theme":"css-variables"}
3
```

###### Throws

InvalidArgumentError if the value is negative or not an integer

### signal?

```ts theme={"theme":"css-variables"}
optional signal: AbortSignal;
```

An optional `AbortSignal` that can be used to cancel the in-flight request.
When the signal is aborted, the underlying `fetch` is aborted and the
returned promise rejects with an `AbortError`.

### ~~validateApiKey?~~

```ts theme={"theme":"css-variables"}
optional validateApiKey: boolean;
```

Whether to validate the format of the E2B API key on the client side.

###### Deprecated

The API key format is no longer validated on the client side;
this option has no effect.

***

### SecretInfo

Metadata of a secret. Secret values are write-only and never returned.

#### Properties

### createdAt

```ts theme={"theme":"css-variables"}
createdAt: Date;
```

Time when the secret was created.

### metadata

```ts theme={"theme":"css-variables"}
metadata: Record<string, string>;
```

Customer metadata of the secret.

### name

```ts theme={"theme":"css-variables"}
name: string;
```

Secret name, unique within the project.

### secretId

```ts theme={"theme":"css-variables"}
secretId: string;
```

Secret ID.

### updatedAt

```ts theme={"theme":"css-variables"}
updatedAt: Date;
```

Time when the secret was last updated.

### version

```ts theme={"theme":"css-variables"}
version: number;
```

Version served to readers that do not name one.

***

### SecretListOpts

#### Properties

### apiHeaders?

```ts theme={"theme":"css-variables"}
optional apiHeaders: Record<string, string>;
```

Additional headers to send with E2B API requests.

### apiKey?

```ts theme={"theme":"css-variables"}
optional apiKey: string;
```

E2B API key to use for authentication.

###### Default

```ts theme={"theme":"css-variables"}
E2B_API_KEY // environment variable
```

### domain?

```ts theme={"theme":"css-variables"}
optional domain: string;
```

Domain to use for the API.

###### Default

E2B\_DOMAIN // environment variable or `e2b.app`

### ~~headers?~~

```ts theme={"theme":"css-variables"}
optional headers: Record<string, string>;
```

Additional headers to send with the request.

###### Deprecated

Use `apiHeaders` instead.

### httpVersion?

```ts theme={"theme":"css-variables"}
optional httpVersion: HttpVersion;
```

HTTP version for requests to the E2B API and to sandboxes (commands,
filesystem, PTY). `'2'` multiplexes streams over shared connections;
`'1.1'` pins them to HTTP/1.1 with one connection per concurrent
request — for example when an intermediary on the path retires or
mishandles long-lived HTTP/2 connections. Only applies in Node.

###### Default

E2B\_HTTP\_VERSION // environment variable or `'2'`

### limit?

```ts theme={"theme":"css-variables"}
optional limit: number;
```

Number of secrets to return per page.

###### Default

```ts theme={"theme":"css-variables"}
100
```

### logger?

```ts theme={"theme":"css-variables"}
optional logger: Logger;
```

Logger to use for logging messages. It can accept any object that implements `Logger` interface—for example, console.

### nextToken?

```ts theme={"theme":"css-variables"}
optional nextToken: string;
```

Token to the next page.

### proxy?

```ts theme={"theme":"css-variables"}
optional proxy: string;
```

Proxy URL to use for requests. In case of a sandbox it applies to all
requests made to the returned sandbox.

###### Example

```ts theme={"theme":"css-variables"}
'http://user:pass@127.0.0.1:8080'
```

### requestTimeoutMs?

```ts theme={"theme":"css-variables"}
optional requestTimeoutMs: number;
```

Timeout for requests to the API in **milliseconds**.

###### Default

```ts theme={"theme":"css-variables"}
60_000 // 60 seconds
```

### retries?

```ts theme={"theme":"css-variables"}
optional retries: number;
```

Number of control-plane API retries for responses marked `Should-Retry: true`,
or 429/502/503/504 responses without that header. `Should-Retry: false` is
never retried. Waits for a valid `Retry-After` delta-seconds value, otherwise
exponential backoff with jitter from 100 ms to 10 s. Also retries failures
to establish the connection; network errors after the request is sent are
not retried.
A retry is skipped when its wait would exhaust the request timeout.
Retry waits use a 60-second total limit when request timeouts are disabled.
Set to `0` to disable retries. Defaults to 3 retries.

###### Default

```ts theme={"theme":"css-variables"}
3
```

###### Throws

InvalidArgumentError if the value is negative or not an integer

### ~~validateApiKey?~~

```ts theme={"theme":"css-variables"}
optional validateApiKey: boolean;
```

Whether to validate the format of the E2B API key on the client side.

###### Deprecated

The API key format is no longer validated on the client side;
this option has no effect.

***

### SecretUpdateOpts

#### Properties

### apiHeaders?

```ts theme={"theme":"css-variables"}
optional apiHeaders: Record<string, string>;
```

Additional headers to send with E2B API requests.

### apiKey?

```ts theme={"theme":"css-variables"}
optional apiKey: string;
```

E2B API key to use for authentication.

###### Default

```ts theme={"theme":"css-variables"}
E2B_API_KEY // environment variable
```

### domain?

```ts theme={"theme":"css-variables"}
optional domain: string;
```

Domain to use for the API.

###### Default

E2B\_DOMAIN // environment variable or `e2b.app`

### ~~headers?~~

```ts theme={"theme":"css-variables"}
optional headers: Record<string, string>;
```

Additional headers to send with the request.

###### Deprecated

Use `apiHeaders` instead.

### httpVersion?

```ts theme={"theme":"css-variables"}
optional httpVersion: HttpVersion;
```

HTTP version for requests to the E2B API and to sandboxes (commands,
filesystem, PTY). `'2'` multiplexes streams over shared connections;
`'1.1'` pins them to HTTP/1.1 with one connection per concurrent
request — for example when an intermediary on the path retires or
mishandles long-lived HTTP/2 connections. Only applies in Node.

###### Default

E2B\_HTTP\_VERSION // environment variable or `'2'`

### logger?

```ts theme={"theme":"css-variables"}
optional logger: Logger;
```

Logger to use for logging messages. It can accept any object that implements `Logger` interface—for example, console.

### metadata?

```ts theme={"theme":"css-variables"}
optional metadata: Record<string, string>;
```

Customer metadata to store with the secret. When provided, replaces the
stored metadata.

### proxy?

```ts theme={"theme":"css-variables"}
optional proxy: string;
```

Proxy URL to use for requests. In case of a sandbox it applies to all
requests made to the returned sandbox.

###### Example

```ts theme={"theme":"css-variables"}
'http://user:pass@127.0.0.1:8080'
```

### requestTimeoutMs?

```ts theme={"theme":"css-variables"}
optional requestTimeoutMs: number;
```

Timeout for requests to the API in **milliseconds**.

###### Default

```ts theme={"theme":"css-variables"}
60_000 // 60 seconds
```

### retries?

```ts theme={"theme":"css-variables"}
optional retries: number;
```

Number of control-plane API retries for responses marked `Should-Retry: true`,
or 429/502/503/504 responses without that header. `Should-Retry: false` is
never retried. Waits for a valid `Retry-After` delta-seconds value, otherwise
exponential backoff with jitter from 100 ms to 10 s. Also retries failures
to establish the connection; network errors after the request is sent are
not retried.
A retry is skipped when its wait would exhaust the request timeout.
Retry waits use a 60-second total limit when request timeouts are disabled.
Set to `0` to disable retries. Defaults to 3 retries.

###### Default

```ts theme={"theme":"css-variables"}
3
```

###### Throws

InvalidArgumentError if the value is negative or not an integer

### signal?

```ts theme={"theme":"css-variables"}
optional signal: AbortSignal;
```

An optional `AbortSignal` that can be used to cancel the in-flight request.
When the signal is aborted, the underlying `fetch` is aborted and the
returned promise rejects with an `AbortError`.

### ~~validateApiKey?~~

```ts theme={"theme":"css-variables"}
optional validateApiKey: boolean;
```

Whether to validate the format of the E2B API key on the client side.

###### Deprecated

The API key format is no longer validated on the client side;
this option has no effect.

## Type Aliases

### SecretDestroyOpts

```ts theme={"theme":"css-variables"}
type SecretDestroyOpts = ConnectionOpts;
```

***

### SecretExistsOpts

```ts theme={"theme":"css-variables"}
type SecretExistsOpts = ConnectionOpts;
```

***

### SecretGetInfoOpts

```ts theme={"theme":"css-variables"}
type SecretGetInfoOpts = ConnectionOpts;
```
