Fawran
Get Started

Environments

Sandbox vs live — hosts, environment-scoped keys, and how to tell where a request landed

Environments

Fawran runs two completely isolated environments. Nothing is shared between them: customers, plans, subscriptions, usage and provider accounts all live in one or the other.

EnvironmentHostKey prefixUse it for
Sandboxhttps://sandbox.fawran.copto.orgfawran_sk_test_Development, tests, CI — throwaway data
Livehttps://api.fawran.copto.orgfawran_sk_live_Production — real customers, real charges

The dashboard has a sandbox/live toggle in the header; everything you see is scoped to the selected environment.

Sandbox is managed

You never configure a payment provider for the sandbox. Fawran owns a test account on every supported provider (Paystack, Stripe, Dodo Payments, Bachs) and every organization transacts through them:

  • attach(), wallet setup, invoice payment and plan sync all just work on sandbox.fawran.copto.org with a fresh organization.
  • Checkout pages are the providers' real test pages — use their test cards.
  • Provider webhooks for those accounts are already pointed at Fawran, so payments confirm without you registering anything.
  • Settings → Providers lists these as Managed by Fawran. They cannot be edited or deleted.

If you need to see sandbox activity in your own provider dashboard, add your own test keys for that provider under Settings → Providers. Your account then replaces the managed one for that provider only, and you register the per-organization webhook URL yourself as described in Webhook setup.

Live is yours. Production always charges through provider accounts you own. The Go to Production flow in the dashboard asks for live keys for the providers your sandbox catalog uses before it lets you switch.

Keys are scoped to one environment

An API key belongs to exactly one environment, encoded in its prefix. The API enforces it:

  • an fawran_sk_test_… key sent to api.fawran.copto.org is rejected with 401 environment_mismatch before anything is written;
  • an fawran_sk_live_… key sent to sandbox.fawran.copto.org is rejected the same way.
{
  "success": false,
  "error": {
    "code": "environment_mismatch",
    "message": "This API key is scoped to the sandbox environment but the request was sent to the live API (https://api.fawran.copto.org). Use an fawran_sk_live_… key, or send this request to https://sandbox.fawran.copto.org."
  },
  "environment": "live",
  "keyEnvironment": "sandbox"
}

Create one key per environment in Settings → API keys, choosing the environment for each. fawran connect issues both at once.

Legacy keys. Keys created before scoping existed look like fawran_sk_… (no test/live) and are still accepted by both hosts. They cannot protect you from writing to the wrong environment — rotate them when you can.

Every response tells you where it landed

You never have to infer the environment from a hostname. Every public API response carries:

WhereField / headerValues
Response headerX-Fawran-Environmentsandbox | live
Response headerX-Fawran-Organizationyour organization ID
check / track bodyenvironmentsandbox | live
const result = await fawran.track({ customer: "workspace_1", feature: "agent_turns" });
if (result.environment !== "live") {
  console.warn("usage was recorded in", result.environment);
}

Selecting the environment

Neither the SDK nor the CLI defaults to an environment silently.

SDK

// A scoped key is enough — the SDK infers the environment from the prefix
const fawran = new Fawran({ secretKey: process.env.FAWRAN_SECRET_KEY });
fawran.mode; // "sandbox" | "live"

// A legacy key needs an explicit mode
const fawran = new Fawran({ secretKey: "fawran_sk_…", mode: "sandbox" });

With a legacy key and no mode, the first request throws FawranError (code: "config_error") rather than hitting live. If mode contradicts the key's scope, that is also a config_error. See Configuration.

CLI

fawran sync                     # mode inferred from an fawran_sk_test_/fawran_sk_live_ key
fawran sync --mode live --yes   # explicit
FAWRAN_MODE=sandbox fawran diff

With a legacy key and no --mode, fawran exits with code 2 and says what to pass. See CLI commands.

Same code, both environments

Keep one code path and switch only the key:

# .env.development
FAWRAN_SECRET_KEY=fawran_sk_test_…

# .env.production
FAWRAN_SECRET_KEY=fawran_sk_live_…

Sync your catalog to each environment separately — the catalog is data, and the two environments don't share it:

FAWRAN_SECRET_KEY=$SANDBOX_KEY fawran sync --yes
FAWRAN_SECRET_KEY=$LIVE_KEY    fawran sync --yes

Self-hosted deployments

If you run your own Fawran API, point the SDK at it with apiUrl and the CLI with FAWRAN_API_URL (or environments.test / environments.live in fawran.config.ts). The key prefix rules still apply, because the same code enforces them.

On this page

Ask about fawran

Ready

Start a new chat below.