# DXtrade API POST /accounts/{accountCode}/orders

Independent and unofficial. Not affiliated with or endorsed by any broker or platform named here. Educational only: nothing here is advice, and nothing here recommends a broker or a trade.

This is the markdown version of https://openbrokerapi.com/platforms/dxtrade/endpoints/post-account-orders, written from the same records as that page.

Risk warning: CFDs and spread bets are complex instruments and come with a high risk of losing money rapidly due to leverage. You can lose money on these products, and each provider publishes its own loss figure under FCA rules. You should consider whether you understand how they work and whether you can afford to take the high risk of losing your money. Automated and API trading can amplify losses through bugs, connectivity failures and runaway orders.

Place a market, limit or stop order, or a group of orders, on an account. The client gives each order a code of its own so a repeat is refused.

- Request: `POST /accounts/{accountCode}/orders`
- Group: Trading
- Status: verified. Source: [demo.dx.trade](https://demo.dx.trade/developers/#/DXtrade-REST-API), checked 2026-10-12.
- Official reference: https://demo.dx.trade/developers/#/DXtrade-REST-API?id=place-order

Note: Read on 12 Oct 2026 in the DXtrade REST API specification on DXtrade's developer portal. The portal draws its pages in the browser from Markdown files it also serves directly, and the Markdown file of this page (DXtrade-REST-API.md) is what was read, with the model files it includes. The portal writes each address after a base address it fills in from its own settings, which on this portal is https://demo.dx.trade/dxsca-web. A broker or firm that offers DXtrade hosts its own, so the path here is what follows that base. The page writes the placeholder in the address as {account code} and names the parameter accountCode or account code. This record uses accountCode. The specification says every request needs authentication unless it says otherwise, and this section says the Authorization header should be included, which is why it is recorded as required. The body fields are those of the Single Order Request model, with the model's own required and optional marks. The page also accepts an Order Group Request, which is not recorded here. The call is not idempotent: the page says an order code that already exists is refused with 409 and error code 100. The reply is an Order Response, whose orderId and updateOrderId are both marked required. The mock reply uses those names with invented values.

## Parameters

- `accountCode` (in path, type string, required): The account code, two strings joined by a colon in the form clearing:account, assigned by the platform. URL-encode it.
- `orderCode` (in body, type string, required): An identifier for the order, unique among the orders on the account. For a new order the client assigns it.
- `type` (in body, type string, required): One of: MARKET, LIMIT, STOP. It cannot be changed once the order is issued.
- `instrument` (in body, type string, required): The symbol of the instrument. It cannot be changed once the order is issued.
- `side` (in body, type string, required): One of: BUY, SELL.
- `quantity` (in body, type number, optional): Marked optional. The size in units, not lots. Left out or zero for a closing order tied to a position, which takes the position's size.
- `positionEffect` (in body, type string, optional): Marked optional. One of: OPEN, CLOSE. The model says it is required for position based trading.
- `positionCode` (in body, type string, optional): Marked optional. The position the order changes. Present when positionEffect is CLOSE and left out otherwise.
- `limitPrice` (in body, type number, optional): Marked optional. The price of a limit order. Absent for market and stop orders.
- `stopPrice` (in body, type number, optional): Marked optional. The price of a stop order. Absent for market and limit orders.
- `priceOffset` (in body, type number, optional): Marked optional. A price offset for a protection order, taken from the fill price of the order that triggers it. Needs priceLink.
- `priceLink` (in body, type string, optional): Marked optional. One of: TRIGGERED_STOP, TRIGGERED_LIMIT.
- `tif` (in body, type string, optional): Marked optional. Time in force. One of: GTC, DAY, GTD. The default depends on how the platform is set up.
- `expireDate` (in body, type string, optional): Marked optional. Expiry in UTC. Present when tif is GTD and left out otherwise.
- `metadata` (in body, type object, optional): Marked optional. Up to 32 key and value pairs of the client's own, stored and returned with the order.

### Authentication headers

- `Authorization` (type string, required): With token authentication, send DXAPI followed by the sessionToken from POST /login. With HMAC authentication the same header carries DXAPI with a principal, a timestamp and a hash, signed for each request as the specification describes. Placeholder only: never paste a real token into this site.

## Request

Written from the method, path and parameters recorded on this page. No demo host is recorded as a plain address for this API, so the samples read the base address from an environment variable. Not executed against a live or demo account. Credentials are read from environment variables on your own machine and are never entered on this site. The request builder at https://openbrokerapi.com/tools/request-builder writes these same snippets, from the same record.

This call takes a request body. The samples send it as JSON with a placeholder for each of the 4 body fields the record marks as required. Each placeholder has to be replaced with a real value before the request can succeed.

### Python

```python
# Set DXTRADE_BASE_URL, DXTRADE_SESSION_TOKEN as environment variables first. Never paste real values into code.
# DXTRADE_SESSION_TOKEN holds the Authorization header that POST /login returns.
# No demo host is recorded as a plain address for this API, so the base address is read from DXTRADE_BASE_URL.
# Replace each {placeholder}, "..." and 0 with a real value before running.
# Optional and not shown: body fields quantity, positionEffect, positionCode, limitPrice, stopPrice, priceOffset, priceLink, tif, expireDate, metadata.
import os
import requests

BASE_URL = os.environ["DXTRADE_BASE_URL"]
headers = {
    "Authorization": "DXAPI " + os.environ["DXTRADE_SESSION_TOKEN"],
}
body = {"orderCode": "...", "type": "...", "instrument": "...", "side": "..."}
resp = requests.post(BASE_URL + "/accounts/{accountCode}/orders", headers=headers, json=body, timeout=10)
resp.raise_for_status()
print(resp.json())
```

### JavaScript

```javascript
// Set DXTRADE_BASE_URL, DXTRADE_SESSION_TOKEN as environment variables first. Never paste real values into code.
// DXTRADE_SESSION_TOKEN holds the Authorization header that POST /login returns.
// No demo host is recorded as a plain address for this API, so the base address is read from DXTRADE_BASE_URL.
// Replace each {placeholder}, "..." and 0 with a real value before running.
// Optional and not shown: body fields quantity, positionEffect, positionCode, limitPrice, stopPrice, priceOffset, priceLink, tif, expireDate, metadata.
// Run as a module, for example a .mjs file, on a Node version that has fetch built in.
const BASE_URL = process.env.DXTRADE_BASE_URL;
const res = await fetch(BASE_URL + "/accounts/{accountCode}/orders", {
  method: "POST",
  headers: {
    "Authorization": "DXAPI " + process.env.DXTRADE_SESSION_TOKEN,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({"orderCode": "...", "type": "...", "instrument": "...", "side": "..."}),
});
if (!res.ok) throw new Error(`HTTP ${res.status}`);
console.log(await res.json());
```

### curl

```bash
# Set DXTRADE_BASE_URL, DXTRADE_SESSION_TOKEN as environment variables first. Never paste real values into code.
# DXTRADE_SESSION_TOKEN holds the Authorization header that POST /login returns.
# No demo host is recorded as a plain address for this API, so the base address is read from DXTRADE_BASE_URL.
# Replace each {placeholder}, "..." and 0 with a real value before running.
# Optional and not shown: body fields quantity, positionEffect, positionCode, limitPrice, stopPrice, priceOffset, priceLink, tif, expireDate, metadata.
curl -X POST "$DXTRADE_BASE_URL/accounts/{accountCode}/orders" \
  -H "Authorization: DXAPI $DXTRADE_SESSION_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"orderCode": "...", "type": "...", "instrument": "...", "side": "..."}'
```

## Response

A mock response. The values are invented, so check field names against the [official reference](https://demo.dx.trade/developers/#/DXtrade-REST-API?id=place-order).

```json
{
  "_mock": true,
  "orderId": 1,
  "updateOrderId": 1
}
```

## More on the DXtrade API

- [All DXtrade API endpoints](https://openbrokerapi.com/platforms/dxtrade/endpoints): 21 documented, grouped by what they do.
- [All DXtrade API error codes](https://openbrokerapi.com/errors/dxtrade)
- [DXtrade API page](https://openbrokerapi.com/platforms/dxtrade): The full record: access, authentication, limits and the source for each.
- [DXtrade API as an OpenAPI file](https://openbrokerapi.com/specs/dxtrade.json): Generated from these endpoint records. Independent and unofficial.

## Licence and how to cite

The records behind this page are all rights reserved. This file is the page itself, at its own address, in another format. It is not part of the CC BY 4.0 downloads listed at https://openbrokerapi.com/data. Quote from it with a link to the page.

Cite as: DXtrade API POST /accounts/{accountCode}/orders. Broker API Hub, https://openbrokerapi.com/platforms/dxtrade/endpoints/post-account-orders, newest check 2026-10-12.

Where you rely on a single figure, cite the source and the checked date printed beside it as well. Where this page and a broker's own documentation differ, the documentation wins.
