Twilio SMS is saying a "to" phone number is not provided even though it is

810 views Asked by At

I have very simple code and I just can't figure out what's going wrong.

I have a Twilio trial account and a trial phone number and I am trying to send an SMS using it.

from os import environ
from twilio.rest import Client

client = Client(environ['ACCOUNT_SID'], environ['AUTH_TOKEN'])

message = client.messages.create(body = f'The verification code for Treal is {code}', from_ = "+1**********", to = "+91**********")

The one in the from is my Twilio trial number and the one in the "to" is a number I want to send to. I am getting an error:

twilio.base.exceptions.TwilioRestException:
HTTP Error Your request was:

POST /Accounts/AC*******1830e0****a3403dfd16d****/Messages.json

Twilio returned the following information:

Unable to create record: A 'To' phone number is required.

More information may be available here:

https://www.twilio.com/docs/errors/21604
2

There are 2 answers

4
omercotkd On BEST ANSWER

With a trial account, in Twilio, you can send a message only to the phone you signed in with or verified so if I provided the phone number "1234" I can only send messages to "1234".

Maybe you didn't provide a phone number when you signed up?

Twiilo docs docs pic

2
Alan On

Check for hidden control characters using a site like https://www.soscisurvey.de/tools/view-chars.php, and simply using a regular string, and see if it works or not and then work to failure.