API REFERENCE

Users & Accounts

Authentication & Users

Create API Key

POST /api-keys (admin only)

1{
2  "name": "My Demo Platform Key",
3  "ip_whitelist": ["10.0.0.0/24", "1.2.3.4"],
4  "permissions": ["READ", "TRADE", "CHALLENGE_ADMIN"]
5}

Response:

1{
2  "success": true,
3  "data": {
4    "api_key": "TLK_9d2f0f...",
5    "api_secret": "TLSEC_8293af...",
6    "name": "My Demo Platform Key",
7    "created_at": 1700483073000
8  }
9}

Link External User (SSO)

POST /users

Most challenge/demo platforms already have their own users. TradeLayer supports linking them by external_user_id.

1{
2  "external_user_id": "user_12345",
3  "email": "user@example.com",
4  "display_name": "ProTrader01",
5  "country": "DE",
6  "metadata": {
7    "plan": "Pro",
8    "segment": "challenge_user"
9  }
10}

Response:

1{
2  "success": true,
3  "data": {
4    "user_id": "tl_user_9e8127",
5    "external_user_id": "user_12345",
6    "status": "ACTIVE",
7    "created_at": 1700483073000
8  }
9}

Get User by External ID

GET /users/by-external-id/{external_user_id}

Accounts, Margin & Balances

Get Account Summary

GET /account?user_id=tl_user_9e8127

1{
2  "success": true,
3  "data": {
4    "user_id": "tl_user_9e8127",
5    "equity": "12500.50",
6    "wallet_balance": "10000.00",
7    "unrealized_pnl": "2500.50",
8    "margin_used": "3000.00",
9    "available_margin": "9500.50",
10    "margin_mode": "CROSS",
11    "currency": "USDT"
12  }
13}

Get Transaction History

GET /transactions?user_id=tl_user_9e8127&page=1&page_size=50

1{
2  "success": true,
3  "data": [
4    {
5      "tx_id": "acc_92381",
6      "type": "DEPOSIT",
7      "amount": "10000.00",
8      "currency": "USDT",
9      "balance_after": "10000.00",
10      "timestamp": 1700300000000,
11      "reference": "Demo challenge top-up"
12    }
13  ],
14  "pagination": { ... }
15}