Cancel All Orders
curl --request POST \
--url https://api-options.sandbox.rails.xyz/v1/matching/orders/cancel-all \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"clientRequestId": "c0a0d2d0-6b1e-4f3a-8d2b-5e7f9a1b2c3d",
"contract": "BTC-7FEB26-100000-C"
}
'import requests
url = "https://api-options.sandbox.rails.xyz/v1/matching/orders/cancel-all"
payload = {
"clientRequestId": "c0a0d2d0-6b1e-4f3a-8d2b-5e7f9a1b2c3d",
"contract": "BTC-7FEB26-100000-C"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
clientRequestId: 'c0a0d2d0-6b1e-4f3a-8d2b-5e7f9a1b2c3d',
contract: 'BTC-7FEB26-100000-C'
})
};
fetch('https://api-options.sandbox.rails.xyz/v1/matching/orders/cancel-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://api-options.sandbox.rails.xyz/v1/matching/orders/cancel-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([
'clientRequestId' => 'c0a0d2d0-6b1e-4f3a-8d2b-5e7f9a1b2c3d',
'contract' => 'BTC-7FEB26-100000-C'
]),
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://api-options.sandbox.rails.xyz/v1/matching/orders/cancel-all"
payload := strings.NewReader("{\n \"clientRequestId\": \"c0a0d2d0-6b1e-4f3a-8d2b-5e7f9a1b2c3d\",\n \"contract\": \"BTC-7FEB26-100000-C\"\n}")
req, _ := http.NewRequest("POST", 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.post("https://api-options.sandbox.rails.xyz/v1/matching/orders/cancel-all")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"clientRequestId\": \"c0a0d2d0-6b1e-4f3a-8d2b-5e7f9a1b2c3d\",\n \"contract\": \"BTC-7FEB26-100000-C\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-options.sandbox.rails.xyz/v1/matching/orders/cancel-all")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"clientRequestId\": \"c0a0d2d0-6b1e-4f3a-8d2b-5e7f9a1b2c3d\",\n \"contract\": \"BTC-7FEB26-100000-C\"\n}"
response = http.request(request)
puts response.read_body{
"action": "cancelAll",
"clientRequestId": "c0a0d2d0-6b1e-4f3a-8d2b-5e7f9a1b2c3d",
"contract": "BTC-7FEB26-100000-C",
"count": 2,
"cancels": [
{
"queued": true,
"accepted": false,
"body": "order queued, pending acceptance",
"action": "cancel",
"messageId": "1770000000000-0",
"clientRequestId": "2b6c8e1a-0d4f-4e7b-9c3a-1f5d7e9b0a2c",
"contract": "BTC-7FEB26-100000-C",
"orderId": "01JRQM8H5XYZABCDEFGHJKMNPQ"
},
{
"queued": true,
"accepted": false,
"body": "order queued, pending acceptance",
"action": "cancel",
"messageId": "1770000000000-1",
"clientRequestId": "7d3e5f1b-2a4c-4b6d-8e0f-9a1b3c5d7e9f",
"contract": "BTC-7FEB26-100000-C",
"orderId": "01JRQM8H5XYZABCDEFGHJKMNPR"
}
]
}{
"error": {
"slug": "BAD_REQUEST",
"code": "0006"
},
"message": "clientRequestId must be a UUID"
}{
"error": {
"slug": "UNAUTHORIZED",
"code": "0001"
},
"message": "unauthorized"
}{
"error": {
"slug": "FORBIDDEN",
"code": "0008"
},
"message": "read-only token cannot create orders"
}{
"error": {
"slug": "SERVICE_UNAVAILABLE",
"code": "0004"
},
"message": "matching service unavailable"
}{
"error": {
"slug": "SERVICE_UNAVAILABLE",
"code": "0004"
},
"message": "matching service timed out"
}Orders
Cancel All Orders
Queue a cancel for every open order, or every open order in one contract.
POST
/
v1
/
matching
/
orders
/
cancel-all
Cancel All Orders
curl --request POST \
--url https://api-options.sandbox.rails.xyz/v1/matching/orders/cancel-all \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"clientRequestId": "c0a0d2d0-6b1e-4f3a-8d2b-5e7f9a1b2c3d",
"contract": "BTC-7FEB26-100000-C"
}
'import requests
url = "https://api-options.sandbox.rails.xyz/v1/matching/orders/cancel-all"
payload = {
"clientRequestId": "c0a0d2d0-6b1e-4f3a-8d2b-5e7f9a1b2c3d",
"contract": "BTC-7FEB26-100000-C"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
clientRequestId: 'c0a0d2d0-6b1e-4f3a-8d2b-5e7f9a1b2c3d',
contract: 'BTC-7FEB26-100000-C'
})
};
fetch('https://api-options.sandbox.rails.xyz/v1/matching/orders/cancel-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://api-options.sandbox.rails.xyz/v1/matching/orders/cancel-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([
'clientRequestId' => 'c0a0d2d0-6b1e-4f3a-8d2b-5e7f9a1b2c3d',
'contract' => 'BTC-7FEB26-100000-C'
]),
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://api-options.sandbox.rails.xyz/v1/matching/orders/cancel-all"
payload := strings.NewReader("{\n \"clientRequestId\": \"c0a0d2d0-6b1e-4f3a-8d2b-5e7f9a1b2c3d\",\n \"contract\": \"BTC-7FEB26-100000-C\"\n}")
req, _ := http.NewRequest("POST", 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.post("https://api-options.sandbox.rails.xyz/v1/matching/orders/cancel-all")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"clientRequestId\": \"c0a0d2d0-6b1e-4f3a-8d2b-5e7f9a1b2c3d\",\n \"contract\": \"BTC-7FEB26-100000-C\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-options.sandbox.rails.xyz/v1/matching/orders/cancel-all")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"clientRequestId\": \"c0a0d2d0-6b1e-4f3a-8d2b-5e7f9a1b2c3d\",\n \"contract\": \"BTC-7FEB26-100000-C\"\n}"
response = http.request(request)
puts response.read_body{
"action": "cancelAll",
"clientRequestId": "c0a0d2d0-6b1e-4f3a-8d2b-5e7f9a1b2c3d",
"contract": "BTC-7FEB26-100000-C",
"count": 2,
"cancels": [
{
"queued": true,
"accepted": false,
"body": "order queued, pending acceptance",
"action": "cancel",
"messageId": "1770000000000-0",
"clientRequestId": "2b6c8e1a-0d4f-4e7b-9c3a-1f5d7e9b0a2c",
"contract": "BTC-7FEB26-100000-C",
"orderId": "01JRQM8H5XYZABCDEFGHJKMNPQ"
},
{
"queued": true,
"accepted": false,
"body": "order queued, pending acceptance",
"action": "cancel",
"messageId": "1770000000000-1",
"clientRequestId": "7d3e5f1b-2a4c-4b6d-8e0f-9a1b3c5d7e9f",
"contract": "BTC-7FEB26-100000-C",
"orderId": "01JRQM8H5XYZABCDEFGHJKMNPR"
}
]
}{
"error": {
"slug": "BAD_REQUEST",
"code": "0006"
},
"message": "clientRequestId must be a UUID"
}{
"error": {
"slug": "UNAUTHORIZED",
"code": "0001"
},
"message": "unauthorized"
}{
"error": {
"slug": "FORBIDDEN",
"code": "0008"
},
"message": "read-only token cannot create orders"
}{
"error": {
"slug": "SERVICE_UNAVAILABLE",
"code": "0004"
},
"message": "matching service unavailable"
}{
"error": {
"slug": "SERVICE_UNAVAILABLE",
"code": "0004"
},
"message": "matching service timed out"
}The same sweep is available over WebSocket as
cancelAllOrders on the Order Management Stream, so capital can be released from whichever connection is still up. See Releasing Capital on Disconnect for when to use which.Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json
Response
Always cancelAll.
Client-generated UUID for correlation.
Number of cancels queued.
One entry per queued cancel, newest first.
Show child attributes
Show child attributes
Contract name. Absent when every contract was swept.
Open orders the sweep did not queue a cancel for. Present only when the queue refused part-way.
Show child attributes
Show child attributes