Deploy context specific environment variable secrets out of netlify.toml

I am wanting to set deploy context-specific environment variable overrides that are secrets (e.g. API_KEY) so I don’t want to hardcode them in the netlify.toml file.

Is there a way to set Deploy context-specific environment variables via the UI or API to avoid hard-coding them?

In your code, you can do something like:

let secret = process.env.CONTEXT === 'foo' ? process.env.SECRET1 : process.env.SECRET2

Here’s a more detailed example: How to Contextualize your env vars with Netlify Build Plugins