Trading on behalf
Place, change and close orders FOR a mapped user through the same order path the trader uses. Leverage, spread, lot rules, margin and every guard apply; every action is written to the client's history as done by your key. MetaTrader accounts are not traded here (409 mt_account).
#The user's pending orders
Scope accounts:read. ?account_id= narrows to one of the user's accounts.
Path parameters
Your client id (1-191 letters, digits, . _ @ : + -). Stored on the client as external_user_id.
Query parameters
Responses
The pending orders (status pending).
not_found / user_not_found / account_not_found / symbol_not_found.
curl "https://api.your-brand.com/api/external/v1/users/cust_10042/orders" \
-H "X-Api-Key: $OCTOLIT_PARTNER_KEY"const res = await fetch("https://api.your-brand.com/api/external/v1/users/cust_10042/orders", {
method: "GET",
headers: {
"X-Api-Key": process.env.OCTOLIT_PARTNER_KEY,
},
});
if (!res.ok) throw new Error(`GET failed: ${res.status} ${await res.text()}`);
const data = await res.json();
console.log(data);import os, requests
r = requests.request(
"GET",
"https://api.your-brand.com/api/external/v1/users/cust_10042/orders",
headers={"X-Api-Key": os.environ["OCTOLIT_PARTNER_KEY"]},
timeout=10,
)
r.raise_for_status()
print(r.json())<?php
$ch = curl_init("https://api.your-brand.com/api/external/v1/users/cust_10042/orders");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"X-Api-Key: " . getenv("OCTOLIT_PARTNER_KEY"),
],
]);
$data = json_decode(curl_exec($ch), true);
curl_close($ch);
print_r($data);using var http = new HttpClient();
using var req = new HttpRequestMessage(HttpMethod.Get, "https://api.your-brand.com/api/external/v1/users/cust_10042/orders");
req.Headers.Add("X-Api-Key", Environment.GetEnvironmentVariable("OCTOLIT_PARTNER_KEY"));
using var res = await http.SendAsync(req);
res.EnsureSuccessStatusCode();
Console.WriteLine(await res.Content.ReadAsStringAsync());var client = HttpClient.newHttpClient();
var req = HttpRequest.newBuilder(URI.create("https://api.your-brand.com/api/external/v1/users/cust_10042/orders"))
.header("X-Api-Key", System.getenv("OCTOLIT_PARTNER_KEY"))
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
var res = client.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(res.statusCode() + " " + res.body());var body io.Reader
req, err := http.NewRequest("GET", "https://api.your-brand.com/api/external/v1/users/cust_10042/orders", body)
if err != nil {
log.Fatal(err)
}
req.Header.Set("X-Api-Key", os.Getenv("OCTOLIT_PARTNER_KEY"))
res, err := http.DefaultClient.Do(req)
if err != nil {
log.Fatal(err)
}
defer res.Body.Close()
out, _ := io.ReadAll(res.Body)
fmt.Println(res.StatusCode, string(out))var req = URLRequest(url: URL(string: "https://api.your-brand.com/api/external/v1/users/cust_10042/orders")!)
req.httpMethod = "GET"
req.setValue(ProcessInfo.processInfo.environment["OCTOLIT_PARTNER_KEY"], forHTTPHeaderField: "X-Api-Key")
let (data, response) = try await URLSession.shared.data(for: req)
print((response as! HTTPURLResponse).statusCode, String(decoding: data, as: UTF8.self))val client = OkHttpClient()
val req = Request.Builder()
.url("https://api.your-brand.com/api/external/v1/users/cust_10042/orders")
.header("X-Api-Key", System.getenv("OCTOLIT_PARTNER_KEY"))
.get()
.build()
client.newCall(req).execute().use { res ->
println("${res.code} ${res.body?.string()}")
} {
"orders": [
{
"id": 1042,
"account_id": 55,
"symbol": "EURUSD",
"status": "open",
"side": "buy",
"order_type": 1,
"amount": "100.00",
"trade_amount": "string",
"units": 10000,
"lot_size": 1.5,
"leverage": 100,
"open_price": "string",
"stop_loss": "string",
"take_profit": "string",
"profit": "19.00",
"commission": "0.00",
"swap": "-0.12",
"market": "string",
"opened_at": "2026-11-11T09:30:00Z",
"closed_at": "2026-11-11T10:05:12Z",
"closed_by": "string",
"created_at": "2026-11-11T09:30:00.000000Z"
}
]
}#Place an order for the user
Scope trading:act. Places a market / limit / stop order on one of the user's trading accounts through the SAME order path the trading platform uses (the account's leverage, spread, lot rules, margin and every CRM guard apply; the position is the user's). The brand's partner API switch and the user's trading state are checked (403 brand_disabled, company_inactive, brand_inactive, client_inactive, trading_inactive). Every action is written to the client's history as done by this API key. Idempotent per key by client_order_id (body or Idempotency-Key header): a repeat returns 200 replayed with the first answer.
Path parameters
Your client id (1-191 letters, digits, . _ @ : + -). Stored on the client as external_user_id.
Headers
Used as client_order_id when the body has none.
Request body · application/json
Your id of this order (idempotency per key, letters digits _ - : .); or send the Idempotency-Key header. 0-64 characters.
One of the user's trading accounts.
The symbol id (or symbol).
The symbol name
buysellmarketlimitstopSize in units (or lots).
Size in lots (converted with the symbol's contract size).
One of the leverages the account offers; default the symbol's.
Required for limit / stop.
Responses
replayed - the same client_order_id was placed before.
placed - the order / position.
insufficient_scope, ip_not_allowed, api_disabled, company_inactive, brand_disabled, sso_disabled, trending_disabled (trading on behalf also: brand_inactive, client_inactive, trading_inactive, trading_denied).
not_found / user_not_found / account_not_found / symbol_not_found.
invalid_request (details.errors) or a refusal of the order path: order_refused, insufficient_margin, invalid_size, invalid_levels, invalid_price, invalid_leverage, market_closed, symbol_not_allowed, too_many_orders (details.reason / details.errors). Also 409 mt_account (an MT4 / MT5 account is not traded here), 503 no_price / balance_unavailable.
curl -X POST "https://api.your-brand.com/api/external/v1/users/cust_10042/orders" \
-H "X-Api-Key: $OCTOLIT_PARTNER_KEY" \
-H "Content-Type: application/json" \
-d '{
"client_order_id": "ord-2026-0001",
"trading_account_id": 55,
"symbol_id": 42,
"symbol": "EURUSD",
"side": "buy",
"type": "market",
"units": 10000,
"lots": 0.1,
"leverage": 100,
"sl": 1.08,
"tp": 1.1,
"price": 1.085
}'const res = await fetch("https://api.your-brand.com/api/external/v1/users/cust_10042/orders", {
method: "POST",
headers: {
"X-Api-Key": process.env.OCTOLIT_PARTNER_KEY,
"Content-Type": "application/json",
},
body: JSON.stringify({
"client_order_id": "ord-2026-0001",
"trading_account_id": 55,
"symbol_id": 42,
"symbol": "EURUSD",
"side": "buy",
"type": "market",
"units": 10000,
"lots": 0.1,
"leverage": 100,
"sl": 1.08,
"tp": 1.1,
"price": 1.085
}),
});
if (!res.ok) throw new Error(`POST failed: ${res.status} ${await res.text()}`);
const data = await res.json();
console.log(data);import os, requests
r = requests.request(
"POST",
"https://api.your-brand.com/api/external/v1/users/cust_10042/orders",
headers={"X-Api-Key": os.environ["OCTOLIT_PARTNER_KEY"]},
json={
"client_order_id": "ord-2026-0001",
"trading_account_id": 55,
"symbol_id": 42,
"symbol": "EURUSD",
"side": "buy",
"type": "market",
"units": 10000,
"lots": 0.1,
"leverage": 100,
"sl": 1.08,
"tp": 1.1,
"price": 1.085,
},
timeout=10,
)
r.raise_for_status()
print(r.json())<?php
$ch = curl_init("https://api.your-brand.com/api/external/v1/users/cust_10042/orders");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"X-Api-Key: " . getenv("OCTOLIT_PARTNER_KEY"),
"Content-Type: " . "application/json",
],
CURLOPT_POSTFIELDS => json_encode([
"client_order_id" => "ord-2026-0001",
"trading_account_id" => 55,
"symbol_id" => 42,
"symbol" => "EURUSD",
"side" => "buy",
"type" => "market",
"units" => 10000,
"lots" => 0.1,
"leverage" => 100,
"sl" => 1.08,
"tp" => 1.1,
"price" => 1.085,
]),
]);
$data = json_decode(curl_exec($ch), true);
curl_close($ch);
print_r($data);using var http = new HttpClient();
using var req = new HttpRequestMessage(HttpMethod.Post, "https://api.your-brand.com/api/external/v1/users/cust_10042/orders");
req.Headers.Add("X-Api-Key", Environment.GetEnvironmentVariable("OCTOLIT_PARTNER_KEY"));
req.Content = new StringContent("""
{
"client_order_id": "ord-2026-0001",
"trading_account_id": 55,
"symbol_id": 42,
"symbol": "EURUSD",
"side": "buy",
"type": "market",
"units": 10000,
"lots": 0.1,
"leverage": 100,
"sl": 1.08,
"tp": 1.1,
"price": 1.085
}
""", Encoding.UTF8, "application/json");
using var res = await http.SendAsync(req);
res.EnsureSuccessStatusCode();
Console.WriteLine(await res.Content.ReadAsStringAsync());var client = HttpClient.newHttpClient();
var req = HttpRequest.newBuilder(URI.create("https://api.your-brand.com/api/external/v1/users/cust_10042/orders"))
.header("X-Api-Key", System.getenv("OCTOLIT_PARTNER_KEY"))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("""
{
"client_order_id": "ord-2026-0001",
"trading_account_id": 55,
"symbol_id": 42,
"symbol": "EURUSD",
"side": "buy",
"type": "market",
"units": 10000,
"lots": 0.1,
"leverage": 100,
"sl": 1.08,
"tp": 1.1,
"price": 1.085
}
"""))
.build();
var res = client.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(res.statusCode() + " " + res.body());body := strings.NewReader(`{
"client_order_id": "ord-2026-0001",
"trading_account_id": 55,
"symbol_id": 42,
"symbol": "EURUSD",
"side": "buy",
"type": "market",
"units": 10000,
"lots": 0.1,
"leverage": 100,
"sl": 1.08,
"tp": 1.1,
"price": 1.085
}`)
req, err := http.NewRequest("POST", "https://api.your-brand.com/api/external/v1/users/cust_10042/orders", body)
if err != nil {
log.Fatal(err)
}
req.Header.Set("X-Api-Key", os.Getenv("OCTOLIT_PARTNER_KEY"))
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
log.Fatal(err)
}
defer res.Body.Close()
out, _ := io.ReadAll(res.Body)
fmt.Println(res.StatusCode, string(out))var req = URLRequest(url: URL(string: "https://api.your-brand.com/api/external/v1/users/cust_10042/orders")!)
req.httpMethod = "POST"
req.setValue(ProcessInfo.processInfo.environment["OCTOLIT_PARTNER_KEY"], forHTTPHeaderField: "X-Api-Key")
req.setValue("application/json", forHTTPHeaderField: "Content-Type")
req.httpBody = """
{
"client_order_id": "ord-2026-0001",
"trading_account_id": 55,
"symbol_id": 42,
"symbol": "EURUSD",
"side": "buy",
"type": "market",
"units": 10000,
"lots": 0.1,
"leverage": 100,
"sl": 1.08,
"tp": 1.1,
"price": 1.085
}
""".data(using: .utf8)
let (data, response) = try await URLSession.shared.data(for: req)
print((response as! HTTPURLResponse).statusCode, String(decoding: data, as: UTF8.self))val client = OkHttpClient()
val req = Request.Builder()
.url("https://api.your-brand.com/api/external/v1/users/cust_10042/orders")
.header("X-Api-Key", System.getenv("OCTOLIT_PARTNER_KEY"))
.method("POST", """{
"client_order_id": "ord-2026-0001",
"trading_account_id": 55,
"symbol_id": 42,
"symbol": "EURUSD",
"side": "buy",
"type": "market",
"units": 10000,
"lots": 0.1,
"leverage": 100,
"sl": 1.08,
"tp": 1.1,
"price": 1.085
}""".toRequestBody("application/json".toMediaType()))
.build()
client.newCall(req).execute().use { res ->
println("${res.code} ${res.body?.string()}")
} {
"code": "placed",
"client_order_id": "ord-2026-0001",
"order": {
"id": 1042,
"account_id": 55,
"symbol": "EURUSD",
"status": "open",
"side": "buy",
"order_type": 1,
"amount": "100.00",
"trade_amount": "string",
"units": 10000,
"lot_size": 1.5,
"leverage": 100,
"open_price": "string",
"stop_loss": "string",
"take_profit": "string",
"profit": "19.00",
"commission": "0.00",
"swap": "-0.12",
"market": "string",
"opened_at": "2026-11-11T09:30:00Z",
"closed_at": "2026-11-11T10:05:12Z",
"closed_by": "string",
"created_at": "2026-11-11T09:30:00.000000Z"
},
"position": {
"id": 1042,
"account_id": 55,
"symbol": "EURUSD",
"status": "open",
"side": "buy",
"order_type": 1,
"amount": "100.00",
"trade_amount": "string",
"units": 10000,
"lot_size": 1.5,
"leverage": 100,
"open_price": "string",
"stop_loss": "string",
"take_profit": "string",
"profit": "19.00",
"commission": "0.00",
"swap": "-0.12",
"market": "string",
"opened_at": "2026-11-11T09:30:00Z",
"closed_at": "2026-11-11T10:05:12Z",
"closed_by": "string",
"created_at": "2026-11-11T09:30:00.000000Z"
}
}{
"code": "placed",
"client_order_id": "ord-2026-0001",
"order": {
"id": 1042,
"account_id": 55,
"symbol": "EURUSD",
"status": "open",
"side": "buy",
"order_type": 1,
"amount": "100.00",
"trade_amount": "string",
"units": 10000,
"lot_size": 1.5,
"leverage": 100,
"open_price": "string",
"stop_loss": "string",
"take_profit": "string",
"profit": "19.00",
"commission": "0.00",
"swap": "-0.12",
"market": "string",
"opened_at": "2026-11-11T09:30:00Z",
"closed_at": "2026-11-11T10:05:12Z",
"closed_by": "string",
"created_at": "2026-11-11T09:30:00.000000Z"
},
"position": {
"id": 1042,
"account_id": 55,
"symbol": "EURUSD",
"status": "open",
"side": "buy",
"order_type": 1,
"amount": "100.00",
"trade_amount": "string",
"units": 10000,
"lot_size": 1.5,
"leverage": 100,
"open_price": "string",
"stop_loss": "string",
"take_profit": "string",
"profit": "19.00",
"commission": "0.00",
"swap": "-0.12",
"market": "string",
"opened_at": "2026-11-11T09:30:00Z",
"closed_at": "2026-11-11T10:05:12Z",
"closed_by": "string",
"created_at": "2026-11-11T09:30:00.000000Z"
}
}#Find the order / position this key placed with a client_order_id
Scope accounts:read. ?client_order_id= - 404 not_found when this key never placed it.
Path parameters
Your client id (1-191 letters, digits, . _ @ : + -). Stored on the client as external_user_id.
Query parameters
Responses
The order (pending) or position (open / closed) with that id.
not_found / user_not_found / account_not_found / symbol_not_found.
invalid_request with details.errors = { field: reason }.
curl "https://api.your-brand.com/api/external/v1/users/cust_10042/orders/lookup?client_order_id=ord-2026-0001" \
-H "X-Api-Key: $OCTOLIT_PARTNER_KEY"const res = await fetch("https://api.your-brand.com/api/external/v1/users/cust_10042/orders/lookup?client_order_id=ord-2026-0001", {
method: "GET",
headers: {
"X-Api-Key": process.env.OCTOLIT_PARTNER_KEY,
},
});
if (!res.ok) throw new Error(`GET failed: ${res.status} ${await res.text()}`);
const data = await res.json();
console.log(data);import os, requests
r = requests.request(
"GET",
"https://api.your-brand.com/api/external/v1/users/cust_10042/orders/lookup?client_order_id=ord-2026-0001",
headers={"X-Api-Key": os.environ["OCTOLIT_PARTNER_KEY"]},
timeout=10,
)
r.raise_for_status()
print(r.json())<?php
$ch = curl_init("https://api.your-brand.com/api/external/v1/users/cust_10042/orders/lookup?client_order_id=ord-2026-0001");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"X-Api-Key: " . getenv("OCTOLIT_PARTNER_KEY"),
],
]);
$data = json_decode(curl_exec($ch), true);
curl_close($ch);
print_r($data);using var http = new HttpClient();
using var req = new HttpRequestMessage(HttpMethod.Get, "https://api.your-brand.com/api/external/v1/users/cust_10042/orders/lookup?client_order_id=ord-2026-0001");
req.Headers.Add("X-Api-Key", Environment.GetEnvironmentVariable("OCTOLIT_PARTNER_KEY"));
using var res = await http.SendAsync(req);
res.EnsureSuccessStatusCode();
Console.WriteLine(await res.Content.ReadAsStringAsync());var client = HttpClient.newHttpClient();
var req = HttpRequest.newBuilder(URI.create("https://api.your-brand.com/api/external/v1/users/cust_10042/orders/lookup?client_order_id=ord-2026-0001"))
.header("X-Api-Key", System.getenv("OCTOLIT_PARTNER_KEY"))
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
var res = client.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(res.statusCode() + " " + res.body());var body io.Reader
req, err := http.NewRequest("GET", "https://api.your-brand.com/api/external/v1/users/cust_10042/orders/lookup?client_order_id=ord-2026-0001", body)
if err != nil {
log.Fatal(err)
}
req.Header.Set("X-Api-Key", os.Getenv("OCTOLIT_PARTNER_KEY"))
res, err := http.DefaultClient.Do(req)
if err != nil {
log.Fatal(err)
}
defer res.Body.Close()
out, _ := io.ReadAll(res.Body)
fmt.Println(res.StatusCode, string(out))var req = URLRequest(url: URL(string: "https://api.your-brand.com/api/external/v1/users/cust_10042/orders/lookup?client_order_id=ord-2026-0001")!)
req.httpMethod = "GET"
req.setValue(ProcessInfo.processInfo.environment["OCTOLIT_PARTNER_KEY"], forHTTPHeaderField: "X-Api-Key")
let (data, response) = try await URLSession.shared.data(for: req)
print((response as! HTTPURLResponse).statusCode, String(decoding: data, as: UTF8.self))val client = OkHttpClient()
val req = Request.Builder()
.url("https://api.your-brand.com/api/external/v1/users/cust_10042/orders/lookup?client_order_id=ord-2026-0001")
.header("X-Api-Key", System.getenv("OCTOLIT_PARTNER_KEY"))
.get()
.build()
client.newCall(req).execute().use { res ->
println("${res.code} ${res.body?.string()}")
} {
"client_order_id": "ord-2026-0001",
"order": {
"id": 1042,
"account_id": 55,
"symbol": "EURUSD",
"status": "open",
"side": "buy",
"order_type": 1,
"amount": "100.00",
"trade_amount": "string",
"units": 10000,
"lot_size": 1.5,
"leverage": 100,
"open_price": "string",
"stop_loss": "string",
"take_profit": "string",
"profit": "19.00",
"commission": "0.00",
"swap": "-0.12",
"market": "string",
"opened_at": "2026-11-11T09:30:00Z",
"closed_at": "2026-11-11T10:05:12Z",
"closed_by": "string",
"created_at": "2026-11-11T09:30:00.000000Z"
}
}#Change a pending order (price, stop loss, take profit)
Scope trading:act. Body { "price": 1.0850, "sl": 1.08, "tp": null, "client_order_id": "..." } - a field left out keeps its value, null clears it. 409 not_pending when the order was filled already. Answers 200 modified / 200 unchanged.
Path parameters
Your client id (1-191 letters, digits, . _ @ : + -). Stored on the client as external_user_id.
The pending order's id.
Request body · application/json
Pending orders only.
0-64 characters.
Responses
The order after the change.
insufficient_scope, ip_not_allowed, api_disabled, company_inactive, brand_disabled, sso_disabled, trending_disabled (trading on behalf also: brand_inactive, client_inactive, trading_inactive, trading_denied).
not_found / user_not_found / account_not_found / symbol_not_found.
email_taken, brand_fixed, limit_reached, already_linked, no_brand, no_app_domain.
invalid_request with details.errors = { field: reason }.
curl -X PATCH "https://api.your-brand.com/api/external/v1/users/cust_10042/orders/1042" \
-H "X-Api-Key: $OCTOLIT_PARTNER_KEY" \
-H "Content-Type: application/json" \
-d '{
"price": 1.085,
"sl": 1.08,
"tp": 1.1,
"client_order_id": "ord-2026-0001"
}'const res = await fetch("https://api.your-brand.com/api/external/v1/users/cust_10042/orders/1042", {
method: "PATCH",
headers: {
"X-Api-Key": process.env.OCTOLIT_PARTNER_KEY,
"Content-Type": "application/json",
},
body: JSON.stringify({
"price": 1.085,
"sl": 1.08,
"tp": 1.1,
"client_order_id": "ord-2026-0001"
}),
});
if (!res.ok) throw new Error(`PATCH failed: ${res.status} ${await res.text()}`);
const data = await res.json();
console.log(data);import os, requests
r = requests.request(
"PATCH",
"https://api.your-brand.com/api/external/v1/users/cust_10042/orders/1042",
headers={"X-Api-Key": os.environ["OCTOLIT_PARTNER_KEY"]},
json={
"price": 1.085,
"sl": 1.08,
"tp": 1.1,
"client_order_id": "ord-2026-0001",
},
timeout=10,
)
r.raise_for_status()
print(r.json())<?php
$ch = curl_init("https://api.your-brand.com/api/external/v1/users/cust_10042/orders/1042");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"X-Api-Key: " . getenv("OCTOLIT_PARTNER_KEY"),
"Content-Type: " . "application/json",
],
CURLOPT_POSTFIELDS => json_encode([
"price" => 1.085,
"sl" => 1.08,
"tp" => 1.1,
"client_order_id" => "ord-2026-0001",
]),
]);
$data = json_decode(curl_exec($ch), true);
curl_close($ch);
print_r($data);using var http = new HttpClient();
using var req = new HttpRequestMessage(HttpMethod.Patch, "https://api.your-brand.com/api/external/v1/users/cust_10042/orders/1042");
req.Headers.Add("X-Api-Key", Environment.GetEnvironmentVariable("OCTOLIT_PARTNER_KEY"));
req.Content = new StringContent("""
{
"price": 1.085,
"sl": 1.08,
"tp": 1.1,
"client_order_id": "ord-2026-0001"
}
""", Encoding.UTF8, "application/json");
using var res = await http.SendAsync(req);
res.EnsureSuccessStatusCode();
Console.WriteLine(await res.Content.ReadAsStringAsync());var client = HttpClient.newHttpClient();
var req = HttpRequest.newBuilder(URI.create("https://api.your-brand.com/api/external/v1/users/cust_10042/orders/1042"))
.header("X-Api-Key", System.getenv("OCTOLIT_PARTNER_KEY"))
.header("Content-Type", "application/json")
.method("PATCH", HttpRequest.BodyPublishers.ofString("""
{
"price": 1.085,
"sl": 1.08,
"tp": 1.1,
"client_order_id": "ord-2026-0001"
}
"""))
.build();
var res = client.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(res.statusCode() + " " + res.body());body := strings.NewReader(`{
"price": 1.085,
"sl": 1.08,
"tp": 1.1,
"client_order_id": "ord-2026-0001"
}`)
req, err := http.NewRequest("PATCH", "https://api.your-brand.com/api/external/v1/users/cust_10042/orders/1042", body)
if err != nil {
log.Fatal(err)
}
req.Header.Set("X-Api-Key", os.Getenv("OCTOLIT_PARTNER_KEY"))
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
log.Fatal(err)
}
defer res.Body.Close()
out, _ := io.ReadAll(res.Body)
fmt.Println(res.StatusCode, string(out))var req = URLRequest(url: URL(string: "https://api.your-brand.com/api/external/v1/users/cust_10042/orders/1042")!)
req.httpMethod = "PATCH"
req.setValue(ProcessInfo.processInfo.environment["OCTOLIT_PARTNER_KEY"], forHTTPHeaderField: "X-Api-Key")
req.setValue("application/json", forHTTPHeaderField: "Content-Type")
req.httpBody = """
{
"price": 1.085,
"sl": 1.08,
"tp": 1.1,
"client_order_id": "ord-2026-0001"
}
""".data(using: .utf8)
let (data, response) = try await URLSession.shared.data(for: req)
print((response as! HTTPURLResponse).statusCode, String(decoding: data, as: UTF8.self))val client = OkHttpClient()
val req = Request.Builder()
.url("https://api.your-brand.com/api/external/v1/users/cust_10042/orders/1042")
.header("X-Api-Key", System.getenv("OCTOLIT_PARTNER_KEY"))
.method("PATCH", """{
"price": 1.085,
"sl": 1.08,
"tp": 1.1,
"client_order_id": "ord-2026-0001"
}""".toRequestBody("application/json".toMediaType()))
.build()
client.newCall(req).execute().use { res ->
println("${res.code} ${res.body?.string()}")
} {
"code": "placed",
"client_order_id": "ord-2026-0001",
"order": {
"id": 1042,
"account_id": 55,
"symbol": "EURUSD",
"status": "open",
"side": "buy",
"order_type": 1,
"amount": "100.00",
"trade_amount": "string",
"units": 10000,
"lot_size": 1.5,
"leverage": 100,
"open_price": "string",
"stop_loss": "string",
"take_profit": "string",
"profit": "19.00",
"commission": "0.00",
"swap": "-0.12",
"market": "string",
"opened_at": "2026-11-11T09:30:00Z",
"closed_at": "2026-11-11T10:05:12Z",
"closed_by": "string",
"created_at": "2026-11-11T09:30:00.000000Z"
},
"position": {
"id": 1042,
"account_id": 55,
"symbol": "EURUSD",
"status": "open",
"side": "buy",
"order_type": 1,
"amount": "100.00",
"trade_amount": "string",
"units": 10000,
"lot_size": 1.5,
"leverage": 100,
"open_price": "string",
"stop_loss": "string",
"take_profit": "string",
"profit": "19.00",
"commission": "0.00",
"swap": "-0.12",
"market": "string",
"opened_at": "2026-11-11T09:30:00Z",
"closed_at": "2026-11-11T10:05:12Z",
"closed_by": "string",
"created_at": "2026-11-11T09:30:00.000000Z"
}
}#Cancel a pending order
Scope trading:act. Answers 200 cancelled / 200 already_cancelled; 409 not_pending once filled.
Path parameters
Your client id (1-191 letters, digits, . _ @ : + -). Stored on the client as external_user_id.
The pending order's id.
Responses
Cancelled.
insufficient_scope, ip_not_allowed, api_disabled, company_inactive, brand_disabled, sso_disabled, trending_disabled (trading on behalf also: brand_inactive, client_inactive, trading_inactive, trading_denied).
not_found / user_not_found / account_not_found / symbol_not_found.
email_taken, brand_fixed, limit_reached, already_linked, no_brand, no_app_domain.
curl -X DELETE "https://api.your-brand.com/api/external/v1/users/cust_10042/orders/1042" \
-H "X-Api-Key: $OCTOLIT_PARTNER_KEY"const res = await fetch("https://api.your-brand.com/api/external/v1/users/cust_10042/orders/1042", {
method: "DELETE",
headers: {
"X-Api-Key": process.env.OCTOLIT_PARTNER_KEY,
},
});
if (!res.ok) throw new Error(`DELETE failed: ${res.status} ${await res.text()}`);
const data = await res.json();
console.log(data);import os, requests
r = requests.request(
"DELETE",
"https://api.your-brand.com/api/external/v1/users/cust_10042/orders/1042",
headers={"X-Api-Key": os.environ["OCTOLIT_PARTNER_KEY"]},
timeout=10,
)
r.raise_for_status()
print(r.json())<?php
$ch = curl_init("https://api.your-brand.com/api/external/v1/users/cust_10042/orders/1042");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => "DELETE",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"X-Api-Key: " . getenv("OCTOLIT_PARTNER_KEY"),
],
]);
$data = json_decode(curl_exec($ch), true);
curl_close($ch);
print_r($data);using var http = new HttpClient();
using var req = new HttpRequestMessage(HttpMethod.Delete, "https://api.your-brand.com/api/external/v1/users/cust_10042/orders/1042");
req.Headers.Add("X-Api-Key", Environment.GetEnvironmentVariable("OCTOLIT_PARTNER_KEY"));
using var res = await http.SendAsync(req);
res.EnsureSuccessStatusCode();
Console.WriteLine(await res.Content.ReadAsStringAsync());var client = HttpClient.newHttpClient();
var req = HttpRequest.newBuilder(URI.create("https://api.your-brand.com/api/external/v1/users/cust_10042/orders/1042"))
.header("X-Api-Key", System.getenv("OCTOLIT_PARTNER_KEY"))
.method("DELETE", HttpRequest.BodyPublishers.noBody())
.build();
var res = client.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(res.statusCode() + " " + res.body());var body io.Reader
req, err := http.NewRequest("DELETE", "https://api.your-brand.com/api/external/v1/users/cust_10042/orders/1042", body)
if err != nil {
log.Fatal(err)
}
req.Header.Set("X-Api-Key", os.Getenv("OCTOLIT_PARTNER_KEY"))
res, err := http.DefaultClient.Do(req)
if err != nil {
log.Fatal(err)
}
defer res.Body.Close()
out, _ := io.ReadAll(res.Body)
fmt.Println(res.StatusCode, string(out))var req = URLRequest(url: URL(string: "https://api.your-brand.com/api/external/v1/users/cust_10042/orders/1042")!)
req.httpMethod = "DELETE"
req.setValue(ProcessInfo.processInfo.environment["OCTOLIT_PARTNER_KEY"], forHTTPHeaderField: "X-Api-Key")
let (data, response) = try await URLSession.shared.data(for: req)
print((response as! HTTPURLResponse).statusCode, String(decoding: data, as: UTF8.self))val client = OkHttpClient()
val req = Request.Builder()
.url("https://api.your-brand.com/api/external/v1/users/cust_10042/orders/1042")
.header("X-Api-Key", System.getenv("OCTOLIT_PARTNER_KEY"))
.method("DELETE", null)
.build()
client.newCall(req).execute().use { res ->
println("${res.code} ${res.body?.string()}")
} {
"code": "placed",
"client_order_id": "ord-2026-0001",
"order": {
"id": 1042,
"account_id": 55,
"symbol": "EURUSD",
"status": "open",
"side": "buy",
"order_type": 1,
"amount": "100.00",
"trade_amount": "string",
"units": 10000,
"lot_size": 1.5,
"leverage": 100,
"open_price": "string",
"stop_loss": "string",
"take_profit": "string",
"profit": "19.00",
"commission": "0.00",
"swap": "-0.12",
"market": "string",
"opened_at": "2026-11-11T09:30:00Z",
"closed_at": "2026-11-11T10:05:12Z",
"closed_by": "string",
"created_at": "2026-11-11T09:30:00.000000Z"
},
"position": {
"id": 1042,
"account_id": 55,
"symbol": "EURUSD",
"status": "open",
"side": "buy",
"order_type": 1,
"amount": "100.00",
"trade_amount": "string",
"units": 10000,
"lot_size": 1.5,
"leverage": 100,
"open_price": "string",
"stop_loss": "string",
"take_profit": "string",
"profit": "19.00",
"commission": "0.00",
"swap": "-0.12",
"market": "string",
"opened_at": "2026-11-11T09:30:00Z",
"closed_at": "2026-11-11T10:05:12Z",
"closed_by": "string",
"created_at": "2026-11-11T09:30:00.000000Z"
}
}#Change the stop loss / take profit of an open position
Scope trading:act. Body { "sl": 1.08, "tp": 1.10, "client_order_id": "..." } - a field left out keeps its value, null clears it. 409 pending_order for an order not filled yet (use the orders routes).
Path parameters
Your client id (1-191 letters, digits, . _ @ : + -). Stored on the client as external_user_id.
The open position's id.
Request body · application/json
Pending orders only.
0-64 characters.
Responses
modified / unchanged - the position after the change.
insufficient_scope, ip_not_allowed, api_disabled, company_inactive, brand_disabled, sso_disabled, trending_disabled (trading on behalf also: brand_inactive, client_inactive, trading_inactive, trading_denied).
not_found / user_not_found / account_not_found / symbol_not_found.
email_taken, brand_fixed, limit_reached, already_linked, no_brand, no_app_domain.
invalid_request with details.errors = { field: reason }.
curl -X PATCH "https://api.your-brand.com/api/external/v1/users/cust_10042/positions/1042" \
-H "X-Api-Key: $OCTOLIT_PARTNER_KEY" \
-H "Content-Type: application/json" \
-d '{
"price": 1.085,
"sl": 1.08,
"tp": 1.1,
"client_order_id": "ord-2026-0001"
}'const res = await fetch("https://api.your-brand.com/api/external/v1/users/cust_10042/positions/1042", {
method: "PATCH",
headers: {
"X-Api-Key": process.env.OCTOLIT_PARTNER_KEY,
"Content-Type": "application/json",
},
body: JSON.stringify({
"price": 1.085,
"sl": 1.08,
"tp": 1.1,
"client_order_id": "ord-2026-0001"
}),
});
if (!res.ok) throw new Error(`PATCH failed: ${res.status} ${await res.text()}`);
const data = await res.json();
console.log(data);import os, requests
r = requests.request(
"PATCH",
"https://api.your-brand.com/api/external/v1/users/cust_10042/positions/1042",
headers={"X-Api-Key": os.environ["OCTOLIT_PARTNER_KEY"]},
json={
"price": 1.085,
"sl": 1.08,
"tp": 1.1,
"client_order_id": "ord-2026-0001",
},
timeout=10,
)
r.raise_for_status()
print(r.json())<?php
$ch = curl_init("https://api.your-brand.com/api/external/v1/users/cust_10042/positions/1042");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"X-Api-Key: " . getenv("OCTOLIT_PARTNER_KEY"),
"Content-Type: " . "application/json",
],
CURLOPT_POSTFIELDS => json_encode([
"price" => 1.085,
"sl" => 1.08,
"tp" => 1.1,
"client_order_id" => "ord-2026-0001",
]),
]);
$data = json_decode(curl_exec($ch), true);
curl_close($ch);
print_r($data);using var http = new HttpClient();
using var req = new HttpRequestMessage(HttpMethod.Patch, "https://api.your-brand.com/api/external/v1/users/cust_10042/positions/1042");
req.Headers.Add("X-Api-Key", Environment.GetEnvironmentVariable("OCTOLIT_PARTNER_KEY"));
req.Content = new StringContent("""
{
"price": 1.085,
"sl": 1.08,
"tp": 1.1,
"client_order_id": "ord-2026-0001"
}
""", Encoding.UTF8, "application/json");
using var res = await http.SendAsync(req);
res.EnsureSuccessStatusCode();
Console.WriteLine(await res.Content.ReadAsStringAsync());var client = HttpClient.newHttpClient();
var req = HttpRequest.newBuilder(URI.create("https://api.your-brand.com/api/external/v1/users/cust_10042/positions/1042"))
.header("X-Api-Key", System.getenv("OCTOLIT_PARTNER_KEY"))
.header("Content-Type", "application/json")
.method("PATCH", HttpRequest.BodyPublishers.ofString("""
{
"price": 1.085,
"sl": 1.08,
"tp": 1.1,
"client_order_id": "ord-2026-0001"
}
"""))
.build();
var res = client.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(res.statusCode() + " " + res.body());body := strings.NewReader(`{
"price": 1.085,
"sl": 1.08,
"tp": 1.1,
"client_order_id": "ord-2026-0001"
}`)
req, err := http.NewRequest("PATCH", "https://api.your-brand.com/api/external/v1/users/cust_10042/positions/1042", body)
if err != nil {
log.Fatal(err)
}
req.Header.Set("X-Api-Key", os.Getenv("OCTOLIT_PARTNER_KEY"))
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
log.Fatal(err)
}
defer res.Body.Close()
out, _ := io.ReadAll(res.Body)
fmt.Println(res.StatusCode, string(out))var req = URLRequest(url: URL(string: "https://api.your-brand.com/api/external/v1/users/cust_10042/positions/1042")!)
req.httpMethod = "PATCH"
req.setValue(ProcessInfo.processInfo.environment["OCTOLIT_PARTNER_KEY"], forHTTPHeaderField: "X-Api-Key")
req.setValue("application/json", forHTTPHeaderField: "Content-Type")
req.httpBody = """
{
"price": 1.085,
"sl": 1.08,
"tp": 1.1,
"client_order_id": "ord-2026-0001"
}
""".data(using: .utf8)
let (data, response) = try await URLSession.shared.data(for: req)
print((response as! HTTPURLResponse).statusCode, String(decoding: data, as: UTF8.self))val client = OkHttpClient()
val req = Request.Builder()
.url("https://api.your-brand.com/api/external/v1/users/cust_10042/positions/1042")
.header("X-Api-Key", System.getenv("OCTOLIT_PARTNER_KEY"))
.method("PATCH", """{
"price": 1.085,
"sl": 1.08,
"tp": 1.1,
"client_order_id": "ord-2026-0001"
}""".toRequestBody("application/json".toMediaType()))
.build()
client.newCall(req).execute().use { res ->
println("${res.code} ${res.body?.string()}")
} {
"code": "placed",
"client_order_id": "ord-2026-0001",
"order": {
"id": 1042,
"account_id": 55,
"symbol": "EURUSD",
"status": "open",
"side": "buy",
"order_type": 1,
"amount": "100.00",
"trade_amount": "string",
"units": 10000,
"lot_size": 1.5,
"leverage": 100,
"open_price": "string",
"stop_loss": "string",
"take_profit": "string",
"profit": "19.00",
"commission": "0.00",
"swap": "-0.12",
"market": "string",
"opened_at": "2026-11-11T09:30:00Z",
"closed_at": "2026-11-11T10:05:12Z",
"closed_by": "string",
"created_at": "2026-11-11T09:30:00.000000Z"
},
"position": {
"id": 1042,
"account_id": 55,
"symbol": "EURUSD",
"status": "open",
"side": "buy",
"order_type": 1,
"amount": "100.00",
"trade_amount": "string",
"units": 10000,
"lot_size": 1.5,
"leverage": 100,
"open_price": "string",
"stop_loss": "string",
"take_profit": "string",
"profit": "19.00",
"commission": "0.00",
"swap": "-0.12",
"market": "string",
"opened_at": "2026-11-11T09:30:00Z",
"closed_at": "2026-11-11T10:05:12Z",
"closed_by": "string",
"created_at": "2026-11-11T09:30:00.000000Z"
}
}#Close an open position at market
Scope trading:act. Body { "client_order_id": "..." } (optional, or the Idempotency-Key header). Answers 200 closed / 200 already_closed.
Path parameters
Your client id (1-191 letters, digits, . _ @ : + -). Stored on the client as external_user_id.
The open position's id.
Responses
The closed position.
insufficient_scope, ip_not_allowed, api_disabled, company_inactive, brand_disabled, sso_disabled, trending_disabled (trading on behalf also: brand_inactive, client_inactive, trading_inactive, trading_denied).
not_found / user_not_found / account_not_found / symbol_not_found.
invalid_request with details.errors = { field: reason }.
curl -X POST "https://api.your-brand.com/api/external/v1/users/cust_10042/positions/1042/close" \
-H "X-Api-Key: $OCTOLIT_PARTNER_KEY"const res = await fetch("https://api.your-brand.com/api/external/v1/users/cust_10042/positions/1042/close", {
method: "POST",
headers: {
"X-Api-Key": process.env.OCTOLIT_PARTNER_KEY,
},
});
if (!res.ok) throw new Error(`POST failed: ${res.status} ${await res.text()}`);
const data = await res.json();
console.log(data);import os, requests
r = requests.request(
"POST",
"https://api.your-brand.com/api/external/v1/users/cust_10042/positions/1042/close",
headers={"X-Api-Key": os.environ["OCTOLIT_PARTNER_KEY"]},
timeout=10,
)
r.raise_for_status()
print(r.json())<?php
$ch = curl_init("https://api.your-brand.com/api/external/v1/users/cust_10042/positions/1042/close");
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"X-Api-Key: " . getenv("OCTOLIT_PARTNER_KEY"),
],
]);
$data = json_decode(curl_exec($ch), true);
curl_close($ch);
print_r($data);using var http = new HttpClient();
using var req = new HttpRequestMessage(HttpMethod.Post, "https://api.your-brand.com/api/external/v1/users/cust_10042/positions/1042/close");
req.Headers.Add("X-Api-Key", Environment.GetEnvironmentVariable("OCTOLIT_PARTNER_KEY"));
using var res = await http.SendAsync(req);
res.EnsureSuccessStatusCode();
Console.WriteLine(await res.Content.ReadAsStringAsync());var client = HttpClient.newHttpClient();
var req = HttpRequest.newBuilder(URI.create("https://api.your-brand.com/api/external/v1/users/cust_10042/positions/1042/close"))
.header("X-Api-Key", System.getenv("OCTOLIT_PARTNER_KEY"))
.method("POST", HttpRequest.BodyPublishers.noBody())
.build();
var res = client.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println(res.statusCode() + " " + res.body());var body io.Reader
req, err := http.NewRequest("POST", "https://api.your-brand.com/api/external/v1/users/cust_10042/positions/1042/close", body)
if err != nil {
log.Fatal(err)
}
req.Header.Set("X-Api-Key", os.Getenv("OCTOLIT_PARTNER_KEY"))
res, err := http.DefaultClient.Do(req)
if err != nil {
log.Fatal(err)
}
defer res.Body.Close()
out, _ := io.ReadAll(res.Body)
fmt.Println(res.StatusCode, string(out))var req = URLRequest(url: URL(string: "https://api.your-brand.com/api/external/v1/users/cust_10042/positions/1042/close")!)
req.httpMethod = "POST"
req.setValue(ProcessInfo.processInfo.environment["OCTOLIT_PARTNER_KEY"], forHTTPHeaderField: "X-Api-Key")
let (data, response) = try await URLSession.shared.data(for: req)
print((response as! HTTPURLResponse).statusCode, String(decoding: data, as: UTF8.self))val client = OkHttpClient()
val req = Request.Builder()
.url("https://api.your-brand.com/api/external/v1/users/cust_10042/positions/1042/close")
.header("X-Api-Key", System.getenv("OCTOLIT_PARTNER_KEY"))
.method("POST", null)
.build()
client.newCall(req).execute().use { res ->
println("${res.code} ${res.body?.string()}")
} {
"code": "placed",
"client_order_id": "ord-2026-0001",
"order": {
"id": 1042,
"account_id": 55,
"symbol": "EURUSD",
"status": "open",
"side": "buy",
"order_type": 1,
"amount": "100.00",
"trade_amount": "string",
"units": 10000,
"lot_size": 1.5,
"leverage": 100,
"open_price": "string",
"stop_loss": "string",
"take_profit": "string",
"profit": "19.00",
"commission": "0.00",
"swap": "-0.12",
"market": "string",
"opened_at": "2026-11-11T09:30:00Z",
"closed_at": "2026-11-11T10:05:12Z",
"closed_by": "string",
"created_at": "2026-11-11T09:30:00.000000Z"
},
"position": {
"id": 1042,
"account_id": 55,
"symbol": "EURUSD",
"status": "open",
"side": "buy",
"order_type": 1,
"amount": "100.00",
"trade_amount": "string",
"units": 10000,
"lot_size": 1.5,
"leverage": 100,
"open_price": "string",
"stop_loss": "string",
"take_profit": "string",
"profit": "19.00",
"commission": "0.00",
"swap": "-0.12",
"market": "string",
"opened_at": "2026-11-11T09:30:00Z",
"closed_at": "2026-11-11T10:05:12Z",
"closed_by": "string",
"created_at": "2026-11-11T09:30:00.000000Z"
}
}