Skip to content

SecretsManager

Secrets Manager for managing edge function and job secrets

Provides both name-based (recommended) and UUID-based operations. Name-based operations are more convenient for most use cases.

const client = createClient({ url: 'http://localhost:8080' })
await client.auth.login({ email: 'user@example.com', password: 'password' })
// Create a global secret
const secret = await client.secrets.create({
name: 'STRIPE_KEY',
value: 'sk_live_xxx',
description: 'Stripe production API key'
})
// Create a namespace-scoped secret
await client.secrets.create({
name: 'DATABASE_URL',
value: 'postgres://...',
scope: 'namespace',
namespace: 'production'
})
// Get secret by name
const secret = await client.secrets.get('STRIPE_KEY')
// Get namespace-scoped secret
const secret = await client.secrets.get('DATABASE_URL', { namespace: 'production' })
// Update secret
await client.secrets.update('STRIPE_KEY', { value: 'sk_live_new_key' })
// List all secrets
const secrets = await client.secrets.list()
// Get version history
const versions = await client.secrets.getVersions('STRIPE_KEY')
// Rollback to previous version
await client.secrets.rollback('STRIPE_KEY', 1)
// Delete secret
await client.secrets.delete('STRIPE_KEY')

new SecretsManager(fetch): SecretsManager

Parameter Type
fetch FluxbaseFetch

SecretsManager

create(request): Promise<Secret>

Create a new secret

Creates a new secret with the specified name, value, and scope. The value is encrypted at rest and never returned by the API.

Parameter Type Description
request CreateSecretRequest Secret creation request

Promise<Secret>

Promise resolving to the created secret (metadata only)

// Create a global secret
const secret = await client.secrets.create({
name: 'SENDGRID_API_KEY',
value: 'SG.xxx',
description: 'SendGrid API key for transactional emails'
})
// Create a namespace-scoped secret
const secret = await client.secrets.create({
name: 'DATABASE_URL',
value: 'postgres://user:pass@host:5432/db',
scope: 'namespace',
namespace: 'production',
description: 'Production database URL'
})
// Create a secret with expiration
const secret = await client.secrets.create({
name: 'TEMP_TOKEN',
value: 'xyz123',
expires_at: '2025-12-31T23:59:59Z'
})

delete(name, options?): Promise<void>

Delete a secret by name

Permanently deletes the secret and all its versions.

Parameter Type Description
name string Secret name
options? SecretByNameOptions Optional namespace for namespace-scoped secrets

Promise<void>

Promise resolving when deletion is complete

// Delete a global secret
await client.secrets.delete('OLD_API_KEY')
// Delete a namespace-scoped secret
await client.secrets.delete('DATABASE_URL', { namespace: 'staging' })

deleteById(id): Promise<void>

Delete a secret by ID

Parameter Type Description
id string Secret UUID

Promise<void>

Promise resolving when deletion is complete

await client.secrets.deleteById('550e8400-e29b-41d4-a716-446655440000')

get(name, options?): Promise<Secret>

Get a secret by name (metadata only, never includes value)

Parameter Type Description
name string Secret name
options? SecretByNameOptions Optional namespace for namespace-scoped secrets

Promise<Secret>

Promise resolving to the secret

// Get a global secret
const secret = await client.secrets.get('API_KEY')
// Get a namespace-scoped secret
const secret = await client.secrets.get('DATABASE_URL', { namespace: 'production' })

getById(id): Promise<Secret>

Get a secret by ID (metadata only)

Parameter Type Description
id string Secret UUID

Promise<Secret>

Promise resolving to the secret

const secret = await client.secrets.getById('550e8400-e29b-41d4-a716-446655440000')

getVersions(name, options?): Promise<SecretVersion[]>

Get version history for a secret by name

Returns all historical versions of the secret (values are never included).

Parameter Type Description
name string Secret name
options? SecretByNameOptions Optional namespace for namespace-scoped secrets

Promise<SecretVersion[]>

Promise resolving to array of secret versions

const versions = await client.secrets.getVersions('API_KEY')
versions.forEach(v => {
console.log(`Version ${v.version} created at ${v.created_at}`)
})

getVersionsById(id): Promise<SecretVersion[]>

Get version history for a secret by ID

Parameter Type Description
id string Secret UUID

Promise<SecretVersion[]>

Promise resolving to array of secret versions

const versions = await client.secrets.getVersionsById('550e8400-e29b-41d4-a716-446655440000')

list(options?): Promise<SecretSummary[]>

List all secrets (metadata only, never includes values)

Parameter Type Description
options? ListSecretsOptions Filter options for scope and namespace

Promise<SecretSummary[]>

Promise resolving to array of secret summaries

// List all secrets
const secrets = await client.secrets.list()
// List only global secrets
const secrets = await client.secrets.list({ scope: 'global' })
// List secrets for a specific namespace
const secrets = await client.secrets.list({ namespace: 'production' })
secrets.forEach(s => {
console.log(`${s.name}: version ${s.version}, expired: ${s.is_expired}`)
})

rollback(name, version, options?): Promise<Secret>

Rollback a secret to a previous version by name

Restores the secret to a previous version’s value. This creates a new version with the old value.

Parameter Type Description
name string Secret name
version number Version number to rollback to
options? SecretByNameOptions Optional namespace for namespace-scoped secrets

Promise<Secret>

Promise resolving to the updated secret

// Rollback to version 2
const secret = await client.secrets.rollback('API_KEY', 2)
console.log(`Secret now at version ${secret.version}`)

rollbackById(id, version): Promise<Secret>

Rollback a secret to a previous version by ID

Parameter Type Description
id string Secret UUID
version number Version number to rollback to

Promise<Secret>

Promise resolving to the updated secret

const secret = await client.secrets.rollbackById('550e8400-e29b-41d4-a716-446655440000', 2)

stats(): Promise<SecretStats>

Get statistics about secrets

Promise<SecretStats>

Promise resolving to secret statistics

const stats = await client.secrets.stats()
console.log(`Total: ${stats.total}, Expiring soon: ${stats.expiring_soon}, Expired: ${stats.expired}`)

update(name, request, options?): Promise<Secret>

Update a secret by name

Updates the secret’s value, description, or expiration. Only provided fields will be updated.

Parameter Type Description
name string Secret name
request UpdateSecretRequest Update request
options? SecretByNameOptions Optional namespace for namespace-scoped secrets

Promise<Secret>

Promise resolving to the updated secret

// Update secret value
const secret = await client.secrets.update('API_KEY', { value: 'new-value' })
// Update description
const secret = await client.secrets.update('API_KEY', { description: 'Updated description' })
// Update namespace-scoped secret
const secret = await client.secrets.update('DATABASE_URL',
{ value: 'postgres://new-host:5432/db' },
{ namespace: 'production' }
)

updateById(id, request): Promise<Secret>

Update a secret by ID

Parameter Type Description
id string Secret UUID
request UpdateSecretRequest Update request

Promise<Secret>

Promise resolving to the updated secret

const secret = await client.secrets.updateById('550e8400-e29b-41d4-a716-446655440000', {
value: 'new-value'
})