How to Add ENV vars using the CLI

Your best advice on doing anything our UI can do via API will be in this article, @Resto:

If you watch what our UI does when you save a variable, you can see a call like this:

HTTP PUT https://api.netlify.com/api/v1/site/YOUR_SITE_ID_HERE

with a value like this:

{"build_settings":
  {"env":
    {"EXISTING_VAR":"existing_val","NEW_VAR":"new_val"}
  }
}

Make sure you send ALL existing vars, but also, try it in the UI first to see the shape of the command so you make sure you aren’t missing anything - perhaps my test site didn’t have some other configuration that yours did and you’d need to send that along too :slight_smile: