> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bayse.markets/llms.txt
> Use this file to discover all available pages before exploring further.

# Cancel order

> Cancel an open or partially filled CLOB order

## Authentication

Write authentication required — `X-Public-Key`, `X-Timestamp`, and `X-Signature` headers. See the [Authentication guide](/authentication).

## Path parameters

<ParamField path="orderId" type="string" required>
  UUID of the order to cancel.
</ParamField>

## Example request

<CodeGroup>
  ```bash cURL theme={null}
  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}"
  ```

  ```javascript Node.js theme={null}
  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,
    },
  });
  ```

  ```python Python theme={null}
  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,
      },
  )
  ```

  ```go Go theme={null}
  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)
  ```
</CodeGroup>

## Response

<ResponseExample>
  ```json 200 OK theme={null}
  {
    "message": "Order cancelled"
  }
  ```

  ```json 404 Not Found theme={null}
  {
    "error": "not_found",
    "message": "Order not found",
    "statusCode": 404
  }
  ```
</ResponseExample>

<Note>
  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.
</Note>
