> ## 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.

# Rotating secrets

> Store a new value for a secret and have running sandboxes pick it up on their next request.

Update a secret with `Secret.update`. Each successful update stores a new immutable version and makes it current. Version numbers increase and are never reused within the same secret, but failed updates can leave gaps.

<CodeGroup>
  ```js JavaScript & TypeScript theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
  import { Secret } from 'e2b'

  const secret = await Secret.update('stripe_api_key', 'sk_live_new...')
  console.log(secret.version) // 2
  ```

  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
  from e2b import Secret

  secret = Secret.update("stripe_api_key", "sk_live_new...")
  print(secret.version)  # 2
  ```
</CodeGroup>

After the update succeeds, matching HTTPS requests whose secrets lookup starts afterward use the new current value. A request that already resolved the old value can still use it. You don't need to restart the sandbox or update its network rules, and a paused sandbox uses the current value after it resumes.

References always resolve the current version. The public API and SDKs do not support version pinning, reading older values, or rolling back to a previous version. To restore an earlier credential, supply that value again with `Secret.update`.
