Place and track an order
Goal: buy 10 units of an ETF in a portfolio and know when it filled. Scopes: read and trade.
Also useful: a webhook endpoint subscribed to order.updated and order.expired.
- Your server to IDEALX API: GET /v1/investments?q=EXS
- Your server to IDEALX API: GET /v1/accounts/{id}/orders/fee
- IDEALX API to Your server: fee and estimate
- Your server to IDEALX API: POST /v1/accounts/{id}/orders + Idempotency-Key
- IDEALX API: Cash set aside
- IDEALX API to Your server: 200 order (placing)
- IDEALX API to Market: Send order
- Market to IDEALX API: Filled
- IDEALX API to Your server: Webhook order.updated (filled)
- Your server to IDEALX API: GET /v1/accounts/{id}/orders?status=done
- Your server to IDEALX API: GET /v1/orders/{id}/confirmation.pdf
1. Find the investment
Section titled “1. Find the investment”/v1/investmentsShares, ETFs, bonds and digital assets you can buy
curl "$IDEALX_API/v1/investments?q=EXS&country=AU&limit=5" -H "Authorization: Bearer $IDEALX_API_KEY"{ "investments": [ { "id": "XASX:EXS", "symbol": "EXS", "name": "Example Australian Shares ETF", "assetClass": "etf", "market": "XASX", "currency": "AUD", "description": "Tracks a broad index of Australian shares.", "quantityDecimals": 0, "priceDecimals": 4, "securityType": "etf", "logo": "/v1/logos/XASX:EXS", "tradable": true, "accent": "#2f6fd6", "priceUsd": null, "quote": { "bid": "101.2500", "ask": "101.3100", "last": "101.2800", "previousClose": "100.9400", "asOf": "2026-11-25T04:12:00.000Z", "freshness": "delayed" }, "bond": null, "term": null, "shown": null, "marketCap": null } ], "total": 1}Note quantityDecimals: 0: this listing trades in whole units.
2. Check the fee
Section titled “2. Check the fee”/v1/accounts/{id}/orders/feeThe transaction fee an order would pay, before placing it
curl "$IDEALX_API/v1/accounts/acc_01937c4e8a2b7d1f9e0c3b5a6d7e8f90/orders/fee?instrumentId=XASX:EXS&side=buy&quantity=10&type=market" \ -H "Authorization: Bearer $IDEALX_API_KEY"{ "estimate": { "amount": "1013.10", "currency": "AUD" }, "fee": { "amount": "5.00", "currency": "AUD" }}A market buy also sets aside 3% above the ask while it works (here about A$1,043.49 plus the fee); what is not used comes back when it fills. Make sure the portfolio has that much cash, or use a limit order.
3. Place the order
Section titled “3. Place the order”/v1/accounts/{id}/ordersBuy or sell in a portfolio
Generate an Idempotency-Key when you decide to buy, store it with your own record of the order, and send the same
key on every retry.
curl -X POST "$IDEALX_API/v1/accounts/acc_01937c4e8a2b7d1f9e0c3b5a6d7e8f90/orders" \ -H "Authorization: Bearer $IDEALX_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: 6f1c0d7e-2b4a-4e8f-9a31-5c2d7e8f9a10" \ -d '{ "portfolioId": "ptf_01937c4e8a2b7d1f9e0c3b5a6d7e8fa1", "instrumentId": "XASX:EXS", "side": "buy", "type": "market", "quantity": "10" }'import { randomUUID } from "node:crypto";
const key = randomUUID(); // save with your order record before sendingconst res = await fetch(`${process.env.IDEALX_API}/v1/accounts/${accountId}/orders`, { method: "POST", headers: { Authorization: `Bearer ${process.env.IDEALX_API_KEY}`, "Content-Type": "application/json", "Idempotency-Key": key, }, body: JSON.stringify({ portfolioId, instrumentId: "XASX:EXS", side: "buy", type: "market", quantity: "10", }),});const order = await res.json();if (!res.ok) throw new Error(`${order.error.code}: ${order.error.message}`);console.log(order.id, order.state);import uuid
key = str(uuid.uuid4()) # save with your order record before sendingres = requests.post( f"{base}/v1/accounts/{account_id}/orders", headers={**headers, "Idempotency-Key": key}, json={ "portfolioId": portfolio_id, "instrumentId": "XASX:EXS", "side": "buy", "type": "market", "quantity": "10", }, timeout=30,)order = res.json()if not res.ok: raise RuntimeError(f"{order['error']['code']}: {order['error']['message']}")print(order["id"], order["state"]){ "id": "ord_01937e63c1d2e3f4a5b6c7d8e9f0a1b2", "portfolioId": "ptf_01937c4e8a2b7d1f9e0c3b5a6d7e8fa1", "instrumentId": "XASX:EXS", "side": "buy", "type": "market", "quantity": "10", "limitPrice": null, "state": "placing", "filledQuantity": "0", "filledValue": { "amount": "0.00", "currency": "AUD" }, "setAside": "1048.49", "approvalsRequired": 1, "approvals": 1, "approvedByMe": true, "rejectReason": null, "reason": null, "createdAt": "2026-11-25T04:13:02.000Z"}| If you get | It means |
|---|---|
409 conflict |
Not enough cash or units, or no price right now. Nothing was placed. |
422 validation_failed |
A field is wrong, for example too many decimals in quantity (details.issues). |
403 forbidden with details.scope: "trade" |
The key lacks the trade scope. |
state: "pending_approval" |
The account needs more approvals; another person approves in the app or with POST /v1/orders/{id}/approve. |
state: "waiting_market" |
The market is closed; the order is sent at the open. |
4. Follow it
Section titled “4. Follow it”With a webhook endpoint subscribed to order.updated, you receive each state change:
{ "id": "whd_01937e63e4f5a6b7c8d9e0f1a2b3c4d5", "type": "order.updated", "createdAt": "2026-11-25T04:13:09.000Z", "data": { "accountId": "acc_01937c4e8a2b7d1f9e0c3b5a6d7e8f90", "orderId": "ord_01937e63c1d2e3f4a5b6c7d8e9f0a1b2", "state": "filled" }}Then read the order for its figures (there is no single-order read; filter the list):
GET/v1/accounts/{id}/ordersOrders on this account, newest first
curl "$IDEALX_API/v1/accounts/acc_01937c4e8a2b7d1f9e0c3b5a6d7e8f90/orders?status=done&q=EXS&limit=10" \ -H "Authorization: Bearer $IDEALX_API_KEY"{ "orders": [ { "id": "ord_01937e63c1d2e3f4a5b6c7d8e9f0a1b2", "portfolioId": "ptf_01937c4e8a2b7d1f9e0c3b5a6d7e8fa1", "instrumentId": "XASX:EXS", "side": "buy", "type": "market", "quantity": "10", "limitPrice": null, "state": "filled", "filledQuantity": "10", "filledValue": { "amount": "1012.90", "currency": "AUD" }, "setAside": "0.00", "approvalsRequired": 1, "approvals": 1, "approvedByMe": true, "rejectReason": null, "reason": null, "createdAt": "2026-11-25T04:13:02.000Z" } ], "total": 1}5. Download the confirmation
Section titled “5. Download the confirmation”/v1/orders/{id}/confirmation.pdfThe trade confirmation for an order that filled
curl -o confirmation.pdf "$IDEALX_API/v1/orders/ord_01937e63c1d2e3f4a5b6c7d8e9f0a1b2/confirmation.pdf" \ -H "Authorization: Bearer $IDEALX_API_KEY"Cancelling
Section titled “Cancelling”POST /v1/orders/{id}/cancelCancel an order that has not filled works until the order ends. An order still with IDEALX
(waiting for approval, the market or funding) is cancelled at once; an order already at the market is cancelled
there and the answer recorded, so read state in the response: cancelled, or still open /
partially_filled if the market has not confirmed yet (an order.updated follows). Units already filled are kept.
409 means the order has already ended, or is being sent right now: try again in a moment. Whatever was set aside
for the unfilled part comes back.
Checklist
Section titled “Checklist”- One
Idempotency-Keyper order, stored before the first attempt and reused on retries. - Quantities as strings, within the listing’s
quantityDecimals. - Handle
pending_approval,waiting_market,waiting_fundingandqueuedas “still working”. - Treat
filled,cancelled,rejectedandexpiredas final; readrejectReasonfor rejections. - Verify webhook signatures and ignore repeated delivery ids.