Every order accepted by the OpenAPI is designated a unique OrderId
value that is used on Saxo's side for identification and tracing purposes. This ID is returned as a string-formatted number from the /orders
endpoint when a order is accepted. Example: "OrderId": "5002749003"
.
The /orders
endpoint accepts an optional field labeled ExternalReference
. This is a free-text string field that accepts up to 50 characters and can be set by the client to any value that is used externally to identify the submitted order. This value is kept alongside the OrderId
and included in the response from any endpoint that handles order data (such as port/v1/orders
and ENS messages). The submitted value is not checked for uniqueness, and orders will not be rejected if a repeated ExternalReference
is submitted. The client is responsible to ensure proper randomness to prevent duplicate references.
This feature is useful to map the ID used on Saxo's side against any value that is used by the client system to identify orders. In addition, in case specific orders require support/debugging, the API team can query for external references directly.
Example
In the below example, a market order for 10 shares of Apple Inc. is placed on the client's default account with the external reference configured as "My-Unique-Order-ID"
.
POST /trade/v2/orders
{
"Uic": 211,
"AssetType": "Stock",
"BuySell": "Buy",
"Amount": 10,
"OrderType": "Market",
"ManualOrder": true,
"ExternalReference": "My-Unique-Order-ID"
}
The response from the /orders
endpoint includes both the Saxo OrderId
, and the ExternalReference
submitted by the client:
200 - OK
{
"ExternalReference": "My-Unique-Order-ID",
"OrderId": "5002749333"
}
In addition, when the order is retrieved from the /port
endpoint, the same reference is returned:
GET /port/v1/orders/5002749333/details/?ClientKey=[...]
{
"Amount": 10,
"AssetType": "Stock",
"BuySell": "Buy",
"OrderType: "Market",
"Duration": {
"DurationType": "DayOrder"
},
"ExternalReference": "My-Unique-Order-ID",
"OrderId": "5002749333",
"Uic": 211,
...
}
More Resources