Accept more than only one environment variable in envvar REST API endpoint



The CircleCI REST API has an endpoint for adding environment variables:

POST /project/:username/:project/envvar

And it accepts the following body format:

{"name": <var_name>, "value": <var_value>}

However, it only accepts a single variable! This is an incredible inconvenience when you make a habit of storing values in the environment, and you need to add many to the CircleCI project to make it test and build correctly (I typically see 20+ per project).

I propose accepting multiple variables at once. Since the endpoint accepts application/json format, I would keep with JSON standard and simply extend the endpoint to accept an array of the same format:

  {"name": <var_name_1>, "value": <var_value_1>},
  {"name": <var_name_2>, "value": <var_value_2>},
  {"name": <var_name_3>, "value": <var_value_3>},
  {"name": <var_name_4>, "value": <var_value_4>}

This shouldn’t be a difficult change, since the endpoint is clearly already reading JSON. Simply wrapping whatever code is processing the input with code to iterate over it should be about all the effort involved here (I know… assumptions).