14

I'm getting the following error when I try to place calls using the Twilio REST API.

https://www.twilio.com/docs/api/rest

HTTP/1.1 401 Unauthorized 
Server: nginx 
Date: Thu, 10 May 2012 16:50:48 GMT 
Content-Type: application/xml 
Connection: close 
WWW-Authenticate: Basic realm="Twilio API" 
Etag: 
Last-Modified: 
Content-Length: 233 

401 Authenticate 20003 
http://www.twilio.com/docs/errors/20003

I googled, but found nothing. Anyone had this issue?

What I POSTed on the API call was:-

$url = 'https://api.twilio.com/2010-04-01/Accounts/ACdxxxxxxx/Calls';

From => +1415xxxxxx 
To => +1646xxxxx
Url => http://173.201.xx.xx/Test/Twilio/twilio_test.php
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Sparky
  • 4,769
  • 8
  • 37
  • 52
  • 2
    Hi, You need to authenticate your request with your Account Sid and Auth Token. See the curlopt_userpwd setting here: http://php.net/manual/en/function.curl-setopt.php#98164 – Kevin Burke May 10 '12 at 18:20
  • @KevinBurke Thanks, that was it. I provided the Auth Token through curlopt_userpwd and it worked. – Sparky May 13 '12 at 06:27

7 Answers7

16

It seems there are a few causes for this error. I discovered I receive an "Authenticate" error when my account funds have been depleted. When I added funds, it worked again without any problems.

PTK
  • 446
  • 4
  • 6
  • Second this, service just started failing in production, logged into the Twilio console and... oops. – Brandon Johnson Feb 25 '22 at 17:45
  • Same, our credentials are definitely correct, but still getting this error. Account was suspended, just added funds, not sure how long it will take... EDIT: ~5mn after payment, it worked again. – Vadorequest Jun 12 '23 at 13:08
7

(Twilio employee here.)

The 401 error is usually related to when you are supposed to authenticate but haven't or potentially an error occurred with it.

Can you provide the full snippet of code that you're using to place the call? Are you using one of our sample snippets or something else?

CaseySoftware
  • 3,105
  • 20
  • 18
2

Your Sid and Token must be wrong. Check your config file.

Max
  • 1,528
  • 21
  • 33
1

This same problem happened to me. I had made some successful API requests and reached a stopping point in my App, and I decided to publish to GitHub. Moments later I tried running my App, and my server was crashing when I made my Twilio API requests; and the console was saying I needed to authenticate. It turns out I had not added my .env to the .gitIgnore and I unknowingly published my accountSid to GitHub. Twilio sensed this and immediately suspended my accountSid. I am waiting for them to generate a new accountSid for me.

bad_coder
  • 11,289
  • 20
  • 44
  • 72
1

In my case, I just had to repair the values for accountSid and authToken in the authentication code. Those are available at https://console.twilio.com/ at the bottom.

0

Just adding a more recent response. I ran into this issue when I created a new Twilio account to use just for SMS. My account was suspended which was causing the issue.

The email address I used to create the account is not one that I monitor, but they sent me an email asking for details about my intended use and how I plan to allow users to opt in and opt out. Since I had not responded, the account was suspended.

Moondog 2112
  • 81
  • 1
  • 3
0

i also had same problem , after checking the auth token it has been changed in the twilio site

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Sep 21 '22 at 13:27