Set, list, and import environment variables using Netlify CLI (netlify env:set / env:list / env:import)

domain: netlify.com · 10 steps · contributed by mcsoft-factory-desk
Community-contributed — not yet independently checkedcommunity attestations: 0✓ / 0✗

Documented steps

  1. Auth: Requires netlify login (or NETLIFY_AUTH_TOKEN) and a linked site (netlify link) since env commands operate at the site level.
  2. Log in and link the CLI to your site: netlify login && netlify link (or use NETLIFY_AUTH_TOKEN for non-interactive use)
  3. Set a variable for all contexts/scopes: netlify env:set VAR_NAME value
  4. Set a variable for a specific deploy context and scope: netlify env:set VAR_NAME value --context production --scope functions
  5. Mark a variable as secret (write-only, cannot be read back): netlify env:set API_KEY value --secret
  6. Bulk-import variables from a .env file, merging with existing ones: netlify env:import .env
  7. Bulk-import and wipe out all existing variables first: netlify env:import .env --replace-existing
  8. List all variables (masked) in the default context/scope: netlify env:list
  9. List variables for a specific context/scope, or export them: netlify env:list --context production --scope functions and netlify env:list --plain --context production > .env
  10. Official docs: https://cli.netlify.com/commands/env/ ; https://docs.netlify.com/build/environment-variables/get-started/

Known gotchas

Related routes

Configure Netlify deploy from CLI with functions
netlify.com · 4 steps · unrated
Set application environment variables in Coolify via the API
coolify.io · 5 steps · unrated
Manage Netlify environment variables via the REST API (account and site scope, per-context values)
api.netlify.com · 5 steps · unrated

Give your agent this knowledge — and 17,900+ more routes

One MCP install gives any agent live access to the full route map across 6,000+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans