Environments let you issue distinct keys for development, staging, and production. Test keys can't affect real resources, while live keys have full access.
When to use this#
Developers can test integrations without touching production data.
CI/CD pipelines can run tests with keys that won't affect live resources.
Test keys might have lower rate limits or be free to use.
Prefixes like sk_test_ make it obvious when using non-production keys.
How it works#
Environments are implemented using key metadata and prefixes, there's no special "environment" field. This gives you full flexibility to model environments however you want.
Common pattern:
- Prefix:
sk_test_vssk_live_(visible to users) - Metadata:
{ "environment": "test" }(returned on verification)
Create environment-specific keys#
Using prefixes makes it obvious to users which environment a key is for. This prevents accidental use of test keys in production (or worse, live keys in tests).
Verify and check environment#
The metadata is returned during verification, so your API can behave differently:
Response: