Menu

Rate this page:

Thanks for rating this page!

We are always striving to improve our documentation quality, and your feedback is valuable to us. How could this documentation serve you better?

REST API: Subaccounts

Subaccounts in Twilio are just accounts that are "owned" by your account. Using a subaccount, you can segment each of your customers' use of Twilio and keep it separate from all the rest. This will allow you to easily manage the activity and resources of each customer independently.

Important Notes:

  • A master account can only have up to 1000 subaccounts by default. If you need more subaccounts please contact support.
  • Subaccounts will not have access to the API Explorer in their Twilio Console.
  • By default, closed subaccounts get deleted after the parent account is closed. To enable automatic deletion of subaccounts, 30-days after you closed them, please contact support.

Billing

Twilio bills all subaccount usage directly to your master account. You'll have one Twilio balance for all subaccounts. If your master Twilio account is ever suspended, your subaccounts will also be suspended.

Skip to calculate billing for subaccounts >>

Authentication

You can use your master Twilio Account credentials (AccountSid and AuthToken) to access Twilio's REST API for your master account as well as any of your subaccounts. You may also use a subaccount's AccountSid and AuthToken to access the resources of that subaccount. You can not use a subaccount's credentials to access the resources of your master Twilio account or any other subaccounts.

International

We are currently working on ways to help our customers minimize the risk of fraudulent international calls and provide ways for Twilio subaccounts to dial certain international destinations. If you have any questions, please contact support.

Permissions

Subaccounts use the master account's voice and SMS messaging permissions.

Creating Subaccounts

To create a new subaccount, make an HTTP POST request to your Accounts list resource URI:

/2010-04-01/Accounts

If successful, Twilio responds with a representation of the new Account resource.

POST Parameters

Optional Parameters

Your request to create a subaccount may include the following parameters:

FriendlyName
Optional
post string PII MTL: 30 DAYS

A human readable description of the account to create, defaults to SubAccount Created at {YYYY-MM-DD HH:MM meridian}

The FriendlyName property is useful for organizing accounts and linking them back to information in your own system. For example, you may want to create subaccounts where the FriendlyName is the primary key of the customer in your application's database.

Example
Loading Code Sample...
      
      
      
      

      Getting Started with Subaccounts

      Subaccounts are a great way to segment your Twilio usage and act on behalf of your customers, agents or employees.

      If you are running a hosted service that relies on Twilio you can create a Twilio subaccount for each customer that signs up. Then if a customer closes his or her account with your service, you can simply deactivate the associated Twilio subaccount.

      Subaccounts allow you to use the Twilio REST API just as you would for a single account; a subaccount can have its own phone numbers and caller IDs, applications and SIP Domains. You can manage a subaccount's calls, messagess, recordings, and transcriptions without affecting other subaccounts.

      Finding Subaccounts

      You can query any particular subaccount and its related resources via the REST API by AccountSid.

      Loading Code Sample...
          
          
          
          

          If you don't know the AccountSid of a subaccount but you know the FriendlyName, you can query your Accounts list resource with a FriendlyName query string filter:

          Loading Code Sample...
              
              
              
              

              Making a phone call with a Subaccount

              In order to make calls and send messages using a subaccount you simply need to replace the account credentials with the subaccount credentials.

              Loading Code Sample...
                  
                  
                  
                  

                  Calculate billing for Subaccount usage

                  In many cases you may want to calculate the billing incurred by a subaccount. Let's say you created a subaccount for a customer and you needed to charge them for their monthly usage.

                  This is how you would calculate how many minutes of calling your customer made over the last 30 days:

                  Loading Code Sample...
                      
                      
                      
                      

                      Suspending a Subaccount

                      While an account is suspended it cannot make or receive phone calls or send and receive SMS messages. This is useful when your customer does not pay their bill and you want to suspend their account until a successful payment is received. However, you will be charged monthly for any phone numbers the subaccount owns.

                      To suspend a subaccount, POST the parameter 'Status' with the value 'suspended' to suspend an account.

                      Loading Code Sample...
                          
                          
                          
                          

                          To reactivate a suspended subaccount, POST the value active for the Status parameter and we will restore the account to full service.

                          Loading Code Sample...
                              
                              
                              
                              

                              Note that you must use your primary account's authentication credentials to suspend a subaccount. You cannot suspend your master account.

                              Closing a Subaccount

                              If your customer closes their account with you, you can permanently close the associated Twilio subaccount by POSTing the parameter Status with the value closed to the subaccount resource URI.

                              Loading Code Sample...
                                  
                                  
                                  
                                  

                                  When you close a subaccount, Twilio will release all phone numbers assigned to it and shut it down completely. You can't ever use a closed account to make and receive phone calls or send and receive SMS messages. It's closed, gone, kaput – you cannot reopen a closed account.

                                  Your closed subaccount will still appear in your accounts list, and you will still have access to historical data for that subaccount, unless automatic deletion of closed subaccounts is enabled.

                                  If you have enabled automatic deletion of closed subaccounts through the Subaccounts settings page, we will delete all subaccount data 30 days after closure including previously closed subaccounts and those subaccounts will no longer appear on the Console.

                                  • Twilio has enabled this setting for all accounts created after July 5, 2018, and for all accounts without subaccounts
                                  • For all other accounts, account owners can turn this setting on through the Subaccounts settings page.

                                  Note that you must use your master account's authentication credentials to close a subaccount. You also cannot close your master account.

                                  Exchanging Phone Numbers Between Accounts

                                  You can transfer numbers between subaccounts, and between your master account and any one of your subaccounts. You must use your master account's credentials when making the API request to transfer a phone number.

                                  To transfer a phone number between two accounts that you control, make an HTTP POST request to an IncomingPhoneNumber instance resource URI. In the body of the POST set the parameter 'AccountSid' to the AccountSid of the account you wish to own that number. This will remove the phone number from its original account and make it available under the IncomingPhoneNumbers list resource of the new account while retaining all other properties.

                                  If any of the phone numbers you would like to transfer have Address Requirements, you will need to create a compliant Address in the new subaccount before transferring the phone number.

                                  Remember, closing a subaccount as described above will release all of that account's phone numbers, so you might consider transferring all numbers to your master account beforehand if you want to keep them.

                                  Example

                                  Transfer a phone number from account AC00000000000000000000000000000001 to AC00000000000000000000000000000002:

                                  Loading Code Sample...
                                      
                                      
                                      
                                      

                                      Need some help?

                                      We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd browsing the Twilio tag on Stack Overflow.

                                      Loading Code Sample...