Subaccounts
Subaccounts possess their own resources, such as phone numbers, yet they are managed under a primary Twilio account with which they share a financial balance. This page should help you get started.
Last updated
Subaccounts possess their own resources, such as phone numbers, yet they are managed under a primary Twilio account with which they share a financial balance. This page should help you get started.
Last updated
Subaccounts can be created and accessed via Console, but can also be managed via the Twilio REST API. For more details, please see our article .
For each subaccount you will need the following:
Subaccount Sid
API key & Secret
Voice Application
Caller number: make sure the number uses the main account calling function
To create a subaccount go to the console > subaccounts > Create
If you are using the console, make sure to switch to the subaccount before implementing the following steps
Make sure you are using the subaccount console, then follow the same steps as
Make sure you are using the subaccount console, then follow the same steps as . Regarding the application voice function, you can use the main account voice function for easier maintenance. How ever you can create functions for each account, if you have a special use case.
Create a custom event this event then Add an action that requests a subaccount voice access token and store the value in a state
Provide the token to the client element by referring to the token state
To ensure uninterrupted service, it's crucial to refresh client tokens before they expire. Implement a token refresh mechanism by triggering a custom event, get-token
, upon detecting that the current token is nearing expiration. Here's how to set up the event trigger:
Detect Token Expiration: By adding the token expiring element event
Trigger Custom Event: Add the get-token
action. This action should request a new token and update the token state.
By following these steps, you can ensure your application maintains secure and continuous access to resources by keeping client tokens up to date.
That can be implemented in two ways:
Using one voice function and adding the voice function URL to all the numbers under this account
Similar to the , just make sure to use a Caller number that's registered under the subaccount.
Using Twilio Studio flow; Similar to the , just make sure to do it form the subaccount console.