create a file like:
.ebextensions/temporarily_set_env_variable.config
add:
+option_settings:
+  aws:elasticbeanstalk:application:environment:
+    API_ENDPOINT: www.example.com/api
git add .ebextensions/temporarily_set_env_variable.config
then:
eb deploy [environment] --staged