> For the complete documentation index, see [llms.txt](https://docs.tiun.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tiun.io/guides/getting-started/set-up-environment.md).

# Set up your environment

tiun runs **two fully independent environments in parallel**: **live** (real customers, real payments) and **sandbox** (simulated payments, separate catalog and credentials). They are not two modes of the same data — each has its own environment setup, snippet ID, products, product IDs, and API keys.

Most teams **set up sandbox first** while building, test the integration there, then **set up live separately** and swap environment-specific values when they ship. You can configure either environment first; both can be active at the same time.

For the full picture, see [Sandbox](/reference/generic/sandbox.md) in Reference.

***

## Set up sandbox

Sandbox is a **parallel copy** of your tiun setup. Enable it once in the dashboard, then point your dev or staging app at it with `sandbox: true`.

### Enable sandbox in the dashboard

In the dashboard sidebar, click the **Sandbox** toggle. The first time, a dialog asks you to enable sandbox — click **Enable**. There's nothing to fill in: no domain, no settings.

From then on, the toggle switches the whole dashboard between live and sandbox at any time. Products, customers, snippet ID, and API keys in the sandbox view are all separate from live.

Create your **sandbox** products here (mirroring what you plan to sell in live). Copy your **sandbox snippet ID** and `p-test-...` product IDs from this view.

### Point your app at sandbox

In the app you use for development or staging, pass `sandbox: true` and your **sandbox** snippet ID:

```javascript
import { tiun } from '@tiun/sdk';

tiun.init({
  snippetId: 'YOUR_SANDBOX_SNIPPET_ID',
  language: 'en',
  sandbox: true,
});
```

In **sandbox**, `localhost` works out of the box on any port — you don't need to register it. If you also want to test from a hosted staging site, or from a native app, add its domain or app scheme in the sandbox view's **Settings → Environment setup** (see [below](#environment-setup)).

{% hint style="info" %}
**While you're building, keep the dashboard and your app on the same environment.** If the dashboard shows live but your SDK has `sandbox: true` (or the other way around), IDs and sessions won't match what you see in the UI.
{% endhint %}

If you verify purchases or sessions on your server during development, use the **sandbox** API base URL and a **sandbox** API key. Live and sandbox keys are not shared.

***

## Set up live

Until live is configured, the dashboard prompts you to **Set up your live environment**. Click **Set up now** — or go to **Settings** directly — and open **Environment setup**. This is where you tell tiun where it runs: your website, your app, or both.

### Environment setup

Environment setup has two sections. Turn on the ones that apply — **Web**, **App**, or both.

**Web** — your website or web app.

* **Live domain** — your site's address, for example `yoursite.com`. tiun only works on this domain and nowhere else; `localhost` is blocked in live.

**App** — your iOS or Android app.

* **App scheme** — the custom URL scheme your app registers, for example `myapp://`. After payment, checkout uses it to get back into your app. It must be the same scheme you register natively and use in the SDK's `returnUrl` — see [integrate with React Native](/guides/app-integration/monetize-in-react-native.md).

You enter **one** domain and **one** app scheme yourself. If you need more — a second domain, another app — they appear under **Additional domains** and **Additional app schemes**, which tiun manages for you. Contact <support@tiun.io> to add or change them.

{% hint style="info" %}
**Each environment has its own Environment setup.** What you save in the live view applies to live only; the sandbox view has its own, which you only need for non-`localhost` testing.
{% endhint %}

### Products and snippet ID

With the toggle on live, create your **live** products in **Products**. Copy your **live snippet ID** and `p-live-...` product IDs from this dashboard view — they only work with live traffic.

In your production app, initialize the SDK **without** `sandbox` (or with `sandbox: false`) and use those live IDs:

```javascript
import { tiun } from '@tiun/sdk';

tiun.init({
  snippetId: 'YOUR_LIVE_SNIPPET_ID',
  language: 'en',
});
```

To receive the money you earn in live, add your beneficiary details — see [enable payouts](/guides/getting-started/enable-payouts.md).

***

## Going live from sandbox

When your sandbox integration works and you're ready for production traffic:

1. **Set up live** in the dashboard (if you haven't already) — your live domain and/or app scheme in **Settings → Environment setup**, products, snippet ID, and API keys.
2. In your **production** deployment, remove `sandbox: true` from `tiun.init` (or set it to `false`).
3. Replace environment-specific values with their **live** counterparts:
   * Snippet ID
   * Product IDs (`p-test-...` → `p-live-...`)
   * Server-side API base URL and API key (if applicable)
4. [Enable payouts](/guides/getting-started/enable-payouts.md) so live revenue can be paid out to you.

The SDK API is identical across environments — only these IDs and credentials change. Your sandbox environment stays available for continued testing in parallel.

{% hint style="info" %}
**In React Native, the environment is selected with `host`, not `sandbox`.** Pass `host: 'https://api-sandbox.tiun.live'` for sandbox and omit it for live. Everything else on this page — separate snippet IDs, product IDs, and API keys per environment — applies unchanged. See [Configuration](/sdk/react-native-sdk/configuration.md).
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.tiun.io/guides/getting-started/set-up-environment.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
