Test and live projects
A project is created test or live; its environment does not change. A key of one environment is refused on a project of the other (422 api_key_environment_mismatch, field: environment).
Use a test project while you build: Deploy previews are made with test keys only, and production writes need a live key (403 deploy_production_live_key_required). For Mail, the server says which environment sends (403 test_key_not_allowed or live_key_not_allowed).
Resources (buckets, databases, functions, keys) of test and live are separate.