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

# Environments

> Live vs test keys, and what changes when you switch.

Yotel has two environments on a single codebase + database. You
switch by switching the API key's prefix:

| Prefix      | Environment | Behavior                                                          |
| ----------- | ----------- | ----------------------------------------------------------------- |
| `yt_live_…` | Live        | Real PSTN dialing, real charges, webhooks to your production URL. |
| `yt_test_…` | Test        | Sandbox: DB writes + webhooks fire, but no PSTN originate.        |

## What changes in test mode

| Surface                          | Live                           | Test                                    |
| -------------------------------- | ------------------------------ | --------------------------------------- |
| `POST /api/v1/campaigns`         | Creates row                    | Creates row (identical)                 |
| `POST /api/v1/leads`             | Inserts lead                   | Inserts lead (identical)                |
| `POST /api/campaigns/{id}/start` | Starts dialer + originates     | Starts dialer, no originate             |
| Call recordings                  | Real audio                     | No recording created                    |
| Webhooks                         | POSTed to subscription's `url` | POSTed to `test_url` if set, else `url` |
| Rate limits                      | Enforced                       | Enforced (identical)                    |
| DND scrub                        | Enforced                       | Enforced (identical)                    |

Test mode is **not** a read-only mode — writes persist. Your sandbox
campaigns + leads share the tenant's database with production. Use
distinct labels or a separate tenant if that bothers you.

## Webhook subscription test\_url

When creating a webhook subscription, you can optionally set
`test_url` to a separate endpoint. Test-environment events POST there
instead of the production `url`. Common pattern:

```
url:      https://api.prod.mycrm.com/webhooks/yotel
test_url: https://webhook.site/abc-123
```

That way your prod integration isn't polluted with test-mode events
during development.

## How webhooks indicate environment

Every webhook delivery's `data` includes the originating call /
campaign, which carries the environment pinned at dial time (via
`calls.dial_mode` and related fields). To distinguish explicitly,
add a custom header or inspect the key that triggered the event —
we'll add `environment` to the envelope in v1.1.

## Switching a campaign between environments

You can't. The environment is pinned to the key that created the
campaign. To "convert" a test campaign to live: export its config +
leads, create a new campaign with a live key, import.

This is a deliberate guardrail. Bugs that silently promoted test
actions to live would be regulatory (TRAI) + billing incidents.
