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

# Create a secret

> Store a credential with E2B and reference it by a name you choose.

Create a secret with `Secret.create`. The name is yours to choose; the value is stored encrypted and the response carries metadata only.

```js JavaScript & TypeScript theme={"theme":"css-variables"}
import { Secret } from 'e2b'

const secret = await Secret.create('stripe_api_key', 'sk_live_...', {
  metadata: { environment: 'production' },
})

console.log(secret.secretId) // sec_...
console.log(secret.version) // 1
```

```python Python theme={"theme":"css-variables"}
from e2b import Secret

secret = Secret.create(
    "stripe_api_key",
    "sk_live_...",
    metadata={"environment": "production"},
)

print(secret.secret_id)  # sec_...
print(secret.version)  # 1
```

## Secret names

When creating a secret, its name must contain 1–128 ASCII letters, digits, underscores (`_`), or hyphens (`-`), with no whitespace. The API lowercases the name before storing it, so `My-Key` and `my-key` identify the same secret. Names may not start with the reserved `sec_` prefix, in any capitalization. Invalid names, including names with surrounding whitespace, receive a `400` API error that doesn't echo the name back. Creating a name that already exists in the project returns `409`. Use `Secret.update` to rotate its value.

Each secret also receives a stable `sec_...` identifier. Every method that takes a single secret (`Secret.getInfo`, `Secret.exists`, `Secret.update`, and `Secret.destroy`) accepts either the identifier or the name.
