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

# Environments

> Keep development, staging and production events separate.

## Copy this into your coding agent

Paste into Cursor, Codex, Claude Code, or another coding agent in your project.

```text theme={null}
Configure Bench environments using https://docs.usebench.ai/guides/environments.
Use a server-side BENCH_ENVIRONMENT value for each deployment.
Keep the repository and branch accurate and preserve the existing instrumentation.
Send a synthetic event from my test environment and confirm it appears under that label.
Do not send test traffic through production credentials or expose the Bench key.
```

An environment identifies the deployment that produced an SDK event. Use
`development` while building locally, `staging` for your test deployment and
`production` for live traffic. A repository branch and a deployment environment
are different: the same commit can run in both staging and production.

## Set the environment

```ts theme={null}
const bench = new Bench({
  apiKey: process.env.BENCH_API_KEY!,
  endpoint: process.env.BENCH_API_BASE_URL,
  repository: 'your-team/support-agent',
  branch: process.env.BENCH_BRANCH!,
  systemName: 'Support agent',
  environment: process.env.BENCH_ENVIRONMENT ?? 'development',
  captureContent: false,
})
```

Use a stable name with 1–64 letters, digits, dots, dashes or underscores. Avoid
customer identifiers or secrets in environment names. Custom names appear after
Bench receives an event.

## Find the right events

Choose the environment during **SDK** setup. Once events arrive, use
**Event environment** in a system’s **Production** tab. Bench filters the event list and SDK connection status on the
server before applying the result limit. **All environments** shows the combined
view. Events without a label are **Not specified**; Bench does not assume production.

GitHub discovery, business context and prompt/model Bench history remain scoped to
the repository and system. The event filter does not create separate accounts,
permission boundaries, keys, billing balances or copies of those records.

## Test before sending live traffic

1. Use a development or staging deployment with synthetic inputs.
2. Send a metadata-only SDK event and confirm receipt in the same environment.
3. Run real app tests with test services or fixtures for external actions.
4. Add production instrumentation and verify production receipt separately.

Changing `environment` does not change the services your application calls. A
`staging` label cannot turn a live payment key into a test key.
