API documentation
Sign in

Order sessions and recovery

Binding an order's outcome to a session so it survives a dropped connection, and the three ways to recover one.

An order can outlive the connection that placed it. The connection can drop between the moment we accept the order and the moment its outcome is known, and nothing you do on your side changes what has already gone to market.

autoSubscribe selects how the outcome reaches you, per order.

Without it, the order is bound to the connection: you get exactly one frame, the terminal result, and if the connection drops before it arrives the outcome is gone from that socket. With it, the order is bound to your session: you get an immediate PENDING acknowledgement, the terminal arrives as a separate message, and it is redelivered on every reconnect until you acknowledge it.

A session is named by the sessionId query parameter on the WebSocket handshake:

wss://<host>/zm/ws/ws-client?token=<one-shot token>&sessionId=<your id>

Reconnecting under the same sessionId is what makes recovery work. Omitting it is legal — the gateway mints one — but a minted id is new on every connect, so nothing is ever redelivered to it. If you want recovery, choose your own sessionId and reuse it.

sessionId must be 1 to 64 characters and must not contain /, whitespace or control characters. A handshake carrying an invalid one is refused: you receive a single error frame and the socket closes. Connecting again with the same sessionId closes any earlier connection of yours still holding it, so exactly one socket is the delivery target.

Recovering an outcome

Three routes, in the order you would reach for them:

  1. Reconnect under the same sessionId. Every subscribed order whose terminal has been recorded is pushed again.
  2. Read one order by clientRequestId.
  3. List your orders, optionally narrowed to one session.

Records are held for 24 hours, and that window is not extended by reading them. Beyond it, an order that executed is in your trades.

Redelivery is at-least-once — deduplicate on transactionId. A subscribed order is re-pushed on every reconnect until you unsubscribe from it, not just the first one after the drop. Sending orderUnsubscribe once you have the terminal is how you stop it.

Order request

Sent as messageType: "order".

FieldTypeRequiredNotes
messageTypestringRequiredAlways order on this message. It is how the gateway picks the message type, and a request without it is rejected
instrumentstringRequiredThe pair, as TRADED.SETTLEMENT. Source declares a default, but it is a placeholder and is not a usable order
quoteIdstringRequiredThe quote you are accepting, from the price stream. It must be yours, and it expires five minutes after issue
quoteIdxintegerNot read on an order
apiKeystringTaken from the authenticated connection. Anything you send is discarded
accountGrpUuidstringConditionalThe account group to trade for. Required when your credential covers more than one
sideOrderSideBUY or SELL. A trade collecting from a registered sender must be SELL
pricestringNot read on an order; the price is the quote's
quantitystringHow much to trade. Must not exceed the quantity on the quote. Left empty, the quote's own quantity is used
currencystringWhich side of the pair quantity is expressed in. Must be one of the two currencies in instrument
quantityAmountTypeQuantityAmountTypeWhether quantity is the traded or the settlement amount
transactionIdstringAssigned by the gateway. Anything you send is discarded
clientRequestIdstringYour own reference, echoed on every response and the key you look the order up by later. Without one you cannot read the order back individually. Maximum 64 characters
appropriateLeveldecimalNot read on an order
startTimestampintegerNot read on an order
lastTimestampintegerNot read on an order
userSpreaddecimalNot read on an order
holidaySpreaddecimalNot read on an order
treasurySpreaddecimalNot read on an order
totalSpreaddecimalNot read on an order
tenorstringSettlement tenor, matching the quote
settleDatestringNot read on an order; the settlement date comes from the quote
signedIntentSignedIntentTamper-evident signature over the order parameters. See signed order intent
paymentReasonstringConditionalRequired for a third-party transfer, and must be one of the reasons configured for you
_beneficiaryDetailsBeneficiaryDetailsThird-party delivery destination, set by the gateway from the quote's own beneficiary. Anything you send is discarded — the destination is fixed when you subscribe. Note the leading underscore — that is the field name on the wire
_senderDetailsSenderDetailsThird-party collection source, set by the gateway from the quote's own sender. Anything you send is discarded. Note the leading underscore
idempotencyKeystringGuards against a retry placing a second order. Maximum 64 characters, and it may not contain whitespace or :
autoSubscribebooleanSend true to bind the outcome to your session and make it recoverable. Left false, the outcome is delivered once on this connection and not retained for redelivery
sessionIdstringIgnored. The session comes from the connection; a different value here is overridden, and an invalid one rejects the order
chanIdstringSet by the gateway to your connection identifier. Anything you send is discarded
authUserUUIDstringSet by the gateway from your credential. Anything you send is discarded

SignedIntent

The optional signature over an order's parameters.

FieldTypeRequiredNotes
payloadstringRequiredBase64 of a JSON object carrying quoteId, side, quantity and timestamp
signaturestringRequiredBase64 RS256 signature over payload, made with the private key whose public half you registered

BeneficiaryDetails

Where a third-party delivery is sent. Echoed as _beneficiaryDetails on the order — the leading underscore is the field name on the wire. It comes from the quote, not from the order, so there is nothing here for you to send. Chosen on the price channel.

FieldTypeNotes
beneficiaryIdstringThe registered beneficiary to deliver to
networkIdstringThe delivery network resolved for the beneficiary
payoutCurrencystringThe currency the beneficiary is paid in

SenderDetails

Where a third-party collection comes from. Echoed as _senderDetails on the order, from the quote rather than from anything you send. Chosen on the price channel, and a collection must be a SELL.

FieldTypeNotes
senderIdstringThe registered sender to collect from
networkIdstringThe collection network
payinCurrencystringThe currency the sender pays in. Must be the traded currency of the instrument

OrderSide

ValueMeaning
BUYBuy the traded currency of the instrument
SELLSell the traded currency. A trade collecting from a registered sender must be a sell

QuantityAmountType

Which side of the pair quantity is measured in. Sent as the name, not a number.

ValueMeaning
TRADEDquantity is an amount of the traded currency
SETTLEMENTquantity is an amount of the settlement currency

Order response

Sent as messageType: "order". A subscribed order produces two of these: the PENDING acknowledgement, then the terminal.

FieldTypeNotes
messageTypestringAlways order
messagestringHuman-readable detail accompanying code
codestringSet when something went wrong; see trade error codes
instrumentstringThe pair traded
sideOrderSideBUY or SELL
pricestringThe executed price
quantitystringThe executed quantity
clientRequestIdstringYour own reference, echoed back
orderStatusstringThe outcome so far. PENDING on the acknowledgement of a subscribed order; afterwards a terminal value. Treat it as an open set of strings rather than a fixed list — it carries both settlement outcomes and finer-grained lifecycle values
quoteIdstringThe quote the order was placed against
transactionIdstringThe gateway's identifier for the order, and the key to deduplicate redeliveries on
tenorstringSettlement tenor
settleDatestringSettlement date
subscriptionStatusSubscriptionStatusPresent only on a subscribed order, and absent from the message entirely otherwise
sessionIdstringThe session the outcome is bound to. Present only on a subscribed order, and absent otherwise — this is where you learn the id when the gateway minted one for you
chanIdstringThe connection the message was delivered on
timestampintegerWhen the gateway produced this message, in milliseconds. Not the time of any order event

Unsubscribe request

Sent as messageType: "orderUnsubscribe". Acknowledges a terminal you have received and stops it being redelivered.

FieldTypeRequiredNotes
messageTypestringRequiredAlways orderUnsubscribe
transactionIdstringRequiredThe order to stop redelivering, from the response you received
sessionIdstringIgnored. The order is found by transactionId within your own records
chanIdstringSet by the gateway. Anything you send is discarded
authUserUUIDstringSet by the gateway from your credential. Anything you send is discarded

Unsubscribe response

FieldTypeNotes
messageTypestringAlways orderUnsubscribe
successbooleanWhether redelivery has stopped. Unsubscribing an order that was already unsubscribed succeeds
messagestringHuman-readable detail. An order still in flight is refused here — unsubscribing is only allowed once a terminal result has been delivered, so that you cannot detach yourself from an outcome you have not seen
transactionIdstringThe order the response is about, echoed back
codestringSet when the request was refused
chanIdstringThe connection the message was delivered on
timestampintegerWhen the gateway produced this message, in milliseconds

SubscriptionStatus

Whether the outcome is still being redelivered to you. Independent of the order's own outcome — an order can be PENDING and NOT_SUBSCRIBED at once.

ValueMeaning
NOT_SUBSCRIBEDThe order was placed without autoSubscribe. Its outcome is not retained for redelivery, and this value never appears on a WebSocket message — you see it only when reading the order back over REST
SUBSCRIBEDThe outcome is bound to your session and will be redelivered on every reconnect until you unsubscribe or the 24-hour window passes
UNSUBSCRIBEDYou have acknowledged the outcome and redelivery has stopped

We use cookies to improve your experience and analyse site traffic. Cookie policy