Transaction
Subscribe to real-time transaction notifications for user account activity including buys, sells, deposits, withdrawals, and other financial transactions.
7 breaking changes - code updates required
Critical Changes:
Several contract-related fields have been removed, symbol field renamed, and action enum validation removed in New.
Quick comparison
| Aspect | Legacy | New | Action required |
|---|---|---|---|
Endpoint ✅ Same | transaction | transaction | None |
Auth Required ✅ Same | Yes | Yes | None |
Subscribe Parameter ⚠️ Changed | Must be 1 | Can be 0 or 1 | Update logic |
Symbol Field ⚠️ Changed | symbol | underlying_symbol | Update field references |
action validation ⚠️ Changed | Enum | Any string | Update validation logic |
Barrier Fields ❌ Removed | Supported | Removed | Remove field usage |
Stop Loss/Take Profit ❌ Removed | Supported | Removed | Remove field usage |
Breaking changes
1. Subscribe parameter value change
What Changed: Legacy only accepts subscribe: 1, while New accepts both 0 and 1. Setting it to 0 in New will not return any records.
2. LoginID parameter removed
What Changed: The optional loginid parameter has been removed in New. This parameter was used to specify which account's transactions to monitor.
3. Contract barrier fields removed
What Changed: Response fields barrier,high_barrier, and low_barrier have been removed from New. These provided barrier information for contracts.
4. Display name field removed
What Changed: The display_name field (symbol's display name) has been removed from the response in New.
5. Stop loss/take profit fields removed
What Changed: Response fields stop_loss,stop_out, and take_profit have been removed from New. These provided automated contract closure targets.
6. Symbol field renamed
What Changed: The symbol field has been replaced with underlying_symbol in New.
7. action enum validation removed
What Changed: The action field in the response no longer validates against a fixed enum. Legacy accepted: buy, sell, deposit, withdrawal, escrow, adjustment, virtual_credit, transfer. New accepts any string value.
Migration: Update any type-safe validation logic that depends on specific action enum values.
Request structure
Legacy Request Example
1{
2 "transaction": 1,
3 "subscribe": 1, // ⚠️ Must be 1 in Legacy
4 "loginid": "CR90000001", // ❌ Removed in New
5 "passthrough": {},
6 "req_id": 123
7}New Request Example
1{
2 "transaction": 1,
3 "subscribe": 1, // 🆕 Can be 0 or 1 in New
4 "passthrough": {},
5 "req_id": 123
6}Response structure
Legacy Response Example
1{
2 "transaction": {
3 "id": "c84a793b-8a87-7999-ce10-9b22f7ceead3",
4 "action": "buy", // Enum validated
5 "amount": -83.23,
6 "balance": 10000.00,
7 "contract_id": 4867502908,
8 "currency": "USD",
9 "date_expiry": 1699564800,
10 "longcode": "Win payout if...",
11 "symbol": "R_100", // ❌ Removed
12 "display_name": "Volatility 100 Index", // ❌ Removed
13 "barrier": "100.50", // ❌ Removed
14 "high_barrier": "105.00", // ❌ Removed
15 "low_barrier": "95.00", // ❌ Removed
16 "stop_loss": "95.00", // ❌ Removed
17 "stop_out": "90.00", // ❌ Removed
18 "take_profit": "105.00", // ❌ Removed
19 "transaction_id": 10867502908,
20 "transaction_time": 1699564500
21 },
22 "subscription": {
23 "id": "c84a793b-8a87-7999-ce10-9b22f7ceead3"
24 },
25 "msg_type": "transaction"
26}New Response Example
1{
2 "transaction": {
3 "id": "c84a793b-8a87-7999-ce10-9b22f7ceead3",
4 "action": "buy", // Any string (no enum)
5 "amount": -83.23,
6 "balance": 10000.00,
7 "contract_id": 4867502908,
8 "currency": "USD",
9 "date_expiry": 1699564800,
10 "longcode": "Win payout if...",
11 "underlying_symbol": "R_100", // 🆕 Renamed
12 "transaction_id": 10867502908,
13 "transaction_time": 1699564500,
14 "purchase_time": 1699564500
15 },
16 "subscription": {
17 "id": "c84a793b-8a87-7999-ce10-9b22f7ceead3"
18 },
19 "msg_type": "transaction"
20}Note: Fields removed in v4: symbol, display_name, barrier, high_barrier, low_barrier, stop_loss, stop_out, take_profit. The action field no longer validates against an enum.
Code examples
Legacy Implementation
1async function subscribeToTransactions() {
2 const request = {
3 transaction: 1,
4 subscribe: 1,
5 loginid: "CR90000001", // Optional: specify account
6 req_id: 123
7 };
8
9 ws.send(JSON.stringify(request));
10
11 // Handle response
12 ws.onmessage = (msg) => {
13 const response = JSON.parse(msg.data);
14
15 if (response.msg_type === 'transaction') {
16 const txn = response.transaction;
17
18 console.log('Transaction Type:', txn.action);
19 console.log('Amount:', txn.amount);
20 console.log('Balance:', txn.balance);
21 console.log('Symbol:', txn.symbol); // Available in Legacy
22 console.log('Display Name:', txn.display_name); // Available in Legacy
23
24 // Check barrier info if available
25 if (txn.barrier) {
26 console.log('Barrier:', txn.barrier);
27 }
28
29 // Check stop loss/take profit if available
30 if (txn.stop_loss) {
31 console.log('Stop Loss:', txn.stop_loss);
32 }
33 if (txn.take_profit) {
34 console.log('Take Profit:', txn.take_profit);
35 }
36 }
37 };
38}New Implementation
1async function subscribeToTransactions() {
2 const request = {
3 transaction: 1,
4 subscribe: 1, // Can be 0 or 1 in New
5 req_id: 123
6 };
7
8 ws.send(JSON.stringify(request));
9
10 // Handle response
11 ws.onmessage = (msg) => {
12 const response = JSON.parse(msg.data);
13
14 if (response.msg_type === 'transaction') {
15 const txn = response.transaction;
16
17 console.log('Transaction Type:', txn.action);
18 console.log('Amount:', txn.amount);
19 console.log('Balance:', txn.balance);
20 console.log('Symbol:', txn.underlying_symbol); // Renamed in New
21
22 // Note: display_name, barrier info, and stop_loss/take_profit
23 // are no longer available in New responses
24 }
25 };
26}