Skip to main content
DELETE
/
v1
/
pm
/
orders
/
{orderId}
Cancel order
curl --request DELETE \
  --url https://relay.bayse.markets/v1/pm/orders/{orderId}
import requests

url = "https://relay.bayse.markets/v1/pm/orders/{orderId}"

response = requests.delete(url)

print(response.text)
const options = {method: 'DELETE'};

fetch('https://relay.bayse.markets/v1/pm/orders/{orderId}', 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://relay.bayse.markets/v1/pm/orders/{orderId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"net/http"
"io"
)

func main() {

url := "https://relay.bayse.markets/v1/pm/orders/{orderId}"

req, _ := http.NewRequest("DELETE", url, nil)

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.delete("https://relay.bayse.markets/v1/pm/orders/{orderId}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://relay.bayse.markets/v1/pm/orders/{orderId}")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Delete.new(url)

response = http.request(request)
puts response.read_body
{
  "message": "Order cancelled"
}
{
  "error": "not_found",
  "message": "Order not found",
  "statusCode": 404
}

Authentication

Write authentication required — X-Public-Key, X-Timestamp, and X-Signature headers. See the Authentication guide.

Path parameters

orderId
string
required
UUID of the order to cancel.

Example request

PUBLIC_KEY="pk_live_abcdef123456"
SECRET_KEY="sk_live_secret789xyz"
TIMESTAMP=$(date +%s)
METHOD="DELETE"
URL_PATH="/v1/pm/orders/f6a7b8c9-d0e1-2345-fabc-678901234567"

# No body — bodyHash is empty, payload ends with a trailing dot
PAYLOAD="${TIMESTAMP}.${METHOD}.${URL_PATH}."
SIGNATURE=$(printf '%s' "$PAYLOAD" | openssl dgst -sha256 -hmac "$SECRET_KEY" -binary | base64)

curl -X DELETE "https://relay.bayse.markets${URL_PATH}" \
  -H "X-Public-Key: ${PUBLIC_KEY}" \
  -H "X-Timestamp: ${TIMESTAMP}" \
  -H "X-Signature: ${SIGNATURE}"
import crypto from 'crypto';

const publicKey = 'pk_live_abcdef123456';
const secretKey = 'sk_live_secret789xyz';
const timestamp = Math.floor(Date.now() / 1000);
const method = 'DELETE';
const path = '/v1/pm/orders/f6a7b8c9-d0e1-2345-fabc-678901234567';

// No body — bodyHash is empty
const payload = `${timestamp}.${method}.${path}.`;
const signature = crypto
  .createHmac('sha256', secretKey)
  .update(payload)
  .digest('base64');

await fetch(`https://relay.bayse.markets${path}`, {
  method,
  headers: {
    'X-Public-Key': publicKey,
    'X-Timestamp': timestamp.toString(),
    'X-Signature': signature,
  },
});
import hmac, hashlib, base64, time, requests

public_key = 'pk_live_abcdef123456'
secret_key = 'sk_live_secret789xyz'
timestamp = int(time.time())
method = 'DELETE'
path = '/v1/pm/orders/f6a7b8c9-d0e1-2345-fabc-678901234567'

# No body — bodyHash is empty
payload = f'{timestamp}.{method}.{path}.'
signature = base64.b64encode(
    hmac.new(secret_key.encode(), payload.encode(), hashlib.sha256).digest()
).decode()

requests.delete(
    f'https://relay.bayse.markets{path}',
    headers={
        'X-Public-Key': public_key,
        'X-Timestamp': str(timestamp),
        'X-Signature': signature,
    },
)
timestamp := time.Now().Unix()
method := "DELETE"
urlPath := "/v1/pm/orders/f6a7b8c9-d0e1-2345-fabc-678901234567"

// No body — bodyHash is empty
payload := fmt.Sprintf("%d.%s.%s.", timestamp, method, urlPath)
mac := hmac.New(sha256.New, []byte("sk_live_secret789xyz"))
mac.Write([]byte(payload))
signature := base64.StdEncoding.EncodeToString(mac.Sum(nil))

req, _ := http.NewRequest("DELETE", "https://relay.bayse.markets"+urlPath, nil)
req.Header.Set("X-Public-Key", "pk_live_abcdef123456")
req.Header.Set("X-Timestamp", strconv.FormatInt(timestamp, 10))
req.Header.Set("X-Signature", signature)
http.DefaultClient.Do(req)

Response

{
  "message": "Order cancelled"
}
{
  "error": "not_found",
  "message": "Order not found",
  "statusCode": 404
}
Only CLOB orders with status open or partial_filled can be cancelled. AMM orders execute instantly and cannot be cancelled — sell your shares to exit instead.