SUPPORT.TWILIO.COM END OF LIFE NOTICE: This site, support.twilio.com, is scheduled to go End of Life on February 27, 2024. All Twilio Support content has been migrated to help.twilio.com, where you can continue to find helpful Support articles, API docs, and Twilio blog content, and escalate your issues to our Support team. We encourage you to update your bookmarks and begin using the new site today for all your Twilio Support needs.

Error 20003: "Authentication Error Invalid Username" When Using Restricted API Keys

Issue

Customers may receive the following error when making requests to the Twilio Accounts API using an API Key:

{
  "code": 20003,
  "message": "Authentication Error - invalid username",
  "more_info": "https://www.twilio.com/docs/errors/20003",
  "status": 401
}

 

Product

REST API and TwiML

 

Environment

Twilio Console

 

Cause

Twilio API Keys have different permission levels depending on the key type.

Only Main API Keys have access to all Twilio resources, including the Accounts API endpoint. If the API Key was created as a Standard or Restricted key, requests to the Accounts API may fail with error 20003 and return "Authentication Error - invalid username".

Although the credentials are syntactically valid, the key type does not have sufficient permissions for the requested resource.

 

Resolution

Use one of the following authentication methods:

  • Create and use a Main API Key.
  • Authenticate using the Account SID and Auth Token instead of an API Key.

Once authenticated with credentials that have the required permissions, requests to the Accounts API should succeed.

 

Additional Information

  • Standard and Restricted API Keys are intentionally scoped with limited access.
  • This behavior is specific to endpoints that require elevated account-level permissions, such as /Accounts.
  • Error 20003 can indicate either invalid credentials or insufficient permissions depending on the authentication method being used.

Please reach out to Twilio Support for any further assistance.

Have more questions? Submit a request
Powered by Zendesk