I have a site that requires a secret user token in order to access an API during build. I have set this using the environmental variables feature since I don’t want to commit it into a public repo. Now I am told that the token will need to be updated regularly using the same API. Is it possible to write values back to environmental variables? If not is there a way I can achieve this aim?
Sure, you can use our API to set environment variables (this guide will show you how to discover the call and the shape of the data to use: [Common Issue] Understanding and using Netlify's API), though probably best not to try to do it directly from a Netlify function - not sure you were suggesting that but I wouldn’t recommend it :).
Note also that you do need to redeploy the site (and thus the function) once you’ve changed the variable(s) since they are “snapshotted” at deploy time.
Let me know if you have any questions!