Broker API HubMenu

TradeLocker API POST /auth/jwt/token

POST/auth/jwt/tokenAuth

Log in with an email, a password and a server name and receive an access token and a refresh token.

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.

Independent and unofficialpublic-api.tradelocker.comchecked

Read on 12 Oct 2026 on TradeLocker's own reference page for this call, in the Markdown version the documentation site serves at the same address with .md on the end. That page carries the call's OpenAPI definition, headed Trading API version 2.11.0: the method, path, parameters and required marks here are that definition's. The definition lists no security requirement for this call. The documented success status is 201, with accessToken, refreshToken and expireDate all marked required in the reply, and expireDate described as the expiry of the access token. The mock reply uses those field names with invented values.

Parameters

NameInTypeDescription
emailrequiredbodystringThe TradeLocker user's email. Read it from your own environment.
passwordrequiredbodystringThe TradeLocker user's password. Read it from your own environment. Never type it into this site.
serverrequiredbodystringThe name of the broker server, the same one used when logging in to TradeLocker on the web.

Request

Written from the method, path and parameters recorded on this page, against the demo host. Not executed against a live or demo account. Credentials are read from environment variables on your own machine and are never entered on this site. The request builder writes these same snippets, from the same record.

This call takes a request body. The samples send it as JSON with a Content-Type of application/json (in Python, passing json= sets that header) and a placeholder for each of the 3 body fields the record marks as required. Each placeholder has to be replaced with a real value before the request can succeed.

Python
# Set TRADELOCKER_PASSWORD as an environment variable first. Never paste real values into code.
# Replace each {placeholder}, "..." and 0 with a real value before running.
import os
import requests

BASE_URL = "https://demo.tradelocker.com/backend-api"  # the demo host
headers = {}
body = {"email": "...", "password": os.environ["TRADELOCKER_PASSWORD"], "server": "..."}
resp = requests.post(BASE_URL + "/auth/jwt/token", headers=headers, json=body, timeout=10)
resp.raise_for_status()
print(resp.json())
JavaScript
// Set TRADELOCKER_PASSWORD as an environment variable first. Never paste real values into code.
// Replace each {placeholder}, "..." and 0 with a real value before running.
// Run as a module, for example a .mjs file, on a Node version that has fetch built in.
const BASE_URL = "https://demo.tradelocker.com/backend-api"; // the demo host
const res = await fetch(BASE_URL + "/auth/jwt/token", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: JSON.stringify({"email": "...", "password": process.env.TRADELOCKER_PASSWORD, "server": "..."}),
});
if (!res.ok) throw new Error(`HTTP ${res.status}`);
console.log(await res.json());
curl
# Set TRADELOCKER_PASSWORD as an environment variable first. Never paste real values into code.
# Replace each {placeholder}, "..." and 0 with a real value before running.
curl -X POST "https://demo.tradelocker.com/backend-api/auth/jwt/token" \
  -H "Content-Type: application/json" \
  -d "{\"email\": \"...\", \"password\": \"$TRADELOCKER_PASSWORD\", \"server\": \"...\"}"

Response

A mock response. The values are invented, so check field names against the official reference.

{
  "_mock": true,
  "accessToken": "MOCK_ACCESS_TOKEN",
  "refreshToken": "MOCK_REFRESH_TOKEN",
  "expireDate": "2026-01-01T00:00:00.000Z"
}

TradeLocker API errors you may meet

All TradeLocker API error codes.