Skip to main content
POST
/
v1
/
pm
/
orders
/
batch
/
amend
Batch amend orders
curl --request POST \
  --url https://relay.bayse.markets/v1/pm/orders/batch/amend \
  --header 'Content-Type: application/json' \
  --data '
{
  "items": [
    {
      "orderId": "<string>",
      "newPrice": 123,
      "newSize": 123
    }
  ]
}
'
{
  "engine": "CLOB",
  "results": [
    {
      "index": 0,
      "orderId": "f6a7b8c9-d0e1-2345-fabc-678901234567",
      "success": true,
      "order": {
        "id": "f6a7b8c9-d0e1-2345-fabc-678901234567",
        "marketId": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
        "userId": "9a8b7c6d-5e4f-3210-abcd-ef1234567890",
        "outcome": "YES",
        "side": "BUY",
        "orderType": "LIMIT",
        "type": "BUY",
        "status": "open",
        "amount": 7.50,
        "price": 0.50,
        "size": 15,
        "filledSize": 0,
        "remainingSize": 15,
        "avgFillPrice": 0,
        "fee": 0,
        "postOnly": false,
        "stpMode": "SKIP",
        "quantity": 0,
        "createdAt": "2026-05-12T17:33:21Z",
        "updatedAt": "2026-05-12T17:38:52Z"
      }
    },
    {
      "index": 1,
      "orderId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "success": false,
      "error": {
        "code": "INSUFFICIENT_BALANCE",
        "message": "Insufficient balance"
      }
    }
  ],
  "summary": { "total": 2, "succeeded": 1, "failed": 1 }
}

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.

Modify up to 20 CLOB orders in a single request. Each item names an existing orderId you own and supplies the new price, the new total size, or both. Orders may belong to different markets and events. CLOB-only: any AMM order is rejected per-item with UNSUPPORTED_ENGINE. Amend is the natural complement to place/cancel for market makers running cancel-and-replace ladders. It mutates an order in place — preserving time priority when possible — instead of cancelling and re-placing. See the Batch orders concept page for limits, semantics, and rate-limit behavior.

Authentication

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

Headers

Idempotency-Key
string
Optional. 1–255 characters of [A-Za-z0-9_-]. Retries within 24 hours that share the same key, body, and route replay the original response with Idempotent-Replayed: true. A retry with the same key but a different body is rejected with 422. A concurrent retry (sent while the first is still in flight) is rejected with 409 — back off briefly and retry once the first call has finished. Transient responses (5xx, 429, 408) are not cached, so you can recover by retrying.

Request body

items
array
required
1–20 amend items. Each item is processed independently — one bad item does not abort the others.

Self-trade prevention

Self-trade prevention on amend is a fixed server policy: always CANCEL_OLDEST. If the amend would put the order in a position that crosses a same-user resting order, the resting crosser is cancelled and the amend proceeds.
  • The order’s resting stpMode (set at placement) is not consulted for amend — it governs matching-time self-cross behavior on incoming orders, which is a different event from the amend itself.
  • Orders being amended in the same batch are automatically excluded from the cancel set, so simultaneous amends that transiently cross don’t kill each other.
  • If you want an amend to fail rather than cancel a crosser, cancel + re-place instead of amending.

Example request

PUBLIC_KEY="pk_live_abcdef123456"
SECRET_KEY="sk_live_secret789xyz"
TIMESTAMP=$(date +%s)
METHOD="POST"
URL_PATH="/v1/pm/orders/batch/amend"
BODY='{"items":[{"orderId":"f6a7b8c9-d0e1-2345-fabc-678901234567","newPrice":0.50,"newSize":15},{"orderId":"a1b2c3d4-e5f6-7890-abcd-ef1234567890","newPrice":0.40,"newSize":8}]}'

BODY_HASH=$(printf '%s' "$BODY" | openssl dgst -sha256 -hex 2>/dev/null | sed 's/.*= //')
PAYLOAD="${TIMESTAMP}.${METHOD}.${URL_PATH}.${BODY_HASH}"
SIGNATURE=$(printf '%s' "$PAYLOAD" | openssl dgst -sha256 -hmac "$SECRET_KEY" -binary | base64)

curl -X POST "https://relay.bayse.markets${URL_PATH}" \
  -H "X-Public-Key: ${PUBLIC_KEY}" \
  -H "X-Timestamp: ${TIMESTAMP}" \
  -H "X-Signature: ${SIGNATURE}" \
  -H "Idempotency-Key: 9d3f2c0e-7b1a-4e5d-9f80-3a8b1c2d4e5f" \
  -H "Content-Type: application/json" \
  -d "$BODY"

Response

engine
string
Always CLOB for batch endpoints today.
results
array
Per-item outcomes, in the same order as the request.
summary
object
{
  "engine": "CLOB",
  "results": [
    {
      "index": 0,
      "orderId": "f6a7b8c9-d0e1-2345-fabc-678901234567",
      "success": true,
      "order": {
        "id": "f6a7b8c9-d0e1-2345-fabc-678901234567",
        "marketId": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
        "userId": "9a8b7c6d-5e4f-3210-abcd-ef1234567890",
        "outcome": "YES",
        "side": "BUY",
        "orderType": "LIMIT",
        "type": "BUY",
        "status": "open",
        "amount": 7.50,
        "price": 0.50,
        "size": 15,
        "filledSize": 0,
        "remainingSize": 15,
        "avgFillPrice": 0,
        "fee": 0,
        "postOnly": false,
        "stpMode": "SKIP",
        "quantity": 0,
        "createdAt": "2026-05-12T17:33:21Z",
        "updatedAt": "2026-05-12T17:38:52Z"
      }
    },
    {
      "index": 1,
      "orderId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "success": false,
      "error": {
        "code": "INSUFFICIENT_BALANCE",
        "message": "Insufficient balance"
      }
    }
  ],
  "summary": { "total": 2, "succeeded": 1, "failed": 1 }
}

Per-item error codes

CodeMeaningCaller action
INSUFFICIENT_BALANCEWallet balance is too low for the BID amend’s additional USD/NGN lockReduce newSize or newPrice, or top up the wallet, or fire a cancel batch first to free funds
INSUFFICIENT_SHARESFree share balance is too low for the ASK amend’s additional shares lockReduce newSize, or cancel another ASK first to free shares
NOT_FOUNDOrder not owned by the caller, or already terminal (filled / cancelled / expired / rejected)Check the order’s current status; amend works only while open or partial_filled
MARKET_CLOSEDMarket is not OPEN (paused, closed, or resolved)Wait for the market to reopen, or cancel the order instead
UNSUPPORTED_ENGINEOrder belongs to an LMSR / AMM marketCancel and re-place to change price/size on AMM markets
DUPLICATE_ORDER_IDThe same orderId appears more than once in itemsDeduplicate the request before retrying
INTERNALUnexpected upstream errorRetry; if persistent, contact support

Order ordering convention

A typical cancel-and-replace cycle uses three sibling calls in this order:
  1. DELETE /v1/pm/orders/batch — cancel stale orders (frees locked capital and shares).
  2. POST /v1/pm/orders/batch/amend — modify in-place orders (uses the freshly freed capacity).
  3. POST /v1/pm/orders/batch — place new orders (uses what remains).
Funding rejections are evaluated per-item against the wallet’s current state at the time the amend reaches the matching engine. By cancelling first you give your amend batch the best chance of clearing for size-up / price-up changes. The amend itself does not aggregate releases ahead of debits within the batch; you’ll get an INSUFFICIENT_BALANCE per item that can’t fit even though the batch’s net delta might.
Batch amend charges one rate-limit token per item against your write rate-limit bucket — a 20-item amend costs 20 tokens. Over-budget batches are rejected with 429 before any amends reach the matching engine. See Rate limits.
Amend preserves time priority when the new (price, size) is unchanged or shrunk at the same price level. Price changes (up or down) move the order to the new tail of the new level, same as a cancel-and-replace.