curl --request POST \
--url https://staging.apimonaco.xyz/api/v1/positions/batch-close-all \
--header 'Content-Type: application/json' \
--header 'X-Monaco-Signature: <api-key>' \
--data '
{
"tradingPairId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"slippageToleranceBps": 123
}
'import requests
url = "https://staging.apimonaco.xyz/api/v1/positions/batch-close-all"
payload = {
"tradingPairId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"slippageToleranceBps": 123
}
headers = {
"X-Monaco-Signature": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-Monaco-Signature': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
tradingPairId: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
slippageToleranceBps: 123
})
};
fetch('https://staging.apimonaco.xyz/api/v1/positions/batch-close-all', 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://staging.apimonaco.xyz/api/v1/positions/batch-close-all",
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([
'tradingPairId' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'slippageToleranceBps' => 123
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Monaco-Signature: <api-key>"
],
]);
$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://staging.apimonaco.xyz/api/v1/positions/batch-close-all"
payload := strings.NewReader("{\n \"tradingPairId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"slippageToleranceBps\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Monaco-Signature", "<api-key>")
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://staging.apimonaco.xyz/api/v1/positions/batch-close-all")
.header("X-Monaco-Signature", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"tradingPairId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"slippageToleranceBps\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://staging.apimonaco.xyz/api/v1/positions/batch-close-all")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Monaco-Signature"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"tradingPairId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"slippageToleranceBps\": 123\n}"
response = http.request(request)
puts response.read_body{
"totalRequested": 123,
"totalClosed": 123,
"totalFailed": 123,
"results": [
{
"positionId": "<string>",
"closeOrderId": "<string>",
"status": "<string>",
"submittedQuantity": "<string>",
"error": {
"code": "<string>",
"message": "<string>"
}
}
]
}Post apiv1positionsbatch close all
Close all open positions in a single batch (“panic close”).
Submits a MARKET reduce-only close for every open position owned by the
caller, optionally filtered to a single trading pair. Best-effort and
partial: each position closes independently and per-position failures are
reported in results rather than aborting the batch. Each close draws
one item from the risk-reduction rate limit (an empty call draws one).
The first 100 are charged before anything is sent: over budget, the
whole call is refused with 429 and nothing is closed. Past 100 open
positions the rest are charged 100 at a time as the call reaches them,
and those the budget does not cover are not sent: they come back in
results with RATE_LIMIT_EXCEEDED, to be retried.
curl --request POST \
--url https://staging.apimonaco.xyz/api/v1/positions/batch-close-all \
--header 'Content-Type: application/json' \
--header 'X-Monaco-Signature: <api-key>' \
--data '
{
"tradingPairId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"slippageToleranceBps": 123
}
'import requests
url = "https://staging.apimonaco.xyz/api/v1/positions/batch-close-all"
payload = {
"tradingPairId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"slippageToleranceBps": 123
}
headers = {
"X-Monaco-Signature": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-Monaco-Signature': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
tradingPairId: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
slippageToleranceBps: 123
})
};
fetch('https://staging.apimonaco.xyz/api/v1/positions/batch-close-all', 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://staging.apimonaco.xyz/api/v1/positions/batch-close-all",
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([
'tradingPairId' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'slippageToleranceBps' => 123
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Monaco-Signature: <api-key>"
],
]);
$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://staging.apimonaco.xyz/api/v1/positions/batch-close-all"
payload := strings.NewReader("{\n \"tradingPairId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"slippageToleranceBps\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Monaco-Signature", "<api-key>")
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://staging.apimonaco.xyz/api/v1/positions/batch-close-all")
.header("X-Monaco-Signature", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"tradingPairId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"slippageToleranceBps\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://staging.apimonaco.xyz/api/v1/positions/batch-close-all")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Monaco-Signature"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"tradingPairId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"slippageToleranceBps\": 123\n}"
response = http.request(request)
puts response.read_body{
"totalRequested": 123,
"totalClosed": 123,
"totalFailed": 123,
"results": [
{
"positionId": "<string>",
"closeOrderId": "<string>",
"status": "<string>",
"submittedQuantity": "<string>",
"error": {
"code": "<string>",
"message": "<string>"
}
}
]
}Authorizations
Ed25519 session-key request signing. Every authenticated request carries three headers: X-Monaco-PublicKey (64-char lowercase-hex session public key), X-Monaco-Timestamp (Unix milliseconds, within 30s of server time), and X-Monaco-Signature (hex ed25519 signature). The signature is over METHOD\npath?query\ntimestamp_ms\nSHA256_hex(body), where the body hash is the SHA-256 of the empty byte string when there is no body. Obtain the session keypair from POST /api/v1/auth/challenge followed by POST /api/v1/auth/verify.
Body
Response
OK
Number of open positions the batch attempted to close.
Number of positions whose close order was accepted by the matching engine (SUCCESS, PARTIAL, or PENDING).
Number of positions whose close failed (validation, lookup, or a rejected close order).
Show child attributes
Show child attributes
Was this page helpful?

