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

# List Secrets

`Novita.secret``.list()` returns the metadata of all active Secrets for the current authenticated team. It does not return real values, retired versions, or unfinished pending versions. Use it to discover which Secrets are available before referencing one from a sandbox.

## Prerequisites

```bash CLI icon="terminal" theme={"system"}
export OPENAI_API_KEY="your-openai-api-key"
```

## Example

The example ensures a Secret exists, lists the team's active Secrets with `novita.secret.list()`, launches a sandbox that references one of them, uses the placeholder from inside the sandbox, and kills the sandbox when done.

<CodeGroup>
  ```python Python icon="python" theme={"system"}
  import os
  import uuid

  from novita_sandbox import Novita

  secret_name = f"openai-example-{uuid.uuid4().hex[:12]}"
  openai_api_key = os.environ["OPENAI_API_KEY"]
  novita = Novita()

  # Ensure the Secret exists (created once, reused afterwards).
  novita.secret.create(
      name=secret_name,
      value=openai_api_key,
      hosts=["api.openai.com"],
      description="Sandbox Secrets example",
  )

  # Handle secret: list all active Secrets for the current team (no real values).
  secrets = novita.secret.list()
  for binding in secrets:
      print(binding)

  # Create sandbox: reference the Secret by name.
  sandbox = novita.sandbox.create(
      secret_envs={"OPENAI_API_KEY": secret_name},
  )

  try:
      # Use the secret: the proxy substitutes the real value for the allow-listed host.
      result = sandbox.commands.run(
          'curl -s https://api.openai.com/v1/models '
          '-H "Authorization: Bearer $OPENAI_API_KEY"'
      )
      print(result.stdout)
  finally:
      # Kill sandbox when done.
      sandbox.kill()
  ```

  ```js JavaScript & TypeScript icon="js" theme={"system"}
  import 'dotenv/config'
  import { randomUUID } from 'crypto'
  import { Novita } from 'novita-sandbox'

  const secretName = `openai-example-${randomUUID().slice(0, 12)}`
  const openaiApiKey = process.env.OPENAI_API_KEY
  const novita = new Novita()

  // Ensure the Secret exists (created once, reused afterwards).
  await novita.secret.create({
    name: secretName,
    value: openaiApiKey,
    hosts: ['api.openai.com'],
    description: 'Sandbox Secrets example',
  })

  // Handle secret: list all active Secrets for the current team (no real values).
  const secrets = await novita.secret.list()
  for (const binding of secrets) {
    console.log(binding)
  }

  // Create sandbox: reference the Secret by name.
  const sandbox = await novita.sandbox.create({
    secretEnvs: { OPENAI_API_KEY: secretName },
  })

  try {
    const result = await sandbox.commands.run(
      'curl -s https://api.openai.com/v1/models -H "Authorization: Bearer $OPENAI_API_KEY"'
    )
    console.log(result.stdout)
  } finally {
    await sandbox.kill()
  }
  ```
</CodeGroup>

<Note>
  `novita.secret.list()` takes no business parameters and returns a list of `SecretBinding` metadata. An empty list means the current team has no active Secrets. Real values, retired versions, and pending versions are never returned.
</Note>
