Skip to content

ModifyTrade

Modifies Stop Loss (SL) and Take Profit (TP) for an existing open trade order.

PUT

https://{some_domain}/trade/modify

Authorization

All requests must include a JWT token:

Authorization: <JWT_TOKEN>

The token is issued by the authentication method (/sign/in) and contains session info (login, type, expiration).

Request

Content-Type: application/json

Body Parameters

Field Type Required Description
order int Yes Trade order ID
sl double Yes New Stop Loss
tp double Yes New Take Profit

Response

Success (200)

{
  "data": "OK"
}

Error Responses

Code Error Description
400 INVALID_DATA Validation failed, missing or incorrect request fields
401 PERMISSION_DENIED Access denied (wrong session type; only client sessions are allowed)
403 MODIFY_TRADE_ERROR Order does not belong to the authenticated user
404 MODIFY_TRADE_ERROR Order not found / retrieval failed
500 INCORRECT_SL_TP Server-side validation for SL/TP failed (CheckModifyTrade returned error)

Examples

1
2
3
4
5
6
7
8
curl -X PUT "https://{some_domain}/trade/modify"       
-H "Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."       
-H "Content-Type: application/json"       
--data-raw '{
    "order": 123456,
    "sl": 1.0825,
    "tp": 1.1010
  }'
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const url = "https://{some_domain}/trade/modify";
const jwt = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...";

async function modifyTrade() {
  const resp = await fetch(url, {
    method: "PUT",
    headers: {
      "Authorization": jwt,
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      order: 123456,
      sl: 1.0825,
      tp: 1.1010
    })
  });

  // HTTP status (e.g., 200, 400, 401, 404, 500)
  console.log("Status:", resp.status);

  // Parse JSON response body
  const data = await resp.json().catch(() => ({}));
  console.log("Body:", data);
}

// Call the function
modifyTrade().catch(console.error);
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
$url = "https://{some_domain}/trade/modify";
$jwt = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...";

$payload = [
    "order" => 123456,
    "sl" => 1.0825,
    "tp" => 1.1010
];

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "Authorization: " . $jwt,
    "Content-Type: application/json"
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload, JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);

if ($response === false) {
    $error = curl_error($ch);
    curl_close($ch);
    throw new RuntimeException("cURL error: " . $error);
}
curl_close($ch);

header("Content-Type: application/json");
echo json_encode([
    "status" => $httpCode,
    "body" => json_decode($response, true)
], JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE);

Response

{
  "data": "OK"
}