Environments: Test vs Production
How Aforo separates test from production usage — the key prefix decides the environment, and a dedicated test endpoint guarantees non-billable events.
Two environments, one key#
Aforo separates test from production by the API key you use — not by a config flag, an environment header, or a separate base URL. A sk_test_ key marks the test environment; a sk_live_ key marks production. Both post to the same ingest host, ingest.aforo.ai; the key decides which environment the event lands in.
ingest-sandbox.aforo.ai and no prefix-based host switching. Everything goes to ingest.aforo.ai. To move between environments you swap the key — nothing else changes.The test environment#
Use a sk_test_ key for local development, CI, and integration tests. It runs the same metering, entitlement, and rating pipeline as production, so your integration behaves the same way — but keeps test traffic separate from your live data.
Guaranteed non-billable: POST /v1/ingest/test
When you just want to confirm connectivity without touching any of your own data, post to the dedicated test endpoint. It routes the event to Aforo's own sandbox workspace regardless of the key you present, so it never bills and never appears under your workspace. It also skips metric-existence validation — any metric name is accepted for a smoke test.
The regular POST /v1/ingest path behaves identically in both environments — the difference is which key you send.
Production#
A sk_live_ key processes real usage: every event is rated against your live rate plans and accrues to the customer's invoice for the next billing cycle.
sk_live_ key. A suite that fires 50,000 events writes 50,000 events into your production data. Use a sk_test_ key — and /v1/ingest/test for pure connectivity checks.Switching environments#
Switching is a one-line change: point AFORO_API_KEY at the other key. No code changes, no config files, no redeploy of your application logic — only the secret changes.
You read the variable and pass it to the client — the SDK doesn't read the environment for you, and it doesn't inspect the key prefix to pick a host. There is one default host (ingest.aforo.ai), which you can override with baseUrl for on-premise or proxied deployments.
SDK options#
These are constructor options, not environment variables — the client reads none of these from the environment automatically. Read what you need from your own env and pass it in.
Per-environment keys in CI
Inject the right key per environment via your CI provider's secrets:
Keeping test data out of production#
The environment boundary is enforced server-side by the key, not by the UI. Events sent with a sk_test_ key are scoped to your test data and are never mixed into your production billing — even if a customer ID happens to match a real production customer. And anything sent to /v1/ingest/test lands in Aforo's sandbox workspace, entirely outside your account.
cust_test_001, then create the real customer in production when you go live.