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

# Environments

> Build and test in Staging, then go live in Production. Same API, separate data and keys.

SalesOS has two environments. They run **the same API** — same endpoints, actions, fields and errors — with **separate data and separate keys**.

| | Staging | Production |
| - | - | - |
| **Use it for** | Building and testing your integration | Real companies, real people, real money |
| **API base URL** | `https://api-staging.play2sell.com` | `https://api.play2sell.com` |
| **Dashboard** | `https://app-staging.play2sell.com` | `https://app.play2sell.com` |
| **API key prefix** | `sk_test_` | `sk_live_` |
| **Data** | Test companies and test people | Your company's real data |
| **Payments** | Provider test mode: no real money moves | Real charges |
| **New versions** | Arrive first | Arrive after they are verified in Staging |

> [!NOTE]
>
> Keys never cross environments. A `sk_live_` key sent to Staging, or a `sk_test_` key sent to Production, gets `401` with `code: "api_key_not_found"`.

## Choose the environment by its base URL

Only the base URL changes. Paths, bodies and signatures are identical, so keep the base URL and the key in configuration, never in code:

```bash Staging theme={null}
export P2S_BASE_URL="https://api-staging.play2sell.com"
export P2S_API_KEY="sk_test_..."
export P2S_API_KEY_SECRET="..."
```

```bash Production theme={null}
export P2S_BASE_URL="https://api.play2sell.com"
export P2S_API_KEY="sk_live_..."
export P2S_API_KEY_SECRET="..."
```

Every example in this documentation uses the production URL. To run it in Staging, swap `https://api.play2sell.com` for `https://api-staging.play2sell.com` and use a `sk_test_` key.

> [!WARNING]
>
> The signature covers the path, not the host, so the same request signed for one environment is valid in the other **only with that environment's key**. Never reuse a production key in test tools.

## Get a key for each environment

**1. Staging**

Ask your Play2sell contact for access to a **test company** in Staging. Then, in `https://app-staging.play2sell.com`, go to **Admin > Integrations > API Keys** and create a key with the scopes your integration needs. It starts with `sk_test_`.

**2. Production**

When your integration passes the checklist below, an admin of your company creates the key in `https://app.play2sell.com`, same menu, same scopes. It starts with `sk_live_`.

The secret is shown **only once**, when the key is created. Store it in a secret manager.

## What to test in Staging

| Area | What to try |
| - | - |
| Signing | One successful call and one with a wrong secret (`401 signature_invalid`), so your logs show the difference |
| Scopes | A call your key is not allowed to make (`403 scope_insufficient`) |
| Validation | A request with a missing field (`400 VALIDATION_ERROR` with `details`) |
| Retries | The same write twice with the same `idempotency_key`: the second answer has `idempotent_replayed: true` |
| Limits | Batches at the maximum size of each action |
| Webhooks | Use **Test Webhook** in the Dashboard and verify the signature on your side |
| Payments | Create a charge and follow its status; no real money moves in Staging |

## Go-live checklist

* [ ] Base URL and key come from configuration; nothing environment-specific in code
* [ ] A `sk_live_` key with only the scopes you use
* [ ] The secret is in a secret manager, not in the repository or logs
* [ ] Your server clock is synchronized (signatures are valid for 30 seconds)
* [ ] Retries with backoff on `429` and `5xx`; writes carry an `idempotency_key`
* [ ] The request ID of every answer is logged (`meta.request_id`, or `instance` in Payments errors), so support can find any call
* [ ] Webhook endpoint in production is `https://`, public, verifies the signature and answers `2xx` quickly
* [ ] The first production calls are monitored for a day

## Good practices

* **Use Staging for anything that writes.** Exploring with reads in production is fine; trying writes is not.
* **Test data stays in Staging.** Do not copy real people's data into Staging.
* **Expect new versions in Staging first.** If something changes, you see it there before it reaches production.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.