Environments and test mode

Test vs. live selected by key, full data isolation, and simulating referrals end to end

Every Invitebase org has two parallel environments: test and live. Which one you're talking to is determined entirely by the API key — there is no separate sandbox host, no environment parameter, nothing else to configure.

import invitebase from '@invitebase/js';

// Test mode
invitebase.configure('pk_test_51Hq2jK');

// Live mode — same call, live key
invitebase.configure('pk_live_51Hq2jK');

Publishable keys work the same way — the prefix passed to configure puts the whole client in test or live mode. Key prefixes make the mode legible at a glance: sk_test_ / pk_test_ vs. sk_live_ / pk_live_.

Full isolation, guaranteed

Mode is a first-class tag on every object — campaigns, referrers, links, referrals, events, rewards, payouts — stamped from the API key, never client-supplied. That buys three hard guarantees:

  • Test data is never billed. Billing aggregation counts live-mode validated referrals only. Validate ten thousand test referrals; your invoice is unchanged.
  • Test mode never moves real money. Test payouts route exclusively to sandbox providers; live provider credentials are unreachable from test-mode code paths. The test-mode balance is fake-funded, so the full ledger flow — top-up, hold, debit — works without a card.
  • The modes never see each other. A test key cannot read or write live objects and vice versa. Cross-mode leakage is a bug class Invitebase tests against, not a configuration you maintain.

Test mode is otherwise the real system: the same ingestion pipeline, the same qualification engine, the same state machine, and real webhook deliveries (flagged with "livemode": false). What you prove in test is what runs in live.

The dashboard toggle

The dashboard has an environment switch in the top bar, and every screen — campaigns, users, events, webhooks, payouts, analytics — scopes to the selected mode. While test mode is active, a loud colored banner spans the app so you always know which data you're looking at. If a screen looks empty, check the toggle first: "where did my data go" is almost always "wrong mode".

Simulating referrals in test mode

You can exercise the entire referral loop in minutes without a live app or real users:

Create a test campaign

Use your sk_test_ key (or the dashboard in test mode) to create a campaign with the gates and rewards you intend to ship.

Create a referral link for a test referrer and open it — the refr.link page records a real clicked referral in test mode.

Fire events from the event simulator

In Developers → Event simulator, pick or create a test participant and fire synthetic events — a signup, your custom gate events, even a simulated RevenueCat or Adapty purchase — with whatever properties you need. Simulated events flow through the real ingestion path and gate engine; there are no shortcuts to invalidate your test.

Watch the lifecycle advance

On the Overview live feed and the referral's page, watch it move clicked → signed_up → in_progress → validated → reward_pending → reward_fulfilled as events land. Webhooks fire to your registered test endpoints at each step — the webhook scenario simulator can also replay a full lifecycle sequence against your endpoint in one click. See Webhooks.

The same synthetic events also drive reward fulfillment: app-grant claims work against test rewards, and money payouts run against the sandbox provider with fake funds — including failure simulation, so you can test your reward.failed handling.

Test mode keeps working alongside live forever — keep staging builds on test keys, and use the simulator to reproduce production questions safely. For key management (creation, rolling, revocation), see the Developers section of the dashboard.

On this page