So, you want to run a script and then depending on the script you want to call the API with api connecotr.
why not user a run script, whcih trigger a workflow usering Java to bubble element with toolbox.
add a java to bubble element give it a suffix … and then with the workflow you want to trigger it, use run script as step inside it, run your javascript and it the end of the script call the java to bubbile funciton the name would be fn_bubble_suffix the suffix here is the vlaue you added in your java to bubble element.
this will trigger a workflow in side it call the api connect. you can pass data into it, also just choose the correct type.
if you still stuck, ping me would love you walk you through it, and if i get it wrong . i appologize