Reputation: 1133
I have created a subaccount with Twilio Python SDK using the above code:
twillio_client = Client(settings.TWILLIO_ACCOUNT_ID, settings.TWILLIO_TOKEN)
try:
sub_accounts = twillio_client.api.accounts.list(friendly_name=os.getenv('SERVER_UNIQUE_NAME'), status='active')
sub_account = sub_accounts[0]
except Exception as e:
try:
sub_account = twillio_client.api.accounts.create(friendly_name=os.getenv('SERVER_UNIQUE_NAME'))
except Exception as e:
logger.exception(f'Failed to create new subaccount')
but when I am trying to send a message with this subaccount it throws me the following exception:
twilio.base.exceptions.TwilioRestException: HTTP 400 error: Unable to create record: The From phone number +1XXXXXXXXXX is not a valid, SMS-capable inbound phone number or short code for your account.
the number +1XXXXXXXXXX is my master account number and it works fine Any ideas?
Upvotes: 0
Views: 897
Reputation: 73029
If the number you are using is owned by the master account, then the subaccount won't be able to use it to send messages. Master accounts can use the resources of subaccounts, but subaccounts cannot access master account resources.
If you create a subaccount and want to send messages from it, you will need to get a number for that subaccount too.
Upvotes: 1