Atomically update position TP/SL orders
curl --request PUT \
--url https://developers.fundingperpetuals.com/v1/positions/{position_id}/exit-orders \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"expected_position_size": 123,
"expected_orders": [
{
"order_id": "<string>",
"price": 123,
"size": 123
}
],
"operations": [
{
"kind": "cancel",
"order_id": "<string>"
}
]
}
'import requests
url = "https://developers.fundingperpetuals.com/v1/positions/{position_id}/exit-orders"
payload = {
"expected_position_size": 123,
"expected_orders": [
{
"order_id": "<string>",
"price": 123,
"size": 123
}
],
"operations": [
{
"kind": "cancel",
"order_id": "<string>"
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
expected_position_size: 123,
expected_orders: [{order_id: '<string>', price: 123, size: 123}],
operations: [{kind: 'cancel', order_id: '<string>'}]
})
};
fetch('https://developers.fundingperpetuals.com/v1/positions/{position_id}/exit-orders', 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://developers.fundingperpetuals.com/v1/positions/{position_id}/exit-orders",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'expected_position_size' => 123,
'expected_orders' => [
[
'order_id' => '<string>',
'price' => 123,
'size' => 123
]
],
'operations' => [
[
'kind' => 'cancel',
'order_id' => '<string>'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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://developers.fundingperpetuals.com/v1/positions/{position_id}/exit-orders"
payload := strings.NewReader("{\n \"expected_position_size\": 123,\n \"expected_orders\": [\n {\n \"order_id\": \"<string>\",\n \"price\": 123,\n \"size\": 123\n }\n ],\n \"operations\": [\n {\n \"kind\": \"cancel\",\n \"order_id\": \"<string>\"\n }\n ]\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.put("https://developers.fundingperpetuals.com/v1/positions/{position_id}/exit-orders")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"expected_position_size\": 123,\n \"expected_orders\": [\n {\n \"order_id\": \"<string>\",\n \"price\": 123,\n \"size\": 123\n }\n ],\n \"operations\": [\n {\n \"kind\": \"cancel\",\n \"order_id\": \"<string>\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://developers.fundingperpetuals.com/v1/positions/{position_id}/exit-orders")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"expected_position_size\": 123,\n \"expected_orders\": [\n {\n \"order_id\": \"<string>\",\n \"price\": 123,\n \"size\": 123\n }\n ],\n \"operations\": [\n {\n \"kind\": \"cancel\",\n \"order_id\": \"<string>\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "<string>",
"account_id": "<string>",
"market_id": "<string>",
"provider": "<string>",
"symbol": "<string>",
"coin": "<string>",
"size": 123,
"entry_price": 123,
"leverage": 123,
"isolated_margin_extra": 123,
"opened_at": 123,
"liquidation_price": 123,
"closed_at": 123,
"size_decimals": 1,
"exit_price": 123,
"realized_pnl": 123,
"realized_margin_basis": 123,
"fees": 123,
"funding": 123
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"request_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"request_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"request_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"request_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"request_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"order_id": "<string>",
"rule_id": "<string>",
"details": {}
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"request_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
}Positions
Atomically update position TP/SL orders
Applies a stale-snapshot-guarded batch of place, modify, and cancel operations. New opposite-group legs can be paired as OCO orders.
PUT
/
v1
/
positions
/
{position_id}
/
exit-orders
Atomically update position TP/SL orders
curl --request PUT \
--url https://developers.fundingperpetuals.com/v1/positions/{position_id}/exit-orders \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"expected_position_size": 123,
"expected_orders": [
{
"order_id": "<string>",
"price": 123,
"size": 123
}
],
"operations": [
{
"kind": "cancel",
"order_id": "<string>"
}
]
}
'import requests
url = "https://developers.fundingperpetuals.com/v1/positions/{position_id}/exit-orders"
payload = {
"expected_position_size": 123,
"expected_orders": [
{
"order_id": "<string>",
"price": 123,
"size": 123
}
],
"operations": [
{
"kind": "cancel",
"order_id": "<string>"
}
]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
expected_position_size: 123,
expected_orders: [{order_id: '<string>', price: 123, size: 123}],
operations: [{kind: 'cancel', order_id: '<string>'}]
})
};
fetch('https://developers.fundingperpetuals.com/v1/positions/{position_id}/exit-orders', 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://developers.fundingperpetuals.com/v1/positions/{position_id}/exit-orders",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'expected_position_size' => 123,
'expected_orders' => [
[
'order_id' => '<string>',
'price' => 123,
'size' => 123
]
],
'operations' => [
[
'kind' => 'cancel',
'order_id' => '<string>'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"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://developers.fundingperpetuals.com/v1/positions/{position_id}/exit-orders"
payload := strings.NewReader("{\n \"expected_position_size\": 123,\n \"expected_orders\": [\n {\n \"order_id\": \"<string>\",\n \"price\": 123,\n \"size\": 123\n }\n ],\n \"operations\": [\n {\n \"kind\": \"cancel\",\n \"order_id\": \"<string>\"\n }\n ]\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.put("https://developers.fundingperpetuals.com/v1/positions/{position_id}/exit-orders")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"expected_position_size\": 123,\n \"expected_orders\": [\n {\n \"order_id\": \"<string>\",\n \"price\": 123,\n \"size\": 123\n }\n ],\n \"operations\": [\n {\n \"kind\": \"cancel\",\n \"order_id\": \"<string>\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://developers.fundingperpetuals.com/v1/positions/{position_id}/exit-orders")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"expected_position_size\": 123,\n \"expected_orders\": [\n {\n \"order_id\": \"<string>\",\n \"price\": 123,\n \"size\": 123\n }\n ],\n \"operations\": [\n {\n \"kind\": \"cancel\",\n \"order_id\": \"<string>\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "<string>",
"account_id": "<string>",
"market_id": "<string>",
"provider": "<string>",
"symbol": "<string>",
"coin": "<string>",
"size": 123,
"entry_price": 123,
"leverage": 123,
"isolated_margin_extra": 123,
"opened_at": 123,
"liquidation_price": 123,
"closed_at": 123,
"size_decimals": 1,
"exit_price": 123,
"realized_pnl": 123,
"realized_margin_basis": 123,
"fees": 123,
"funding": 123
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"request_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"request_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"request_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"request_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"request_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"order_id": "<string>",
"rule_id": "<string>",
"details": {}
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"request_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
}Authorizations
API key beginning with fp_live_.
Path Parameters
Body
application/json
Response
Exit orders updated.
Show child attributes
Show child attributes
⌘I