Place Order

Submit a new order.

POST /orders

Auth: Authorization: Bearer <access_token> (see Authentication).

Request Body

FieldTypeRequiredDescription
symbolstringYesInstrument id (e.g. "BTC-USDC-PERP")
sidestringYes"buy" or "sell"
typestringYes"market", "limit", or "peg"
quantitynumberYesOrder size in base asset (must be > 0)
pricenumberConditionalRequired for limit. Optional for market (acts as price cap). Omitted for peg.
peg_referencestringConditionalRequired for peg: "mid", "bid", or "ask".
time_in_forcestringYes"GTC", "GTT", "IOC", or "FOK"
expiry_timeintegerFor GTTNanosecond epoch timestamp at which a GTT order expires
aonbooleanNoAll-or-None. Default false. See Execution Attributes.
min_fill_sizenumberNoMinimum per-execution fill size
client_order_idstringNoClient-supplied idempotency key (≤64 chars). Duplicates return the existing order.

See Order Compatibility for which type × time_in_force × aon combinations are supported.

Example — Limit Order (GTC)

curl -X POST https://api.godarkdex.com/api/v1/orders \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $TOKEN" \
  -d '{
    "symbol": "BTC-USDC-PERP",
    "side": "buy",
    "type": "limit",
    "quantity": 0.1,
    "price": 95000,
    "time_in_force": "GTC",
    "client_order_id": "my-order-001"
  }'

Example — Market Order (IOC)

curl -X POST https://api.godarkdex.com/api/v1/orders \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $TOKEN" \
  -d '{
    "symbol": "BTC-USDC-PERP",
    "side": "buy",
    "type": "market",
    "quantity": 0.05,
    "time_in_force": "IOC"
  }'

Example — Peg to Mid (GTC)

curl -X POST https://api.godarkdex.com/api/v1/orders \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $TOKEN" \
  -d '{
    "symbol": "BTC-USDC-PERP",
    "side": "buy",
    "type": "peg",
    "peg_reference": "mid",
    "quantity": 0.1,
    "time_in_force": "GTC"
  }'

Success Response

{
  "code": 0,
  "data": {
    "order_id": "ord_01HXYZ12345",
    "client_order_id": "my-order-001",
    "status": "NEW"
  },
  "timestamp": "2026-04-20T10:30:00.123Z",
  "request_id": "req_01HXYZ..."
}

order_id is returned as a string to preserve precision. Use it on DELETE /orders/{orderId}, PATCH /orders/{orderId}, and GET /orders/{orderId}.

A 200 response means the order passed pre-trade risk checks and entered the book — not that it has filled. Track fills via GET /orders/{orderId} or the Orders Channel.

Idempotency

Supplying client_order_id makes POST /orders safely retryable:

client_order_id also works as an identifier on DELETE /orders?client_order_id=... and GET /orders?client_order_id=....

Order Status Lifecycle

StatusDescription
NEWOrder placed and acknowledged
PARTIALLY_FILLEDPartial fill received; remainder working
FILLEDFully filled
CANCELLEDCancelled (by user, by TIF expiry, or by system)
REJECTEDRejected at risk check or by matching engine

Valid transitions: NEW → PARTIALLY_FILLED → FILLED | CANCELLED, or NEW → FILLED | CANCELLED | REJECTED directly.

Pre-Trade Risk Validation

Every order is risk-checked before it enters the book. A 200 success response means all checks passed. For the full margin model, health tiers, and liquidation ladder, see Margin & Liquidation.

CheckError Code
Margin sufficiency1410
Position limits1411
Account in liquidation1412
Leverage exceeds instrument max1413

Risk Rejection Response

{
  "code": 1410,
  "message": "Margin insufficient: available 1200.00 USDC, required 5000.00 USDC",
  "timestamp": "2026-04-20T10:30:00.123Z",
  "request_id": "req_01HXYZ..."
}

For WebSocket placements (op: order.place), the rejection is returned as a rejected event on the orders channel with the matching reject_reason (see Rejection Reasons).