# Environments

URL: /code/cli/guides/environments · Id: `page:code/cli/guides/environments`

> Two environments, test and live, keep every trial apart from real Customers and real money.

Every [Startup](/business/nouns/startup) has two environments, `test` and `live`. Both run one definition; each keeps its own records, money and messages, and the key on a call picks between them.

## One definition, two sets of records
A Startup's definition is its [Nouns](/business/nouns/noun), [Verbs](/business/nouns/verb), [Offers](/business/nouns/offer), [Pages](/business/nouns/page) and code. Both environments read it. Every operational record, such as an [Order](/business/nouns/order), a [Customer](/business/nouns/customer) or an [Event](/business/nouns/event), belongs to exactly one environment and never crosses.

The two differ in which build they run. `test` runs the head: the latest merged [Change](/business/nouns/change). `live` runs the [Version](/business/nouns/version) last deployed.

Merge a new Offer, and it is callable in `test` at once, while live Customers still see the deployed build. [Environments](/code/platform/environments) is the capability that keeps the two apart.

## The key picks the environment
An `sk_test_` key reaches `test`, and an `sk_live_` key reaches `live`. The URL is the same for both.

```bash
curl https://api.sb/gradeready.com/offers -H "Authorization: Bearer sk_test_..."
curl https://api.sb/gradeready.com/offers -H "Authorization: Bearer sk_live_..."
```

No parameter moves a keyed call between environments. Code goes from `test` to `live` by changing one variable, `STARTUP_BUILDER_API_KEY`.

A person signed in to the CLI holds a session that reaches both. It starts in `test`, and `--env live` switches one command. [Keys](/code/api/guides/keys) lists every kind of key.

## What test does differently
`test` runs every Verb for real, with three exceptions that keep it safe:

| In `test` | What happens instead |
| --- | --- |
| Payments | Test cards charge, and no money moves |
| Outbound messages | Reach only the Startup's own team, never outside addresses |
| Outside effects | [Domain](/business/nouns/domain) purchases, ad spend and filings are simulated, then recorded as `done` |

Everything else matches `live`: [Permissions](/business/nouns/permission), [Limits](/business/nouns/limit), [Approvals](/business/nouns/approval), delay windows, [Watches](/business/nouns/watch) and Events. A refund over its Limit waits for an Approval in `test` as it would in `live`. A flow that passes in `test` passes in `live`.

Simulated outside effects take magic values that force each outcome, such as a declined card. [Errors and testing](/code/sdk/guides/errors-and-testing) lists them.

## Built in test, by an agent
`gradeready.com` is an [Agent as a Service](/products/templates/agent-as-a-service) that gives students line-by-line feedback on essays. An [Agent](/business/nouns/agent) built it from one sentence, entirely in `test`, before any person looked at it.

In `test` an agent needs nobody's permission. It defines the Offer, publishes the [Site](/business/nouns/site), places Orders as test Customers and handles them end to end. Every step is recorded, so the build is reviewable later.

Money is where a person enters. A sponsor [claims](/business/nouns/startup/claim) the Startup with one link: they verify who they are, connect a payment account and sign. The claim names the owner of record, and from then on the Startup may move real money.

## Going live
`live` serves nothing until the first Version is deployed. Until then, any call with an `sk_live_` key returns [`not-live`](/code/api/errors/not-live), status `503`.

To go live, [deploy](/business/nouns/version/deploy) a Version. Each later deploy moves `live` to a new build, and the previous Version stays one revert away.

Records never move between environments. The test Customers and Orders stay in `test`, and `live` starts empty. [Experiments](/business/nouns/experiment) run only in `live`, where real Customers decide them.

## Next
- [Authentication](/code/api/guides/authentication): creating `sk_test_` and `sk_live_` keys.
- [Errors and testing](/code/sdk/guides/errors-and-testing): a test plan that runs entirely in `test`.
- [Previews](/code/api/guides/modes): the `try` [Mode](/business/nouns/mode) previews a call without recording it, in either environment.