Skip to content

AddScript

Info

POST https://{some_domain}/script

Creates a new 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
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: 0

Notes:> • The server always sets type to "private"; any provided type is ignored.> • The response does not include the new script ID; a simple status is returned.

Response

Success (200)

{
  "data": "OK"
}

Error Responses

Code Error Description
400 INVALID_DATA Validation failed (missing/incorrect fields)
500 INVALID_ADD_SCRIPT Internal error while saving the script

Example

Request

POST https://{some_domain}/script
Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
Content-Type: application/json
{
  "login": 1001,
  "name": "MorningScalper",
  "script": "print('hello from script')",
  "autostart": 1
}

Examples

curl -X POST "https://{some_domain}/script"       -H "Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."       -H "Content-Type: application/json"       --data-raw '{
    "login": 1001,
    "name": "MorningScalper",
    "script": "print(\"hello from script\")",
    "autostart": 1
  }'
const url = "https://{some_domain}/script";
const jwt = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...";

async function addScript() {
  const resp = await fetch(url, {
    method: "POST",
    headers: {
      "Authorization": jwt,
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      login: 1001,
      name: "MorningScalper",
      script: "print('hello from script')",
      autostart: 1
    })
  });

  console.log("Status:", resp.status);
  const data = await resp.json().catch(() => ({}));
  console.log("Body:", data);
}

addScript().catch(console.error);
<?php
$url = "https://{some_domain}/script";
$jwt = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...";

$payload = [
    "login" => 1001,
    "name" => "MorningScalper",
    "script" => "print('hello from script')",
    "autostart" => 1
];

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
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);