Submit test trade
Developer Platform, Sandbox & Key Management
/test-tools/trade
Submit test trade
createTestToolsTradePlaces a deterministic test trade without hitting a real exchange. Recommended: use the sandbox base URL with an sk_sandbox_ key. Set outcome to PENDING, FILL, PARTIAL_FILL, REJECT, CANCEL, or FAIL_SETTLEMENT; sandbox wallet reservations, holdings, execution records, and webhooks are updated consistently. A pending or partially filled order can be advanced with PATCH /test-tools/orders/{orderId}. The production base retains the older live-key integration tool for compatibility: Cheat codes for deterministic outcomes: | Quantity | Outcome | |----------|---------| | 100 | Auto-fills immediately (triggers trade.settled) | | 999 | Auto-rejects immediately (triggers trade.rejected) | | Any other | Enters PENDING state — use admin panel to settle | Formerly POST /sandbox/trade, which remains a supported alias.
Parameters
This endpoint has no path or query parameters.
Headers
AuthorizationstringRequiredBearer sk_sandbox_<your_key> for sandbox requests.
Idempotency-KeystringheaderRequiredUnique 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
symbolstringRequiredStock symbol (exchange-qualified or bare ticker).
Example: "SCOM.KE"
typeBUY | SELLRequiredOrder direction.
quantitynumberRequiredNumber of shares. On the sandbox base URL, use outcome for deterministic behavior. The legacy live-key test tool still accepts 100 = instant fill and 999 = instant rejection.
Example: 10
subAccountIdstringSub-account to trade on. BUY checks wallet and escrows; SELL checks held units. Omit to bypass all checks.
notestringFree-text note shown to the admin for labelling test scenarios.
unitPriceUsdnumberDeterministic execution price used by the isolated sandbox simulator.
outcomePENDING | FILL | PARTIAL_FILL | REJECT | CANCEL | FAIL_SETTLEMENTExplicit isolated-sandbox lifecycle outcome. Ignored by the legacy live-key test tool.
partialQuantitynumberRequired when outcome is PARTIAL_FILL; must be less than quantity.
Response fields
orderIdstringUnique order ID. Use to poll status or cancel.
Example: "ord_abc123xyz"
symbolstringExample: "SCOM.KE"
namestringExample: "Safaricom PLC"
exchangestringExample: "NSE"
orderTypeMARKET | LIMIT | STOP | STOP_LIMITOrder type. MARKET orders are quote-gated; LIMIT/STOP/STOP_LIMIT rest as WORKING until triggered.
Example: "LIMIT"
limitPricenumber | nullLimit price in the stock's local currency (LIMIT / STOP_LIMIT only).
stopPricenumber | nullStop price in the stock's local currency (STOP / STOP_LIMIT only).
cancelablebooleanWhether the order can be cancelled now (DELETE). True while PENDING or WORKING.
replaceablebooleanWhether the order can be modified now (PATCH). True only for a WORKING resting order.
typeBUY | SELLstatusPENDING | WORKING | PARTIALLY_FILLED | PROCESSING | COMPLETED | FILLED | REJECTED | CANCELLED | EXPIREDPENDING 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 | nullPre-trade quote ID consumed by this order.
quoteExpiresAtstring | nullquoteUsdPricenumber | nullclientOrderIdstring | nullPartner-supplied order reference.
omsStatusstring | nullCanonical OMS lifecycle status.
timeInForcestring | nullfilledQuantitynumberremainingQuantitynumberaverageFillPricenumber | nullexecutionVenuestring | nulllastExecutionReportIdstring | nullexecutionSlaunionLive execution SLA clock for orders that have entered the PENDING dealing-desk queue. Null while a resting order is still WORKING.
quantityintegerpriceAtOrdernumberStock price in local currency at submission.
usdPriceAtOrdernumberUSD equivalent of priceAtOrder.
fxRateAtOrdernumber | nullManaged FX rate used for local-to-USD conversion at order submission.
fxSourcestring | nullfxRateAsOfstring | nullfxConversionunionfeenumberTotal fee in USD (base + partner markup).
baseFeenumberMyStocks base broker fee (0.75% of gross).
partnerMarkupFeenumberYour markup fee component. Zero if markupBps = 0.
totalAmountnumberBUY: gross + fee. SELL: gross - fee.
currencystringExample: "USD"
localCurrencystringExample: "KES"
rejectionCodestring | nullStructured rejection code. Populated when status = REJECTED.
rejectionReasonstring | nullFree-text rejection detail provided by the MyStocks internal-book execution service. Populated when status = REJECTED.
cancelledAtstring | nullsettledAtstring | nullSet 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.
createdAtstringcanonicalStatusPENDING | WORKING | PARTIALLY_FILLED | FILLED | REJECTED | CANCELLED | EXPIREDsettlementStatusPENDING | SETTLED | FAILEDorderLifecyclestring | nullEXPIRED for expiry; expiry is not a rejection.
cancelReasonstring | nullResponse codes
201Test order placed.