# Trading 212 API error: HTTP 401

Independent and unofficial. Not affiliated with or endorsed by any broker or platform named here. Educational only: nothing here is advice, and nothing here recommends a broker or a trade.

This is the markdown version of https://openbrokerapi.com/errors/trading-212/401-invalid-api-key, written from the same records as that page.

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.

The error, as text you can copy:

```
HTTP 401
```

- Kind: API error code
- HTTP status: 401
- API: [Trading 212](https://openbrokerapi.com/brokers/trading-212)
- Status: verified. Source: [docs.trading212.com](https://docs.trading212.com/api/accounts/getaccountsummary), checked 2026-09-21.

## What does HTTP 401 mean on the Trading 212 API?

Trading 212 did not accept the credentials on the request. The endpoint reference lists 401 as a response but gives it no description. On the community forum it came back when only the API key was sent without the secret, when the Base64 string had a line break in it, and when a key was sent to a host other than the one for the account it was made on.

## How do I fix HTTP 401?

Send the header Authorization: Basic followed by base64(API_KEY:API_SECRET) with no line breaks, and use the key pair made for the account you are calling. The help centre says key versions may differ between real and demo accounts.

## More on the Trading 212 API

- [All Trading 212 API error codes](https://openbrokerapi.com/errors/trading-212)
- [Trading 212 API quickstart](https://openbrokerapi.com/brokers/trading-212/quickstart): From credentials to a first call on a demo account, step by step.
- [Trading 212 API error codes](https://openbrokerapi.com/errors/trading-212): 8 decoded, each with what it means, and the fix where the source gives one.
- [Trading 212 API endpoints](https://openbrokerapi.com/brokers/trading-212/endpoints): 16 documented, each with its method, path, parameters and source.
- [Trading 212 API page](https://openbrokerapi.com/brokers/trading-212): The full record: access, authentication, limits and the source for each.
- [Export Trading 212 trade history to Excel or a spreadsheet](https://openbrokerapi.com/guides/trading-212-trade-history): Guide

## Licence and how to cite

The records behind this page are all rights reserved. This file is the page itself, at its own address, in another format. It is not part of the CC BY 4.0 downloads listed at https://openbrokerapi.com/data. Quote from it with a link to the page.

Cite as: Trading 212 API error: HTTP 401. Broker API Hub, https://openbrokerapi.com/errors/trading-212/401-invalid-api-key, newest check 2026-09-21.

Where you rely on a single figure, cite the source and the checked date printed beside it as well. Where this page and a broker's own documentation differ, the documentation wins.
