CopySync API / Trade Academy · reference

Introduction

This API gives Trade Academy read-only access to your users' MetaTrader 4 and MetaTrader 5 accounts. You add an account with its login, password and server. We connect it, keep it connected around the clock, and from then on report every change on it: positions opened, modified, partially closed and closed, balance and equity. Your users install nothing.

Changes reach you as webhooks, sent as soon as we receive them. The endpoints give you the current state at any time, for every account in a single call if you want it, so you can rebuild your view whenever you need to.

How it works

Base URL and versioning

Base URL
https://tradeacademy.copysync.net/api/v2/

HTTPS only, TLS 1.2 or newer. Plain HTTP requests are redirected, and you should not rely on the redirect.

Within v2 we only make additive changes: new endpoints, new response fields, new event types and new values in enumerations. Nothing you rely on is renamed or removed. Build your client to ignore fields and values it does not know.

Authentication

Every request carries your platform key in the X-API-Key header. There are no cookies, sessions or OAuth flows.

Authenticated request
curl "https://tradeacademy.copysync.net/api/v2/accounts" \
  -H "X-API-Key: cs_org_7f3a…"

Rate limits

Limits apply per key, per one-minute window. They are part of our agreement with you and are raised as your account count grows.

ClassLimitApplies to
read600 / minAll GET requests
write120 / minPATCH, PUT and every POST except creating an account
provisioning60 / minPOST /accounts and every DELETE

Every response carries the current state of your budget:

Response headers
RateLimit-Limit: 600
RateLimit-Remaining: 583
RateLimit-Reset: 41          # seconds until the window refills
Retry-After: 41              # on 429 only

On 429 the request was not processed; wait for Retry-After and send it again. Webhooks do not count against your limits, and neither does anything we send you.

Conventions

Response envelope

A single object is returned as it is. A collection comes under data with pagination fields next to it, never as a bare array.

Single
{
  "id": 5120,
  "reference": "acc_20931"
}
Collection
{
  "data": [ … ],
  "has_more": true,
  "next_cursor": "eyJpZCI6NTEyMH0"
}

Idempotency

GET, PUT, PATCH and DELETE can be repeated safely. POST cannot, so every POST accepts an Idempotency-Key header: any unique string up to 255 characters, typically a UUID or your own account id.

Safe retry
curl -X POST "https://tradeacademy.copysync.net/api/v2/accounts" \
  -H "X-API-Key: $CS_KEY" \
  -H "Idempotency-Key: acc_20931" \
  -H "Content-Type: application/json" \
  -d @account.json

We keep the result of the first request under that key for 24 hours. A repeat with the same key returns the original response with Idempotent-Replay: true, without acting again. The same key with a different body is refused with 409 idempotency_key_reused.

Errors are kept like successes, except 5xx: after a 500 the key is free again, so the retry really runs. A repeat that arrives while the first request is still running gets 409 idempotency_key_in_progress; retry it a few seconds later.

Pagination

List endpoints are cursor-paginated. Pass limit (1–500, default 100) and, for every page after the first, the next_cursor of the previous one. When has_more is false you are done.

Walking a full trade history
cursor = null
loop:
    url = "/api/v2/accounts/5120/trades?limit=500"
    if cursor: url += "&cursor=" + cursor
    page = GET(url)
    process(page.data)
    if not page.has_more: break
    cursor = page.next_cursor

Cursors are opaque; do not parse or store them. Unlike offsets, they stay correct while new trades are being written.

The account object

One object is one MetaTrader account. It holds your identifiers, what the broker reports about the account, its live figures and its connection status.

A connected MT5 account
{
  "id": 5120,
  "reference": "acc_20931",
  "user_ref": "user_8812",
  "name": "Challenge 100k",

  "platform": "MT5",
  "broker": "Example Markets Ltd",
  "broker_server": "ExampleMarkets-Live",
  "login": "51203399",
  "account_type": "real",
  "currency": "USD",
  "leverage": 100,
  "trade_allowed": false,
  "broker_utc_offset": 7200,

  "balance": 100000.00,
  "equity": 101245.30,
  "credit": 0.00,
  "margin": 1530.00,
  "free_margin": 99715.30,
  "margin_level": 6617.34,
  "floating_pl": 1245.30,
  "open_positions": 2,
  "last_data_at": "2026-11-26T08:14:22Z",

  "status": {
    "state": "connected",
    "reason": null,
    "message": null,
    "since": "2026-11-20T09:02:11Z"
  },
  "history": {
    "mode": "full",
    "state": "complete"
  },

  "created_at": "2026-11-20T08:58:40Z",
  "updated_at": "2026-11-26T08:14:22Z"
}

Field reference

FieldTypeDescription
idintegerOur identifier. Stable, never reused.
referencestring · nullYour identifier for this account, up to 128 characters, returned untouched.
user_refstring · nullYour identifier for the user who owns the account, up to 128 characters. Filter on it to get one user's accounts.
namestringDisplay name, 1–100 characters. Defaults to platform and login.
platformenumMT4 or MT5.
brokerstring · nullBroker company name as MetaTrader reports it. Filled on first connect.
broker_serverstringThe broker's server name, exactly as entered at creation.
loginstringThe account number. The password is never returned.
account_typeenum · nullreal, demo or contest.
currencystring · nullDeposit currency, ISO 4217. All money on this account is in it.
leverageinteger · nulle.g. 100 for 1:100.
trade_allowedboolean · nullWhether the broker would accept trades on this login. false on an investor password, and on an account on which the broker has switched trading off. Such an account stays connected and keeps reporting.
broker_utc_offsetinteger · nullBroker server time minus UTC, in seconds. Changes with the broker's daylight saving time.
balancenumber · nullBalance from closed trades and balance operations.
equitynumber · nullBalance plus floating profit and loss.
creditnumber · nullBroker credit or bonus, if any.
marginnumber · nullMargin in use.
free_marginnumber · nullMargin available for new positions.
margin_levelnumber · nullEquity ÷ margin, in percent. null with no open position.
floating_plnumber · nullUnrealised profit and loss across open positions.
open_positionsintegerNumber of open positions.
last_data_attimestamp · nullWhen we last received figures for this account. Show it next to the numbers when the account is not connected.
statusobjectConnection state and reason. See Account status.
historyobjectmode is full or from_activation, chosen at creation. state is importing while a full history is being loaded, then complete.
created_attimestampWhen the account was created.
updated_attimestampLast change to any field, live figures included. Not useful for change detection; use webhooks.

Account status

status.state says whether data is flowing for an account. Drive your interface from it, and treat any value you do not know as “not connected”.

StateMeaning
pendingAccepted and queued. Normally a few seconds.
connectingLogging in at the broker and loading the account. Typically one to three minutes for a new account.
connectedLive. Positions, balance and equity are current.
disconnectedNo data for at least three minutes. We keep reconnecting by ourselves; reason says why it is down. Returns to connected without action from you.
errorCannot connect until you or your user change something. reason says what.
deletingDeletion accepted and in progress.
Normal path
pending → connecting → connected ⇄ disconnected
                ↓
              error  → PUT …/credentials → connecting

any state → deleting → gone
A disconnect is confirmed before we report it

Brokers drop connections for a few seconds all the time, especially around their daily maintenance. An account only moves to disconnected after three minutes without data. Shorter interruptions produce no state change and no webhook, so you can alert your users on disconnected directly, without filtering of your own.

Reasons

status.reason is a stable code; status.message is readable text whose wording may change. Branch on the code.

ReasonStateMeaning and next step
invalid_passworderrorThe broker rejected the password, or stopped accepting a login that worked before, typically because the password was changed. Ask your user for the correct one and send it with PUT …/credentials.
invalid_loginerrorThe account number does not exist on this broker server.
server_not_founderrorbroker_server is not known. Server names are case-sensitive; check the exact spelling in your user's MetaTrader.
account_disablederrorThe broker has disabled, archived or closed the account, so it can no longer log in. Only the broker can undo it. An account on which the broker has only switched trading off, as often happens after a failed or expired challenge, is not an error: it stays connected and keeps reporting, with trade_allowed: false.
broker_unreachabledisconnectedThe broker's servers are not answering, e.g. during maintenance. Resolves by itself.
connection_lostdisconnectedThe link between the account and us is interrupted. We reconnect automatically; nothing is needed from you.
setup_failederrorOn our side. We are alerted automatically and take care of it; nothing is needed from you.

A wrong password, login or server is not checked when you create the account: the broker tells us when we log in. Expect it as an account.status_changed event to error, typically within one to three minutes of creation.

There is no separate reason for the wrong platform. Each platform has its own servers and accounts, so an MT4 account created as MT5, or the reverse, ends in server_not_found or invalid_login. If your user is not sure, ask which MetaTrader they log in with; to fix it, delete the account and create it again with the right platform.

Account endpoints

GET /accounts
All your accounts with their live figures, newest first. This is the bulk call for balances, equity and status: one request returns up to 500 accounts.
Query parameterTypeDescription
user_refstringOnly this user's accounts.
referencestringExact match on your account identifier.
stateenumFilter on status.state, e.g. error for everything that needs attention.
platformenumMT4 or MT5.
fieldsstringComma-separated list of fields to return.
limitinteger1–500, default 100.
cursorstringFrom the previous page.
Request
curl "https://tradeacademy.copysync.net/api/v2/accounts?user_ref=user_8812&fields=id,reference,equity,status" \
  -H "X-API-Key: $CS_KEY"
200 OK
{
  "data": [{
    "id": 5120,
    "reference": "acc_20931",
    "equity": 101245.30,
    "status": {
      "state": "connected",
      "reason": null,
      "message": null,
      "since": "2026-11-20T09:02:11Z"
    }
  }],
  "has_more": false,
  "next_cursor": null
}
GET /accounts/{id}
One account, with every field of the account object. Returns 404 if the id does not exist or is not yours.
POST /accounts
Adds an account and starts connecting it. Send an Idempotency-Key.
Body fieldTypeDescription
platformenum, requiredMT4 or MT5.
broker_serverstring, requiredThe server name exactly as shown in your user's MetaTrader login window, e.g. ExampleMarkets-Live. Case-sensitive.
loginstring, requiredThe account number, 3 to 20 digits. A JSON number is accepted too and stored as a string.
passwordstring, requiredInvestor or master password, 4 to 200 characters. Write-only; no endpoint ever returns it.
referencestringYour identifier for this account, up to 128 characters.
user_refstringYour identifier for the user, up to 128 characters.
namestringDisplay name, 1 to 100 characters. Defaults to platform and login.
historyenumfrom_activation (default): trades start from the moment the account connects. full: the account's existing broker history is imported as well.
Request
POST /api/v2/accounts
X-API-Key: $CS_KEY
Idempotency-Key: acc_20931
Content-Type: application/json

{
  "platform": "MT5",
  "broker_server": "ExampleMarkets-Live",
  "login": "51203399",
  "password": "…",
  "reference": "acc_20931",
  "user_ref": "user_8812",
  "name": "Challenge 100k",
  "history": "full"
}
201 Created — the full account object
{
  "id": 5120,
  "reference": "acc_20931",
  "user_ref": "user_8812",
  "name": "Challenge 100k",
  "platform": "MT5",
  "broker": null,
  "broker_server": "ExampleMarkets-Live",
  "login": "51203399",
  "account_type": null,
  "currency": null,
  "leverage": null,
  "trade_allowed": null,
  "broker_utc_offset": null,
  "balance": null,
  "equity": null,
  "credit": null,
  "margin": null,
  "free_margin": null,
  "margin_level": null,
  "floating_pl": null,
  "open_positions": 0,
  "last_data_at": null,
  "status": {
    "state": "pending",
    "reason": null,
    "message": null,
    "since": "2026-11-26T08:58:40Z"
  },
  "history": {
    "mode": "full",
    "state": "importing"
  },
  "created_at": "2026-11-26T08:58:40Z",
  "updated_at": "2026-11-26T08:58:40Z"
}

201 means the account exists and is being connected, not that the login worked. Broker fields stay null until the first connect. Wait for account.status_changed to connected before you show the account as live.

The same login on the same server can exist only once under your key; a second create returns 409 duplicate_account with the id of the existing account. The same login number on a different broker server is a different account and is accepted.

A reference can likewise be on only one of your accounts (409 duplicate_reference). An account that is being deleted no longer counts for either rule, so delete and create again works straight away, with the same login, server and reference.

Your key holds up to an agreed number of accounts (10 during the test phase); beyond it, a create returns 403 account_limit_reached. Fields we do not know are refused with 422, so a misspelt field name does not pass unnoticed.

Full history on large accounts

With history: "full" the import runs after the account has connected. Live events start straight away; the imported trades follow. On accounts with tens of thousands of deals the import can take a while. account.history_imported fires when it is complete.

PATCH /accounts/{id}
Changes your own data on an account. Send only what changes.

Updatable: name, reference, user_ref. Not updatable: platform and history, which are fixed at creation. Login, password and server go through their own endpoint.

Answers 200 with the updated account. Send null to clear reference or user_ref, or to set name back to its default. None of these touch the connection.

Request
PATCH /api/v2/accounts/5120
Content-Type: application/json

{ "name": "Challenge 100k — Phase 2" }
PUT /accounts/{id}/credentials
Replaces login, password and server and reconnects the account with them. This is how you fix invalid_password, invalid_login and server_not_found, and what you call when your user changes their password at the broker.
Request
PUT /api/v2/accounts/5120/credentials
Content-Type: application/json

{
  "login": "51203399",
  "password": "…",
  "broker_server": "ExampleMarkets-Live"
}

All three fields are required, even if only the password changed. Answers 200 with the account. It goes back to pending, then connecting, and you receive the outcome as account.status_changed. Trade history already collected is kept.

If the login changes, it is a different broker account. Positions of the old login are then not reported as closed, the open positions of the new one arrive as position.opened, and its first balance is taken as the starting point without an account.balance_changed.

While a setup is running (connecting after a create or an earlier change), new credentials are refused with 409 invalid_state; send them again a minute later.

Passwords are stored encrypted (AES-256-GCM) and used only to log in. No endpoint returns them, and our support cannot read them.

DELETE /accounts/{id}
Disconnects the account and permanently removes it, with its trade history and figures.

Answers 202 Accepted. The account shows deleting for a short time, then disappears, and account.deleted fires. Deletion does nothing at the broker: the account and its positions stay exactly as they are; we simply stop reading it. If you need its data, read it before you delete.

202 Accepted
{ "id": 5120, "status": { "state": "deleting", "reason": null } }

Repeating the request while the deletion runs returns the same 202; once the account is gone, 404.

Trading data

GET /accounts/{id}/positions
Positions currently open on one account, from the live feed.
200 OK
{
  "account_id": 5120,
  "reference": "acc_20931",
  "currency": "USD",
  "broker_utc_offset": 7200,
  "as_of": "2026-11-26T08:14:22Z",
  "data": [{
    "ticket": 88213344,
    "symbol": "EURUSD",
    "type": "buy",
    "volume": 0.50,
    "open_time": "2026-11-26T06:31:02Z",
    "open_price": 1.08442,
    "current_price": 1.08661,
    "sl": 1.08100,
    "tp": 1.09200,
    "profit": 109.50,
    "commission": -3.50,
    "swap": -1.20
  }]
}
FieldTypeDescription
ticketintegerThe broker's position number. A partial close keeps it: on MT5 the broker does, and on MT4, where the remaining volume gets a new ticket at the broker, we keep reporting the original one. A position therefore has one ticket for its whole life, the same as its trade in /trades. One exception on MT4: if the account restarts between a partial close and the final close, the remaining part continues under its new ticket.
typeenumbuy or sell.
volumenumberOpen volume in lots, after any partial closes.
open_timetimestamp · nullWhen the position was opened, in UTC. null in the rare case it cannot be determined.
current_pricenumber · nullThe price the position is valued at right now.
slnumber · nullStop loss. null when none is set.
tpnumber · nullTake profit. null when none is set.
profitnumberFloating profit, excluding commission and swap.
commissionnumber · nullCommission charged so far. Some brokers charge it only on closing; then it is 0 until the position closes.
swapnumber · nullAccumulated swap.

as_of is when we last received data. On an account that is not connected it can be old; show it rather than presenting the figures as current. commission can be null for a short time after a position opens; here as everywhere, null means “not known yet”, not zero.

GET /positions
Open positions of all your accounts in one call, grouped by account. Use it to rebuild your state after a restart, or on a schedule to reconcile.
Query parameterTypeDescription
user_refstringOnly this user's accounts.
stateenumOnly accounts in this state.
limitintegerAccounts per page, 1–500, default 100.
cursorstringFrom the previous page.
200 OK
{
  "data": [
    {
      "account_id": 5120,
      "reference": "acc_20931",
      "user_ref": "user_8812",
      "state": "connected",
      "as_of": "2026-11-26T08:14:22Z",
      "positions": [ /* as in GET /accounts/{id}/positions */ ]
    },
    {
      "account_id": 5121,
      "reference": "acc_20932",
      "user_ref": "user_8812",
      "state": "connected",
      "as_of": "2026-11-26T08:14:21Z",
      "positions": []
    }
  ],
  "has_more": false,
  "next_cursor": null
}

Every account is listed, including those without open positions, so an empty positions array reliably means “nothing open”.

GET /accounts/{id}/trades
Closed trades, newest close first, cursor-paginated.
Query parameterTypeDescription
fromYYYY-MM-DDClosed on or after this day, UTC.
toYYYY-MM-DDClosed on or before this day, UTC.
symbolstringExact symbol.
limitinteger1–500, default 100.
cursorstringFrom the previous page.
200 OK — a trade closed in two steps
{
  "data": [{
    "ticket": 88213344,
    "symbol": "EURUSD",
    "type": "buy",
    "volume": 1.00,
    "open_time": "2026-11-26T06:31:02Z",
    "open_price": 1.08442,
    "close_time": "2026-11-26T09:02:44Z",
    "close_price": 1.08661,
    "sl": 1.08100,
    "tp": 1.09200,
    "profit": 203.50,
    "commission": -7.00,
    "swap": 0.00,
    "net_profit": 196.50,
    "closes": [
      { "volume": 0.50, "price": 1.08626, "profit": 92.00,  "time": "2026-11-26T08:10:05Z" },
      { "volume": 0.50, "price": 1.08665, "profit": 111.50, "time": "2026-11-26T09:02:44Z" }
    ],
    "source": "live"
  }],
  "has_more": true,
  "next_cursor": "eyJ0IjoiODgyMTMzNDQifQ"
}
FieldTypeDescription
volumenumberVolume at opening, in lots.
close_timetimestampWhen the last part was closed.
close_pricenumberVolume-weighted average of all close prices.
sl, tpnumber · nullStop loss and take profit at the time of closing.
profitnumberGross result, excluding commission and swap.
net_profitnumberprofit + commission + swap. Use it for performance figures.
closesarrayEach closing step. One entry for a trade closed at once, several after partial closes. On MT4 the steps are joined across the tickets a partial close creates, so one trade here is one trade as your user thinks of it.
sourceenumlive if we saw it happen, import if it came from a full-history import.
GET /accounts/{id}/equity-history
Snapshots of balance and equity over time, for an equity curve.
Request
GET /api/v2/accounts/5120/equity-history
    ?days=90&interval=hour
200 OK
{
  "account_id": 5120,
  "currency": "USD",
  "interval": "hour",
  "data": [{
    "at": "2026-11-26T08:00:00Z",
    "balance": 100000.00,
    "equity": 101102.70,
    "equity_low": 99640.10,
    "equity_high": 101390.00,
    "floating_pl": 1102.70
  }]
}

days is 1–365, default 30. interval is hour (default) or day. equity_low and equity_high are the lowest and highest equity within the interval. Use equity_low for drawdown rules; the value at the full hour misses a dip in between.

GET /accounts/{id}/balance-operations
Deposits, withdrawals and other balance changes that are not trades, newest first, cursor-paginated (limit, cursor).
200 OK
{
  "data": [
    { "id": 5613, "type": "withdrawal", "amount": -750.00,    "time": "2026-11-24T14:05:11Z" },
    { "id": 5512, "type": "deposit",    "amount": 100000.00, "time": "2026-11-20T09:05:00Z" }
  ],
  "has_more": false,
  "next_cursor": null
}

type is deposit or withdrawal; build your client to accept further values. Withdrawals are negative. Subtract these from balance changes before you compute a return; otherwise a deposit shows up as profit.

Webhooks

Register an HTTPS endpoint and we send you every change as it happens: no polling. Each event has a unique id, failed deliveries are retried, and missed events can be replayed.

Registering

POST /webhooks
{
  "url": "https://api.tradeacademy.example/hooks/copysync",
  "events": ["*"],
  "equity_interval": 5
}
201 Created
{
  "id": 7,
  "url": "https://api.tradeacademy.example/hooks/copysync",
  "secret": "whsec_9f2c4a…",
  "events": ["*"],
  "equity_interval": 5,
  "active": true,
  "failing_since": null,
  "disabled_at": null,
  "created_at": "2026-11-26T08:50:12Z"
}

url is required. events lists the types you want; ["*"] means all, including types added later, and is the default. equity_interval is how often, in seconds, account.equity_updated is sent: 5 to 60, default 5.

failing_since is set while deliveries to the endpoint keep failing and cleared by the next success; disabled_at is set when we switch it off (see Auto-disable). Watch both if you monitor your integration.

The secret is returned once; store it before you close the response. GET /webhooks lists your endpoints under data, without the secret, PATCH /webhooks/{id} changes url, events, equity_interval or active, and DELETE /webhooks/{id} removes one (204). Up to five endpoints per key; a sixth is refused with 409 webhook_limit_reached.

The url must be https and reach a public address. Local, private and reserved addresses are refused, both when you register and on every delivery, and redirects are not followed.

Events

EventFires when
account.createdAn account was created and is being connected. Carries the account object under account.
account.status_changedstatus.state changed. Carries from, to, reason and message. This covers connected, confirmed disconnects, errors such as a wrong password, and reconnects. It also fires when an account stays in error but the reason changes. The first one for a new account always has from: "pending", even if the account was already further along when we first looked.
account.history_importedA full-history import finished. Carries imported_trades.
account.deletedDeletion is complete. Carries account_id, reference and user_ref.
position.openedA position was opened, by any means: by hand, by an Expert Advisor, or a pending order that filled. Positions already open when an account connects are announced this way too, with their original open_time.
position.modifiedStop loss or take profit changed, or volume was added (netting accounts). Carries sl, tp, volume, their previous_ values, and the position.
position.partially_closedPart of a position was closed. Carries the closed volume, price and profit, and the volume left open. The position keeps its ticket on both platforms: on MT4 the broker gives the remainder a new ticket, and we keep reporting the original one. If the close details do not reach us within a minute, the event carries the volumes and null for price, profit, commission and swap; the final position.closed has the complete trade.
position.closedA position was closed completely, by hand, by SL, TP or stop out. Carries the full trade as in Trade history. In the rare case that the close details do not reach us within ten minutes, the event carries what we know and null for the rest.
account.balance_changedThe balance changed. Carries balance, previous_balance, change, currency and cause: trade, deposit, withdrawal or correction (anything else the broker booked). Accept further values. When the cause is not known straight away, the event waits for it up to two minutes.
account.equity_updatedSent every equity_interval seconds, carrying all accounts whose balance, equity, margin or floating profit changed since the last one. One request, many accounts: up to 1,000 per request, more are split across several. An account appears once it has sent its first figures.

Payloads

Every event has the same envelope. id identifies the event and stays the same on every retry and replay. occurred_at is when the change happened on the account, as far as we can tell from the broker's data.

position.opened
{
  "id": "evt_01JDQ8M4K7Z2X9R3B6V0N5H8TC",
  "type": "position.opened",
  "occurred_at": "2026-11-26T06:31:02Z",
  "data": {
    "account_id": 5120,
    "reference": "acc_20931",
    "user_ref": "user_8812",
    "broker_utc_offset": 7200,
    "position": {
      "ticket": 88213344,
      "symbol": "EURUSD",
      "type": "buy",
      "volume": 1.00,
      "open_time": "2026-11-26T06:31:02Z",
      "open_price": 1.08442,
      "current_price": 1.08442,
      "sl": 1.08100,
      "tp": 1.09200,
      "profit": 0.00,
      "commission": -3.50,
      "swap": 0.00
    }
  }
}
position.partially_closed
{
  "id": "evt_01JDQCV2…",
  "type": "position.partially_closed",
  "occurred_at": "2026-11-26T08:10:05Z",
  "data": {
    "account_id": 5120,
    "reference": "acc_20931",
    "user_ref": "user_8812",
    "broker_utc_offset": 7200,
    "ticket": 88213344,
    "symbol": "EURUSD",
    "closed_volume": 0.50,
    "remaining_volume": 0.50,
    "close_price": 1.08626,
    "profit": 92.00,
    "commission": -3.50,
    "swap": 0.00
  }
}
account.status_changed
{
  "id": "evt_01JDQ9A7…",
  "type": "account.status_changed",
  "occurred_at": "2026-11-26T09:00:41Z",
  "data": {
    "account_id": 5122,
    "reference": "acc_20933",
    "user_ref": "user_9054",
    "from": "connecting",
    "to": "error",
    "reason": "invalid_password",
    "message": "The broker rejected the password."
  }
}
account.equity_updated — one delivery, many accounts
{
  "id": "evt_01JDQD0B…",
  "type": "account.equity_updated",
  "occurred_at": "2026-11-26T08:14:25Z",
  "data": {
    "accounts": [
      { "account_id": 5120, "reference": "acc_20931", "balance": 100000.00, "equity": 101245.30,
        "margin": 1530.00, "free_margin": 99715.30, "floating_pl": 1245.30,
        "equity_low": 101190.10, "at": "2026-11-26T08:14:24Z" },
      { "account_id": 5131, "reference": "acc_21007", "balance": 25000.00,  "equity": 24712.85,
        "margin": 880.00,  "free_margin": 23832.85, "floating_pl": -287.15,
        "equity_low": 24655.40,  "at": "2026-11-26T08:14:25Z" }
    ]
  }
}

equity_low is the lowest equity since the previous delivery for that account, so a short dip between two deliveries is not lost. Equity is sampled four times a second on every account.

Equity updates are not retried: an old figure delivered late helps nobody, and the next delivery carries the current ones. Accounts that did not reach you are included again in the next delivery.

Delivery and verification

What arrives at your endpoint
POST /hooks/copysync HTTP/1.1
Content-Type: application/json
User-Agent: CopySync-Webhooks/1
X-CopySync-Event: position.opened
X-CopySync-Event-Id: evt_01JDQ8M4K7Z2X9R3B6V0N5H8TC
X-CopySync-Delivery: 9f2c4a10-3e77-4a1b-b0d2-5c8e1f7a9b40
X-CopySync-Timestamp: 1795681862
X-CopySync-Signature: sha256=4f8c2e…

{ …event as above… }

X-CopySync-Signature is sha256= followed by the hex HMAC-SHA256 of timestamp + "." + raw_body, keyed with your webhook secret. X-CopySync-Event-Id equals the event's id and is the same on every attempt; X-CopySync-Delivery is new on every attempt.

Verifying — Node.js
const crypto = require('crypto');

app.post('/hooks/copysync',
  express.raw({ type: 'application/json' }),   // raw, not json()
  (req, res) => {
    const ts  = req.get('X-CopySync-Timestamp');
    const sig = req.get('X-CopySync-Signature') || '';

    // Reject anything older than five minutes — stops replayed requests.
    if (Math.abs(Date.now() / 1000 - Number(ts)) > 300) {
      return res.sendStatus(400);
    }

    const expected = 'sha256=' + crypto
      .createHmac('sha256', process.env.CS_WEBHOOK_SECRET)
      .update(ts + '.' + req.body)          // req.body is a Buffer
      .digest('hex');

    // Constant-time comparison; lengths must match first.
    const a = Buffer.from(sig), b = Buffer.from(expected);
    if (a.length !== b.length || !crypto.timingSafeEqual(a, b)) {
      return res.sendStatus(401);
    }

    res.sendStatus(200);              // acknowledge first…
    enqueue(JSON.parse(req.body));       // …then do the work
  });

Verify against the raw bytes: parsing and re-serialising the JSON changes them and the signature will not match. Compare in constant time. Acknowledge before working, because we time out.

PropertyBehaviour
SpeedEvents are sent within a few seconds of the change reaching us, one request per event — except account.equity_updated, which is sent on its interval.
Timeout10 seconds for your response headers.
SuccessAny 2xx. The response body is ignored.
RetriesSix retries with growing delays, about 21 hours in total: after 1 minute, 5 minutes, 30 minutes, 2 hours, 6 hours and 12 hours. After that, use replay.
DuplicatesDelivery is at least once. Deduplicate on the event id.
OrderingEvents for one account are sent in the order they occurred, but a retry can arrive after a later event. Order by occurred_at, and treat a position.closed as final even if a position.modified for the same ticket arrives afterwards.
Auto-disableAn endpoint failing continuously for 72 hours is disabled and we notify your technical contact by email. Events keep being stored for replay. Switch it back on with PATCH /webhooks/{id} and {"active": true}, then fill the gap with replay or GET /events: nothing from the time it was failing or off is sent by itself. If you switch an endpoint off yourself, deliveries already queued wait and go out once it is on again, but events that occur while it is off are not queued for it.

Replay

Every event except account.equity_updated is stored for 7 days. If your endpoint was down, or you want to rebuild from a point in time, you can fetch the events yourself or have us send them again. Equity updates are not stored as events; use equity history to fill those gaps.

Times here (since, until) refer to when we recorded an event, which is when it went out to your endpoints. occurred_at can be earlier: a position opened while the account was disconnected is recorded when it reconnects. So a window starting when your endpoint went down catches everything it missed.

GET /events
Stored events in the order we recorded them, oldest first, cursor-paginated. Each item is exactly the body we send to your endpoint.
Query parameterTypeDescription
afterstringAn event id. Returns only events recorded after it: pass the last id you processed. An id older than 7 days is refused with 422; use since then.
sincetimestampAlternative to after: events recorded at or after this time. Send one or the other, not both.
typesstringComma-separated event types.
account_idintegerOnly events of this account, also after it was deleted.
limitinteger1–500, default 100.
cursorstringFrom the previous page.
200 OK
{
  "data": [
    {
      "id": "evt_01JDQ8M4K7Z2X9R3B6V0N5H8TC",
      "type": "position.closed",
      "occurred_at": "2026-11-26T02:14:09Z",
      "data": { … }
    }
  ],
  "has_more": false,
  "next_cursor": null
}

When has_more is false you have everything up to now. To keep reading later, continue with after set to the last id you received.

POST /webhooks/{id}/replay
Sends stored events to a webhook endpoint again, signed and with their original ids.
Request
{
  "since": "2026-11-26T02:00:00Z",
  "until": "2026-11-26T06:30:00Z",
  "types": ["position.closed", "account.status_changed"]
}
202 Accepted
{
  "replay_id": "rpl_31",
  "events": 1842
}

since is required. until defaults to now and types to every type the endpoint subscribes to; types it does not subscribe to are refused. events is the number of events queued. Because replayed events keep their ids, the deduplication you already do makes a generous time window safe.

  • A replay runs alongside live deliveries and never holds them up, so replayed events can arrive between new ones. Failed deliveries are retried like any other.
  • One replay per endpoint at a time: starting a new one stops the replay still running and sends the new window instead.
  • Up to 50,000 events per replay; a larger window is refused with 422. For more, read them with GET /events, which is also faster.
  • A window without events answers "events": 0 and sends nothing.
  • The endpoint has to be switched on; a disabled one returns 409 invalid_state.

Errors

Every error is one object with a stable code. Branch on the code, never on message.

422 — validation
{
  "error": {
    "code": "validation_failed",
    "message": "platform must be MT4 or MT5",
    "field": "platform",
    "request_id": "req_8f21c4a9"
  }
}

request_id is on every error and in the X-Request-Id header of every response. Log it; quoting it to us turns a report into a quick lookup.

HTTPcodeMeaningRetry?
400malformed_requestBody is not valid JSON, or a header is unusable.no
401unauthorizedMissing, unknown or revoked key.no
403ip_not_allowedThe request came from an address not on the key's allowlist.no
403account_limit_reachedYour key holds the agreed maximum number of accounts; details.limit names it. Contact us to raise it.no
404not_foundNo such resource under your key.no
409duplicate_accountThis login on this server already exists; details.account_id names it.no
409duplicate_referenceAnother of your accounts already carries this reference; details.account_id names it.no
409invalid_stateNot possible in the current state, e.g. new credentials while the account is being set up or deleted, or a replay to a disabled endpoint.later
409idempotency_key_reusedSame idempotency key, different body.no
409webhook_limit_reachedFive webhook endpoints are registered already. Delete one first.no
409idempotency_key_in_progressThe first request with this key is still running.yes
422validation_failedA field is missing, malformed or out of range; field names it.no
429rate_limitedRate limit reached. See Retry-After.yes
500internal_errorOn our side. Safe to retry with the same idempotency key.yes
503service_unavailableMaintenance or overload. Retry-After is set.yes

Retry the ones marked yes with growing delays and some randomness. A 500 on a POST leaves it unclear whether the write happened; repeating it with the same idempotency key settles that without creating a duplicate.

Integration recipe

  1. Register your webhook first. Events for an account start the moment it is created; an endpoint registered afterwards misses them.
  2. Create the account with your reference and user_ref, the history mode your user chose, and an Idempotency-Key.
  3. Show “connecting” until account.status_changed arrives. On connected the account is live. On error, show the reason in plain words and, for a wrong password, login or server, let your user correct it; send the correction with PUT …/credentials.
  4. Keep your view current from events. position.* for trades, account.balance_changed for balance, account.equity_updated for equity, margin and floating profit.
  5. Reconcile. On startup, and every few minutes, call GET /positions and GET /accounts and correct your state. After downtime on your side, fetch GET /events?after=<last id> first.
  6. Alert on state, not on silence. A quiet account is usually an account without trades. disconnected and error are already confirmed and can go straight to your users.
  7. Delete accounts your users remove, so they stop counting towards your account total.

Before you go live

Support

Your technical contact is reachable at support@copysync.net. Include the request_id or event id when you report something specific. If a field or event does not fit your product, tell us; this API is built for you and can be extended.

Base URL https://tradeacademy.copysync.net/api/v2/ · Last updated 3 December 2026