> ## 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":{"light":"github-light","dark":"github-dark-default"}}
new Secret(): Secret
```

###### Returns

`Secret`

#### Methods

### create()

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
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":{"light":"github-light","dark":"github-dark-default"}}
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":{"light":"github-light","dark":"github-dark-default"}}
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":{"light":"github-light","dark":"github-dark-default"}}
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":{"light":"github-light","dark":"github-dark-default"}}
Secret.fill('openai-api-key')
// '${e2b.secrets.openai-api-key}'
```

### getInfo()

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
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":{"light":"github-light","dark":"github-dark-default"}}
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":{"light":"github-light","dark":"github-dark-default"}}
const sandbox = await Sandbox.create({
  iam: {
    tokens: {
      aws: Secret.iamToken({
        audience: 'sts.amazonaws.com',
        tokenType: 'JWT-SVID',
      }),
    },
  },
})
```

### list()

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
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":{"light":"github-light","dark":"github-dark-default"}}
const paginator = Secret.list({ limit: 50 })
while (paginator.hasNext) {
  const secrets = await paginator.nextItems()
}
```

### update()

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
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":{"light":"github-light","dark":"github-dark-default"}}
const paginator = Secret.list()
while (paginator.hasNext) {
  const secrets = await paginator.nextItems()
  console.log(secrets)
}
```

#### Constructors

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
new SecretPaginator(opts?: SecretListOpts): SecretPaginator
```

###### Parameters

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

###### Returns

`SecretPaginator`

#### Accessors

### hasNext

###### Get Signature

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
get hasNext(): boolean
```

Returns true if there are more items to fetch.

###### Returns

`boolean`

### nextToken

###### Get Signature

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
get nextToken(): undefined | string
```

Returns the next token to use for pagination.

###### Returns

`undefined` | `string`

#### Methods

### nextItems()

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
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":{"light":"github-light","dark":"github-dark-default"}}
optional apiHeaders: Record<string, string>;
```

Additional headers to send with E2B API requests.

### apiKey?

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
optional apiKey: string;
```

E2B API key to use for authentication.

###### Default

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
E2B_API_KEY // environment variable
```

### domain?

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
optional domain: string;
```

Domain to use for the API.

###### Default

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

### ~~headers?~~

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
optional headers: Record<string, string>;
```

Additional headers to send with the request.

###### Deprecated

Use `apiHeaders` instead.

### httpVersion?

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
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":{"light":"github-light","dark":"github-dark-default"}}
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":{"light":"github-light","dark":"github-dark-default"}}
optional metadata: Record<string, string>;
```

Customer metadata to store with the secret.

### proxy?

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
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":{"light":"github-light","dark":"github-dark-default"}}
'http://user:pass@127.0.0.1:8080'
```

### requestTimeoutMs?

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
optional requestTimeoutMs: number;
```

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

###### Default

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
60_000 // 60 seconds
```

### retries?

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
optional retries: number;
```

Number of control-plane API retries after a 429, 502 or 503 response or
a failure to establish the connection (refused, DNS, unreachable host).
Any other network error (dropped connection, opaque browser/Workers
`TypeError`) is retried too. A 502 and those network errors are not
retried for operations that create a resource (e.g. sandbox creation) or
append to one (secret update), as the server may already have processed
them.
A 429 is retried only with a valid, non-negative integer delta-seconds
`Retry-After` header (HTTP-date and malformed values are not retried).
502 and 503 honor such a `Retry-After` when present; otherwise they and
connection failures use exponential backoff with jitter starting at
100 ms (capped at 10 s).
Retry waits use a 60-second total limit when request timeouts are disabled.

###### Default

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
3
```

### signal?

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
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":{"light":"github-light","dark":"github-dark-default"}}
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":{"light":"github-light","dark":"github-dark-default"}}
createdAt: Date;
```

Time when the secret was created.

### metadata

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
metadata: Record<string, string>;
```

Customer metadata of the secret.

### name

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
name: string;
```

Secret name, unique within the project.

### secretId

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
secretId: string;
```

Secret ID.

### updatedAt

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
updatedAt: Date;
```

Time when the secret was last updated.

### version

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
version: number;
```

Version served to readers that do not name one.

***

### SecretListOpts

#### Properties

### apiHeaders?

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
optional apiHeaders: Record<string, string>;
```

Additional headers to send with E2B API requests.

### apiKey?

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
optional apiKey: string;
```

E2B API key to use for authentication.

###### Default

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
E2B_API_KEY // environment variable
```

### domain?

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
optional domain: string;
```

Domain to use for the API.

###### Default

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

### ~~headers?~~

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
optional headers: Record<string, string>;
```

Additional headers to send with the request.

###### Deprecated

Use `apiHeaders` instead.

### httpVersion?

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
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":{"light":"github-light","dark":"github-dark-default"}}
optional limit: number;
```

Number of secrets to return per page.

###### Default

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
100
```

### logger?

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
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":{"light":"github-light","dark":"github-dark-default"}}
optional nextToken: string;
```

Token to the next page.

### proxy?

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
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":{"light":"github-light","dark":"github-dark-default"}}
'http://user:pass@127.0.0.1:8080'
```

### requestTimeoutMs?

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
optional requestTimeoutMs: number;
```

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

###### Default

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
60_000 // 60 seconds
```

### retries?

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
optional retries: number;
```

Number of control-plane API retries after a 429, 502 or 503 response or
a failure to establish the connection (refused, DNS, unreachable host).
Any other network error (dropped connection, opaque browser/Workers
`TypeError`) is retried too. A 502 and those network errors are not
retried for operations that create a resource (e.g. sandbox creation) or
append to one (secret update), as the server may already have processed
them.
A 429 is retried only with a valid, non-negative integer delta-seconds
`Retry-After` header (HTTP-date and malformed values are not retried).
502 and 503 honor such a `Retry-After` when present; otherwise they and
connection failures use exponential backoff with jitter starting at
100 ms (capped at 10 s).
Retry waits use a 60-second total limit when request timeouts are disabled.

###### Default

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
3
```

### ~~validateApiKey?~~

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
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":{"light":"github-light","dark":"github-dark-default"}}
optional apiHeaders: Record<string, string>;
```

Additional headers to send with E2B API requests.

### apiKey?

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
optional apiKey: string;
```

E2B API key to use for authentication.

###### Default

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
E2B_API_KEY // environment variable
```

### domain?

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
optional domain: string;
```

Domain to use for the API.

###### Default

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

### ~~headers?~~

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
optional headers: Record<string, string>;
```

Additional headers to send with the request.

###### Deprecated

Use `apiHeaders` instead.

### httpVersion?

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
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":{"light":"github-light","dark":"github-dark-default"}}
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":{"light":"github-light","dark":"github-dark-default"}}
optional metadata: Record<string, string>;
```

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

### proxy?

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
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":{"light":"github-light","dark":"github-dark-default"}}
'http://user:pass@127.0.0.1:8080'
```

### requestTimeoutMs?

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
optional requestTimeoutMs: number;
```

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

###### Default

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
60_000 // 60 seconds
```

### retries?

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
optional retries: number;
```

Number of control-plane API retries after a 429, 502 or 503 response or
a failure to establish the connection (refused, DNS, unreachable host).
Any other network error (dropped connection, opaque browser/Workers
`TypeError`) is retried too. A 502 and those network errors are not
retried for operations that create a resource (e.g. sandbox creation) or
append to one (secret update), as the server may already have processed
them.
A 429 is retried only with a valid, non-negative integer delta-seconds
`Retry-After` header (HTTP-date and malformed values are not retried).
502 and 503 honor such a `Retry-After` when present; otherwise they and
connection failures use exponential backoff with jitter starting at
100 ms (capped at 10 s).
Retry waits use a 60-second total limit when request timeouts are disabled.

###### Default

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
3
```

### signal?

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
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":{"light":"github-light","dark":"github-dark-default"}}
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":{"light":"github-light","dark":"github-dark-default"}}
type SecretDestroyOpts = ConnectionOpts;
```

***

### SecretExistsOpts

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
type SecretExistsOpts = ConnectionOpts;
```

***

### SecretGetInfoOpts

```ts theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
type SecretGetInfoOpts = ConnectionOpts;
```
