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
Returns
Secret
Methods
create()
Parameters
Returns
Promise<SecretInfo>
the secret’s ID, name, current version (1 for a new secret),
metadata, and creation and update times.
destroy()
Parameters
Returns
Promise<boolean>
true if the secret was destroyed, false if it was not found.
exists()
Parameters
Returns
Promise<boolean>
true if the secret exists, false otherwise.
fill()
Parameters
Returns
string
placeholder string resolving to the secret’s value.
Example
getInfo()
Parameters
Returns
Promise<SecretInfo>
the secret’s ID, name, current version, metadata, and creation
and update times.
iamToken()
iam.tokens when creating
a sandbox.
Parameters
Returns
SandboxIamToken
a token definition passable to iam.tokens.
Example
list()
Parameters
Returns
SecretPaginator
paginator over the project’s secrets. Drain it page by page:
while (paginator.hasNext) { const secrets = await paginator.nextItems() }.
Example
update()
Parameters
Returns
Promise<SecretInfo>
the secret’s ID, name, new current version, metadata, and
creation and update times.
SecretPaginator
Paginator for listing secrets.Example
Constructors
Parameters
Returns
SecretPaginator
Accessors
hasNext
Get Signature
Returns
boolean
nextToken
Get Signature
Returns
undefined | string
Methods
nextItems()
Parameters
Returns
Promise<SecretInfo[]>
List of items
Throws
Error if there are no more items to fetch. Call this method only ifhasNext is true.
Interfaces
SecretCreateOpts
Properties
apiHeaders?
apiKey?
Default
domain?
Default
E2B_DOMAIN // environment variable ore2b.app
headers?
Deprecated
UseapiHeaders instead.
httpVersion?
'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?
Logger interface—for example, console.
metadata?
proxy?
Example
requestTimeoutMs?
Default
retries?
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
signal?
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?
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
metadata
name
secretId
updatedAt
version
SecretListOpts
Properties
apiHeaders?
apiKey?
Default
domain?
Default
E2B_DOMAIN // environment variable ore2b.app
headers?
Deprecated
UseapiHeaders instead.
httpVersion?
'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?
Default
logger?
Logger interface—for example, console.
nextToken?
proxy?
Example
requestTimeoutMs?
Default
retries?
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
validateApiKey?
Deprecated
The API key format is no longer validated on the client side; this option has no effect.SecretUpdateOpts
Properties
apiHeaders?
apiKey?
Default
domain?
Default
E2B_DOMAIN // environment variable ore2b.app
headers?
Deprecated
UseapiHeaders instead.
httpVersion?
'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?
Logger interface—for example, console.
metadata?
proxy?
Example
requestTimeoutMs?
Default
retries?
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
signal?
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.