Set TP/SL
curl --request POST \
--url https://api.worm.wtf/margin/positions/{pubkey}/tp-sl/ \
--header 'Content-Type: application/json' \
--data '
{
"take_profit_price": "<string>",
"stop_loss_price": "<string>"
}
'import requests
url = "https://api.worm.wtf/margin/positions/{pubkey}/tp-sl/"
payload = {
"take_profit_price": "<string>",
"stop_loss_price": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({take_profit_price: '<string>', stop_loss_price: '<string>'})
};
fetch('https://api.worm.wtf/margin/positions/{pubkey}/tp-sl/', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.worm.wtf/margin/positions/{pubkey}/tp-sl/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'take_profit_price' => '<string>',
'stop_loss_price' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.worm.wtf/margin/positions/{pubkey}/tp-sl/"
payload := strings.NewReader("{\n \"take_profit_price\": \"<string>\",\n \"stop_loss_price\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.worm.wtf/margin/positions/{pubkey}/tp-sl/")
.header("Content-Type", "application/json")
.body("{\n \"take_profit_price\": \"<string>\",\n \"stop_loss_price\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.worm.wtf/margin/positions/{pubkey}/tp-sl/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"take_profit_price\": \"<string>\",\n \"stop_loss_price\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"take_profit_price": "0.75",
"stop_loss_price": "0.58",
"state": "active",
"trigger_type": null,
"triggered_price": null,
"triggered_at": null
},
"meta": {},
"error": null
}
{
"data": null,
"meta": null,
"error": {
"code": -11,
"slug": "invalid_request_params",
"message": "Validation Error",
"details": []
}
}
{
"data": null,
"meta": null,
"error": {
"code": -12,
"slug": "authentication_failed",
"message": "Invalid signature",
"details": []
}
}
{
"data": null,
"meta": null,
"error": {
"code": -14,
"slug": "permission_denied",
"message": "You do not have permission to perform this action.",
"details": []
}
}
{
"data": null,
"meta": null,
"error": {
"code": -15,
"slug": "not_found",
"message": "Not found.",
"details": []
}
}
{
"data": null,
"meta": null,
"error": {
"code": 9201,
"slug": "hyperliquid_margin_tp_sl_not_supported",
"message": "Take-profit and stop-loss are not available for Hyperliquid margin positions on this API yet.",
"details": []
}
}
{
"data": null,
"meta": null,
"error": {
"code": -17,
"slug": "throttled",
"message": "Request was throttled.",
"details": []
}
}
{
"data": null,
"meta": null,
"error": {
"code": -3,
"slug": "internal_error",
"message": "An internal error occurred.",
"details": []
}
}
Margin
Set TP/SL
Create or update take-profit and stop-loss settings for a margin position.
POST
/
margin
/
positions
/
{pubkey}
/
tp-sl
/
Set TP/SL
curl --request POST \
--url https://api.worm.wtf/margin/positions/{pubkey}/tp-sl/ \
--header 'Content-Type: application/json' \
--data '
{
"take_profit_price": "<string>",
"stop_loss_price": "<string>"
}
'import requests
url = "https://api.worm.wtf/margin/positions/{pubkey}/tp-sl/"
payload = {
"take_profit_price": "<string>",
"stop_loss_price": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({take_profit_price: '<string>', stop_loss_price: '<string>'})
};
fetch('https://api.worm.wtf/margin/positions/{pubkey}/tp-sl/', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.worm.wtf/margin/positions/{pubkey}/tp-sl/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'take_profit_price' => '<string>',
'stop_loss_price' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.worm.wtf/margin/positions/{pubkey}/tp-sl/"
payload := strings.NewReader("{\n \"take_profit_price\": \"<string>\",\n \"stop_loss_price\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.worm.wtf/margin/positions/{pubkey}/tp-sl/")
.header("Content-Type", "application/json")
.body("{\n \"take_profit_price\": \"<string>\",\n \"stop_loss_price\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.worm.wtf/margin/positions/{pubkey}/tp-sl/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"take_profit_price\": \"<string>\",\n \"stop_loss_price\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"take_profit_price": "0.75",
"stop_loss_price": "0.58",
"state": "active",
"trigger_type": null,
"triggered_price": null,
"triggered_at": null
},
"meta": {},
"error": null
}
{
"data": null,
"meta": null,
"error": {
"code": -11,
"slug": "invalid_request_params",
"message": "Validation Error",
"details": []
}
}
{
"data": null,
"meta": null,
"error": {
"code": -12,
"slug": "authentication_failed",
"message": "Invalid signature",
"details": []
}
}
{
"data": null,
"meta": null,
"error": {
"code": -14,
"slug": "permission_denied",
"message": "You do not have permission to perform this action.",
"details": []
}
}
{
"data": null,
"meta": null,
"error": {
"code": -15,
"slug": "not_found",
"message": "Not found.",
"details": []
}
}
{
"data": null,
"meta": null,
"error": {
"code": 9201,
"slug": "hyperliquid_margin_tp_sl_not_supported",
"message": "Take-profit and stop-loss are not available for Hyperliquid margin positions on this API yet.",
"details": []
}
}
{
"data": null,
"meta": null,
"error": {
"code": -17,
"slug": "throttled",
"message": "Request was throttled.",
"details": []
}
}
{
"data": null,
"meta": null,
"error": {
"code": -3,
"slug": "internal_error",
"message": "An internal error occurred.",
"details": []
}
}
Path Parameters
string
required
The public key of the margin position.
Body Parameters
string
Take-profit trigger price.
string
Stop-loss trigger price.
The server decides which fields to update from which JSON keys appear in the body, not only non-null values. Include
take_profit_price and/or stop_loss_price keys to write those columns; you may set a value to null to clear that side. Omitting both keys returns a validation error.Take-profit and stop-loss are not supported for Hyperliquid margin positions on this API. Those positions return
501 Not Implemented with error code 9201 and a message explaining the limitation. TP/SL applies to Polymarket-routed margin positions when the market supports it.Response
object
TP/SL state payload.
Show Data fields
Show Data fields
string | null
Take-profit trigger price.
string | null
Stop-loss trigger price.
string
TP/SL lifecycle:
active, triggered, or cancelled.string | null
When triggered:
take_profit or stop_loss; otherwise null.string | null
Triggered price.
integer | null
When
state is triggered, unix seconds when the trigger fired; otherwise null.object
Empty object on success for this endpoint.
object | null
null on success. Error object on failed requests.{
"data": {
"take_profit_price": "0.75",
"stop_loss_price": "0.58",
"state": "active",
"trigger_type": null,
"triggered_price": null,
"triggered_at": null
},
"meta": {},
"error": null
}
{
"data": null,
"meta": null,
"error": {
"code": -11,
"slug": "invalid_request_params",
"message": "Validation Error",
"details": []
}
}
{
"data": null,
"meta": null,
"error": {
"code": -12,
"slug": "authentication_failed",
"message": "Invalid signature",
"details": []
}
}
{
"data": null,
"meta": null,
"error": {
"code": -14,
"slug": "permission_denied",
"message": "You do not have permission to perform this action.",
"details": []
}
}
{
"data": null,
"meta": null,
"error": {
"code": -15,
"slug": "not_found",
"message": "Not found.",
"details": []
}
}
{
"data": null,
"meta": null,
"error": {
"code": 9201,
"slug": "hyperliquid_margin_tp_sl_not_supported",
"message": "Take-profit and stop-loss are not available for Hyperliquid margin positions on this API yet.",
"details": []
}
}
{
"data": null,
"meta": null,
"error": {
"code": -17,
"slug": "throttled",
"message": "Request was throttled.",
"details": []
}
}
{
"data": null,
"meta": null,
"error": {
"code": -3,
"slug": "internal_error",
"message": "An internal error occurred.",
"details": []
}
}