HTTP status code
HTTP status code: 401 Unauthorized
As text you can copy
401 Unauthorized- Kind
- Status code
What does 401 Unauthorized mean in HTTP?
The request was not applied because it lacks valid authentication credentials for the resource. The standard says the reply must carry a WWW-Authenticate header, and that when credentials were sent, 401 means they were refused.
Risk warning: CFDs and spread bets are complex instruments and come with a high risk of losing money rapidly due to leverage. You can lose money on these products, and each provider publishes its own loss figure under FCA rules. You should consider whether you understand how they work and whether you can afford to take the high risk of losing your money. Automated and API trading can amplify losses through bugs, connectivity failures and runaway orders.
What it means in trading API work
In trading API work this is nearly always a token or key problem: the token has expired, it was sent in the wrong header, or it belongs to the demo environment while the call went to live, or the reverse.
This part is this site's own explanation, written for people learning to call a trading API. It is not part of the source cited above and it describes no particular broker.
What should I do about 401 Unauthorized?
Check which environment the credential belongs to and how the API expects it to be sent. If sessions expire, log in again or refresh the token, then repeat the request. Never paste a credential into a forum post or a chat when asking for help.
This page is an independent explanation in plain words. The definition itself is in the source it was read from, which is the authority if the two ever differ.