One way to do this is as a JavaScript library - in API Creator, go to API Properties > Libraries and create a new library containing e.g.:
var topLevelVariables = {
urlForThis: "https://blah",
passwordForThat: "supersecret"
};
If you mark that library as used (checkbox then save), then you'll have those variables available anywhere in your code as e.g. topLevelVariables.urlForThis.
By the way, you don't even have to enclose your variables in a top-level object like this, it's just considered good form in the JavaScript world, to minimize the pollution of the top-level namespace.
Another possibility is to use system variables, which you can then specify when starting Java with e.g. :
java -DmyProperty=myValue etc...
and use in your rules with e.g.:
var myUrl = java.lang.System.getProperty("myProperty");
You can do the same thing with environment variables using e.g.:
var myUrl = java.lang.System.getenv("myEnvironmentVariable");
Which one is right for you depends a great deal on the specific use case. Being able to set the values from the command line is sometimes hugely helpful, but it's not always appropriate, in which case using a library might be a better idea.