UpdScript¶
Info
PUT https://{some_domain}/script
Updates an existing private script for a user account.
Authorization¶
All requests must include a JWT token:
Authorization: <JWT_TOKEN>
Allowed roles: USER, MANAGER, ADMIN, DEALER.
Request¶
Content-Type: application/json
Body Parameters¶
| Field | Type | Required | Description |
|---|---|---|---|
id |
int | Yes | Script ID to update |
login |
int | Yes | Account login the script belongs to |
name |
string | Yes | Script name |
script |
string | Yes | Script source code (text) |
autostart |
int | No | Autostart flag (0 or 1). Default: keep current / 0 |
Notes:\ • The server sets
typeto"private"internally.\ •loginis read by the server and must be provided.
Response¶
Success (200)¶
{
"data": "OK"
}
Error Responses¶
| Code | Error | Description |
|---|---|---|
| 400 | INVALID_DATA |
Validation failed (missing/incorrect fields) |
| 500 | INVALID_UPDATE_SCRIPT |
Internal error while updating the script |
Example¶
Request¶
PUT https://{some_domain}/script
Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
Content-Type: application/json
{
"id": 42,
"login": 1001,
"name": "MorningScalper v2",
"script": "print('hello v2')",
"autostart": 0
}
Examples¶
curl -X PUT "https://{some_domain}/script" -H "Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." -H "Content-Type: application/json" --data-raw '{
"id": 42,
"login": 1001,
"name": "MorningScalper v2",
"script": "print(\"hello v2\")",
"autostart": 0
}'
const url = "https://{some_domain}/script";
const jwt = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...";
async function updateScript() {
const resp = await fetch(url, {
method: "PUT",
headers: {
"Authorization": jwt,
"Content-Type": "application/json"
},
body: JSON.stringify({
id: 42,
login: 1001,
name: "MorningScalper v2",
script: "print('hello v2')",
autostart: 0
})
});
console.log("Status:", resp.status);
const data = await resp.json().catch(() => ({}));
console.log("Body:", data);
}
updateScript().catch(console.error);
<?php
$url = "https://{some_domain}/script";
$jwt = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...";
$payload = [
"id" => 42,
"login" => 1001,
"name" => "MorningScalper v2",
"script" => "print('hello v2')",
"autostart" => 0
];
$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);