0

I have a studio flow set up under a Subaccount. I have a function created under the main account.

When I create a function widget in the subaccount studio flow, I don’t see the main account’s function listed.

I’ve also tried using the http request widget calling the function’s url, but studio shows an error saying that the url cannot be blank.

So is it possible to run a function under a different account with the Twilio Studio function widget?

1 Answers1

0

Subaccounts are normally used to separate resources from each other. So a Twilio Function written in one account will not appear in another.

You could use the HTTP request widget to make a request to the Function by its URL, however that would only work if your Function is set to public visibility.

I’ve also tried using the http request widget calling the function’s url, but studio shows an error saying that the url cannot be blank.

If you've entered the URL of the function into the widget, the Studio HTTP request widget should be fine. If you are finding it is showing an error, something else might be wrong.


I would not recommend running cross account resources like this though. It breaks the separation of concerns that a subaccount gives you.

Instead, I would deploy the function code to your subaccount as well, and then hook it up as normal in the Studio Flow. That way, you always know that only work done within the Subaccount can affect its behaviour.

philnash
  • 70,667
  • 10
  • 60
  • 88
  • Thanks Phil. The function I’m trying to call is a protected function. I wanted to keep it that way so that the x-twilio-signature would be in the header. All I need the function to do is attach an authorization header and forward the http request to my application. And I’ll have hundreds or thousands of subaccounts that need to do the same thing. I won’t be able to recreate the function under each subaccount. Thanks again for your feedback and open to suggestions! – thinkkeyspeak Aug 15 '22 at 15:17
  • The `X-Twilio-Signature` is created using the auth token of your account. Since a main account and a subaccount have different auth tokens, they cannot validate an `X-Twilio-Signature` from each other. You can automate deployment of the functions using the [Serverless API](https://www.twilio.com/docs/runtime/serverless-api) or the [Serverless Toolkit](https://www.twilio.com/docs/labs/serverless-toolkit), so it shouldn't matter if there are hundreds of subaccounts. Do watch out, a Twilio account by default can have a [max of 1000 subaccounts](https://www.twilio.com/docs/iam/api/subaccounts). – philnash Aug 15 '22 at 23:40