Skip to content
MyStocks Developers
API v1

API v1

Current stable contract

Versioning policyRelease changelog
Sandbox console

Replace (modify) a resting order

Sub-Accounts & White-Label Retail KYC

PATCH

/users/{userId}/orders/{orderId}

Replace (modify) a resting order

Sandbox unsupportedreplaceUserOrder

Modifies a WORKING resting order (LIMIT / STOP / STOP_LIMIT) in place, keeping the same orderId. Supply any of limitPrice, stopPrice, quantity — the BUY escrow or SELL unit reservation is adjusted by the delta atomically. Prices are in the stock's LOCAL trading currency. Only WORKING resting orders can be modified — market orders (PENDING for automatic internal-book execution) and terminal orders return 409. Increasing a BUY escrow beyond the available wallet balance returns 400 INSUFFICIENT_FUNDS; increasing a SELL quantity beyond available units returns 409. Fires the order.replaced webhook and writes a REPLACE execution report. A unique Idempotency-Key header is required (this moves escrow).

Parameters

userIdstringpathRequired

Example: usr_abc123

orderIdstringpathRequired

Example: ord_abc123xyz

Headers

AuthorizationstringRequired

Bearer sk_sandbox_<your_key> for sandbox requests.

Idempotency-KeystringheaderRequired

Unique string that makes write calls safe to retry on network failure. Required for money movement, trading, KYC, subscriptions, and webhook creation. Deduplicated for 24 hours -- duplicate keys return the cached response. HTTP 409 if a concurrent request with the same key is still in progress.

Example: dep_user42_1743152580

Request body

limitPricenumber

New limit price in the stock's local currency (LIMIT / STOP_LIMIT).

Example: 21.5

stopPricenumber

New stop price in the stock's local currency (STOP / STOP_LIMIT).

Example: 20

quantitynumber

New order quantity. Converts a cashValue-sized order to quantity-sized.

Example: 150

Response fields

orderIdstring

Unique order ID. Use to poll status or cancel.

Example: "ord_abc123xyz"

symbolstring

Example: "SCOM.KE"

namestring

Example: "Safaricom PLC"

exchangestring

Example: "NSE"

orderTypeMARKET | LIMIT | STOP | STOP_LIMIT

Order type. MARKET orders are quote-gated; LIMIT/STOP/STOP_LIMIT rest as WORKING until triggered.

Example: "LIMIT"

limitPricenumber | null

Limit price in the stock's local currency (LIMIT / STOP_LIMIT only).

stopPricenumber | null

Stop price in the stock's local currency (STOP / STOP_LIMIT only).

cancelableboolean

Whether the order can be cancelled now (DELETE). True while PENDING or WORKING.

replaceableboolean

Whether the order can be modified now (PATCH). True only for a WORKING resting order.

typeBUY | SELL
statusPENDING | WORKING | PARTIALLY_FILLED | PROCESSING | COMPLETED | FILLED | REJECTED | CANCELLED | EXPIRED

PENDING after submission. WORKING = resting LIMIT/STOP/STOP_LIMIT order waiting for its trigger price (becomes PENDING on trigger). PARTIALLY_FILLED and FILLED are the canonical execution states. REJECTED, CANCELLED, and EXPIRED are terminal outcomes. PROCESSING is a legacy transition alias and COMPLETED is a v1 compatibility alias of FILLED; neither represents custody settlement. Settlement is tracked separately as PENDING, SETTLED, or FAILED.

quoteIdstring | null

Pre-trade quote ID consumed by this order.

quoteExpiresAtstring | null
quoteUsdPricenumber | null
clientOrderIdstring | null

Partner-supplied order reference.

omsStatusstring | null

Canonical OMS lifecycle status.

timeInForcestring | null
filledQuantitynumber
remainingQuantitynumber
averageFillPricenumber | null
executionVenuestring | null
lastExecutionReportIdstring | null
executionSlaunion

Live execution SLA clock for orders that have entered the PENDING dealing-desk queue. Null while a resting order is still WORKING.

quantityinteger
priceAtOrdernumber

Stock price in local currency at submission.

usdPriceAtOrdernumber

USD equivalent of priceAtOrder.

fxRateAtOrdernumber | null

Managed FX rate used for local-to-USD conversion at order submission.

fxSourcestring | null
fxRateAsOfstring | null
fxConversionunion
feenumber

Total fee in USD (base + partner markup).

baseFeenumber

MyStocks base broker fee (0.75% of gross).

partnerMarkupFeenumber

Your markup fee component. Zero if markupBps = 0.

totalAmountnumber

BUY: gross + fee. SELL: gross - fee.

currencystring

Example: "USD"

localCurrencystring

Example: "KES"

rejectionCodestring | null

Structured rejection code. Populated when status = REJECTED.

rejectionReasonstring | null

Free-text rejection detail provided by the MyStocks internal-book execution service. Populated when status = REJECTED.

cancelledAtstring | null
settledAtstring | null

Set when custody settlement completes; independent of the canonical FILLED execution state. Legacy completed records that pre-date this field return their immutable completion/creation timestamp as compatibility evidence.

createdAtstring
canonicalStatusPENDING | WORKING | PARTIALLY_FILLED | FILLED | REJECTED | CANCELLED | EXPIRED
settlementStatusPENDING | SETTLED | FAILED
orderLifecyclestring | null

EXPIRED for expiry; expiry is not a rejection.

cancelReasonstring | null
executionReportIdstring
escrowAdjustmentnumber

USD escrow delta for BUY orders (>0 debited, <0 refunded).

messagestring

Response codes

200Order modified. Escrow / reservation adjusted by the delta.
400Validation error, or insufficient funds to increase a BUY escrow.
409Order is not a WORKING resting order, or a concurrent change won the race.