How to programatically render only the selected env(s)?

It would be helpful to be able to set the envs to render as in the viewer. I searched through the doc but did not find an available API for this.