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

# Update a Secret

`novita.secret.update()` creates a new immutable version of an existing Secret and makes it active after the value is stored and the policy is persisted. Running executions keep the version and host policy selected at start; newly created, resumed, and cloned executions use the latest active version.

## Example

```python Python icon="python" theme={"system"}
from novita_sandbox import Novita

secret_name = "<your-secret-name>"

novita = Novita()

novita.secret.update(
    name=secret_name,
    value="<your-value>",
    hosts=["api.openai.com"],
    description="Updated Sandbox Secrets example",
)
```

```js JavaScript & TypeScript icon="js" theme={"system"}
import { Novita } from 'novita-sandbox'

const secretName = '<your-secret-name>'

const novita = new Novita()

await novita.secret.update({
  name: secretName,
  value: '<your-value>',
  hosts: ['api.openai.com'],
  description: 'Updated Sandbox Secrets example',
})
```

```bash CLI icon="terminal" theme={"system"}
# Update the value directly
novita secret update <secret_name> --from-value <secret_value>

# Read the value from an environment variable
novita secret update <secret_name> --from-env <env_name>

# Set the value from standard input
novita secret update <secret_name> --from-stdin

# Set the value via a pipe
echo "value" | novita secret update <secret_name> --from-stdin
```

> [!NOTE]
>
> Each update creates a new immutable version, which becomes active only after the value and policy are persisted. Already-running executions continue using the version selected at start; new, resumed, and cloned executions pick up the latest active version.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.