Unfortunately, there’s no way to set API keys directly through environment variables in n8n. API keys must be created through the frontend interface by going to **Settings** > **n8n API** and clicking “Create an API key” as described in the [docs.n8n.io]( Authentication | n8n Docs ) documentation.
However, once created, you can store the API key value in environment variables or secure files for your applications that need to call the n8n API. For automated deployments, consider using configuration management tools or scripts that can interact with the n8n API to create keys programmatically after the initial setup, or use the `_FILE` suffix pattern mentioned in the [docs.n8n.io]( Configuration methods | n8n Docs ) to keep sensitive API keys in separate files rather than directly in environment variables.