# Order Entry

Order entry operations

## Create order

> Create a new order (IOC, GTC, SL, TP)

```json
{"openapi":"3.0.3","info":{"title":"Reya DEX Trading API v2","version":"2.1.11"},"tags":[{"name":"Order Entry","description":"Order entry operations"}],"servers":[{"url":"https://api.reya.xyz/v2","description":"Production server"},{"url":"https://api-test.reya.xyz/v2","description":"Testnet server"}],"paths":{"/createOrder":{"post":{"summary":"Create order","description":"Create a new order (IOC, GTC, SL, TP)","operationId":"createOrder","tags":["Order Entry"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateOrderRequest"}}}},"responses":{"200":{"description":"Order creation response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateOrderResponse"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"500":{"$ref":"#/components/responses/InternalServerError"}}}}},"components":{"schemas":{"CreateOrderRequest":{"title":"CreateOrderRequest","$id":"#CreateOrderRequest","type":"object","required":["exchangeId","accountId","isBuy","limitPx","orderType","signature","nonce","signerWallet"],"properties":{"exchangeId":{"$ref":"#/components/schemas/UnsignedInteger"},"symbol":{"$ref":"#/components/schemas/Symbol"},"accountId":{"$ref":"#/components/schemas/UnsignedInteger"},"isBuy":{"type":"boolean","description":"Whether this is a buy order"},"limitPx":{"$ref":"#/components/schemas/SignedDecimal"},"qty":{"$ref":"#/components/schemas/UnsignedDecimal"},"orderType":{"$ref":"#/components/schemas/OrderType"},"timeInForce":{"$ref":"#/components/schemas/TimeInForce","description":"Order time in force, exclusively used for LIMIT orders"},"triggerPx":{"$ref":"#/components/schemas/SignedDecimal","description":"Trigger price, only for TP/SL orders"},"reduceOnly":{"type":"boolean","description":"Whether this is a reduce-only order, exclusively used for LIMIT IOC orders."},"signature":{"type":"string","description":"See signatures and nonces section for more details on how to generate."},"nonce":{"type":"string","description":"Order nonce, see signatures and nonces section for more details."},"signerWallet":{"$ref":"#/components/schemas/Address"},"expiresAfter":{"$ref":"#/components/schemas/UnsignedInteger","description":"Expiration timestamp (exclusively for PERP IOC orders and all SPOT orders). In seconds since epoch. The order will only be filled before this timestamp."},"clientOrderId":{"$ref":"#/components/schemas/UnsignedInteger","description":"Client-provided order ID for tracking and correlation. Optional field that allows clients to assign their own unique identifier to orders."}},"additionalProperties":true},"UnsignedInteger":{"title":"UnsignedInteger","$id":"#UnsignedInteger","type":"integer","minimum":0},"Symbol":{"title":"Symbol","$id":"#Symbol","type":"string","pattern":"^[A-Za-z0-9]+$","description":"Trading symbol (e.g., BTCRUSDPERP, WETHRUSD)"},"SignedDecimal":{"title":"SignedDecimal","$id":"#Decimal","type":"string","pattern":"^-?\\d+(\\.\\d+)?([eE][+-]?\\d+)?$"},"UnsignedDecimal":{"title":"UnsignedDecimal","$id":"#UnsignedDecimal","type":"string","pattern":"^\\d+(\\.\\d+)?([eE][+-]?\\d+)?$"},"OrderType":{"title":"OrderType","$id":"#OrderType","type":"string","enum":["LIMIT","TP","SL"],"description":"Order type, (LIMIT = Limit, TP = Take Profit, SL = Stop Loss)"},"TimeInForce":{"title":"TimeInForce","$id":"#TimeInForce","type":"string","enum":["IOC","GTC"],"description":"Order time in force (IOC = Immediate or Cancel, GTC = Good Till Cancel)"},"Address":{"title":"Address","$id":"#Address","type":"string","pattern":"^0x[a-fA-F0-9]{40}$"},"CreateOrderResponse":{"title":"CreateOrderResponse","$id":"#CreateOrderResponse","type":"object","required":["status"],"properties":{"status":{"$ref":"#/components/schemas/OrderStatus"},"execQty":{"$ref":"#/components/schemas/UnsignedDecimal","description":"Executed quantity in the current order update."},"cumQty":{"$ref":"#/components/schemas/UnsignedDecimal","description":"Total Executed quantity accross all fills where the order is involved."},"orderId":{"type":"string","description":"Created order ID (currently generated for all order types except IOC)"},"clientOrderId":{"$ref":"#/components/schemas/UnsignedInteger","description":"Client-provided order ID echoed back from the request"}},"additionalProperties":true},"OrderStatus":{"title":"OrderStatus","$id":"#OrderStatus","type":"string","enum":["OPEN","FILLED","CANCELLED","REJECTED"],"description":"Order status"},"RequestError":{"title":"RequestError","$id":"#RequestError","type":"object","required":["error","message"],"properties":{"error":{"$ref":"#/components/schemas/RequestErrorCode"},"message":{"type":"string","description":"Human-readable error message"}},"additionalProperties":true},"RequestErrorCode":{"title":"RequestErrorCode","$id":"#RequestErrorCode","type":"string","enum":["SYMBOL_NOT_FOUND","NO_ACCOUNTS_FOUND","NO_PRICES_FOUND_FOR_SYMBOL","INPUT_VALIDATION_ERROR","CREATE_ORDER_OTHER_ERROR","CANCEL_ORDER_OTHER_ERROR","ORDER_DEADLINE_PASSED_ERROR","ORDER_DEADLINE_TOO_HIGH_ERROR","INVALID_NONCE_ERROR","UNAVAILABLE_MATCHING_ENGINE_ERROR","UNAUTHORIZED_SIGNATURE_ERROR","NUMERIC_OVERFLOW_ERROR"],"description":"Standardized error codes for API responses"},"ServerError":{"title":"ServerError","$id":"#ServerError","type":"object","required":["error","message"],"properties":{"error":{"$ref":"#/components/schemas/ServerErrorCode"},"message":{"type":"string","description":"Human-readable error message"}},"additionalProperties":true},"ServerErrorCode":{"title":"ServerErrorCode","$id":"#ServerErrorCode","type":"string","enum":["INTERNAL_SERVER_ERROR"],"description":"Standardized error codes for API responses"}},"responses":{"BadRequest":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestError"}}}},"InternalServerError":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ServerError"}}}}}}}
```

## Cancel order

> Cancel an existing order

```json
{"openapi":"3.0.3","info":{"title":"Reya DEX Trading API v2","version":"2.1.11"},"tags":[{"name":"Order Entry","description":"Order entry operations"}],"servers":[{"url":"https://api.reya.xyz/v2","description":"Production server"},{"url":"https://api-test.reya.xyz/v2","description":"Testnet server"}],"paths":{"/cancelOrder":{"post":{"summary":"Cancel order","description":"Cancel an existing order","operationId":"cancelOrder","tags":["Order Entry"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CancelOrderRequest"}}}},"responses":{"200":{"description":"Order cancellation response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CancelOrderResponse"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"500":{"$ref":"#/components/responses/InternalServerError"}}}}},"components":{"schemas":{"CancelOrderRequest":{"title":"CancelOrderRequest","$id":"#CancelOrderRequest","type":"object","required":["signature"],"properties":{"orderId":{"type":"string","description":"Internal matching engine order ID to cancel. Provide either orderId OR clientOrderId, not both. For spot markets, this is the order ID returned in the CreateOrderResponse."},"clientOrderId":{"$ref":"#/components/schemas/UnsignedInteger","description":"Client-provided order ID for tracking and correlation. Provide either orderId OR clientOrderId, not both. This is the same clientOrderId provided in CreateOrderRequest."},"accountId":{"$ref":"#/components/schemas/UnsignedInteger","description":"Account ID that owns the order. Required for spot markets."},"symbol":{"$ref":"#/components/schemas/Symbol","description":"Market symbol for the order.Required for spot market orders. If not provided, assumes perp market for backwards compatibility."},"signature":{"type":"string","description":"See signatures section for more details on how to generate."},"nonce":{"type":"string","description":"See signatures and nonces section for more details. Compulsory for spot orders."},"expiresAfter":{"$ref":"#/components/schemas/UnsignedInteger","description":"Expiration timestamp (exclusively for SPOT orders). In seconds since epoch."}},"additionalProperties":true},"UnsignedInteger":{"title":"UnsignedInteger","$id":"#UnsignedInteger","type":"integer","minimum":0},"Symbol":{"title":"Symbol","$id":"#Symbol","type":"string","pattern":"^[A-Za-z0-9]+$","description":"Trading symbol (e.g., BTCRUSDPERP, WETHRUSD)"},"CancelOrderResponse":{"title":"CancelOrderResponse","$id":"#CancelOrderResponse","type":"object","required":["status","orderId"],"properties":{"status":{"$ref":"#/components/schemas/OrderStatus"},"orderId":{"type":"string","description":"Cancelled order ID"},"clientOrderId":{"type":"integer","description":"Client-provided order ID echoed back from the request"}},"additionalProperties":true},"OrderStatus":{"title":"OrderStatus","$id":"#OrderStatus","type":"string","enum":["OPEN","FILLED","CANCELLED","REJECTED"],"description":"Order status"},"RequestError":{"title":"RequestError","$id":"#RequestError","type":"object","required":["error","message"],"properties":{"error":{"$ref":"#/components/schemas/RequestErrorCode"},"message":{"type":"string","description":"Human-readable error message"}},"additionalProperties":true},"RequestErrorCode":{"title":"RequestErrorCode","$id":"#RequestErrorCode","type":"string","enum":["SYMBOL_NOT_FOUND","NO_ACCOUNTS_FOUND","NO_PRICES_FOUND_FOR_SYMBOL","INPUT_VALIDATION_ERROR","CREATE_ORDER_OTHER_ERROR","CANCEL_ORDER_OTHER_ERROR","ORDER_DEADLINE_PASSED_ERROR","ORDER_DEADLINE_TOO_HIGH_ERROR","INVALID_NONCE_ERROR","UNAVAILABLE_MATCHING_ENGINE_ERROR","UNAUTHORIZED_SIGNATURE_ERROR","NUMERIC_OVERFLOW_ERROR"],"description":"Standardized error codes for API responses"},"ServerError":{"title":"ServerError","$id":"#ServerError","type":"object","required":["error","message"],"properties":{"error":{"$ref":"#/components/schemas/ServerErrorCode"},"message":{"type":"string","description":"Human-readable error message"}},"additionalProperties":true},"ServerErrorCode":{"title":"ServerErrorCode","$id":"#ServerErrorCode","type":"string","enum":["INTERNAL_SERVER_ERROR"],"description":"Standardized error codes for API responses"}},"responses":{"BadRequest":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestError"}}}},"InternalServerError":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ServerError"}}}}}}}
```

## Cancel all orders

> Cancel all orders matching the specified filters (mass cancel)

```json
{"openapi":"3.0.3","info":{"title":"Reya DEX Trading API v2","version":"2.1.11"},"tags":[{"name":"Order Entry","description":"Order entry operations"}],"servers":[{"url":"https://api.reya.xyz/v2","description":"Production server"},{"url":"https://api-test.reya.xyz/v2","description":"Testnet server"}],"paths":{"/cancelAll":{"post":{"summary":"Cancel all orders","description":"Cancel all orders matching the specified filters (mass cancel)","operationId":"cancelAll","tags":["Order Entry"],"requestBody":{"required":false,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MassCancelRequest"}}}},"responses":{"200":{"description":"Mass cancel response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MassCancelResponse"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"500":{"$ref":"#/components/responses/InternalServerError"}}}}},"components":{"schemas":{"MassCancelRequest":{"title":"MassCancelRequest","$id":"#MassCancelRequest","type":"object","required":["signature","nonce","accountId","expiresAfter"],"properties":{"accountId":{"$ref":"#/components/schemas/UnsignedInteger","description":"Account ID to cancel orders for."},"symbol":{"$ref":"#/components/schemas/Symbol","description":"Symbol to cancel orders for. If not specified, cancels orders for all symbols."},"signature":{"type":"string","description":"See signatures and nonces section for more details on how to generate."},"nonce":{"type":"string","description":"See signatures and nonces section for more details."},"expiresAfter":{"$ref":"#/components/schemas/UnsignedInteger","description":"Expiration timestamp. In seconds since epoch."}},"additionalProperties":true,"description":"Request to cancel all orders matching the specified filters"},"UnsignedInteger":{"title":"UnsignedInteger","$id":"#UnsignedInteger","type":"integer","minimum":0},"Symbol":{"title":"Symbol","$id":"#Symbol","type":"string","pattern":"^[A-Za-z0-9]+$","description":"Trading symbol (e.g., BTCRUSDPERP, WETHRUSD)"},"MassCancelResponse":{"title":"MassCancelResponse","$id":"#MassCancelResponse","type":"object","required":["cancelledCount"],"properties":{"cancelledCount":{"$ref":"#/components/schemas/UnsignedInteger","description":"Number of orders that were cancelled"}},"additionalProperties":true},"RequestError":{"title":"RequestError","$id":"#RequestError","type":"object","required":["error","message"],"properties":{"error":{"$ref":"#/components/schemas/RequestErrorCode"},"message":{"type":"string","description":"Human-readable error message"}},"additionalProperties":true},"RequestErrorCode":{"title":"RequestErrorCode","$id":"#RequestErrorCode","type":"string","enum":["SYMBOL_NOT_FOUND","NO_ACCOUNTS_FOUND","NO_PRICES_FOUND_FOR_SYMBOL","INPUT_VALIDATION_ERROR","CREATE_ORDER_OTHER_ERROR","CANCEL_ORDER_OTHER_ERROR","ORDER_DEADLINE_PASSED_ERROR","ORDER_DEADLINE_TOO_HIGH_ERROR","INVALID_NONCE_ERROR","UNAVAILABLE_MATCHING_ENGINE_ERROR","UNAUTHORIZED_SIGNATURE_ERROR","NUMERIC_OVERFLOW_ERROR"],"description":"Standardized error codes for API responses"},"ServerError":{"title":"ServerError","$id":"#ServerError","type":"object","required":["error","message"],"properties":{"error":{"$ref":"#/components/schemas/ServerErrorCode"},"message":{"type":"string","description":"Human-readable error message"}},"additionalProperties":true},"ServerErrorCode":{"title":"ServerErrorCode","$id":"#ServerErrorCode","type":"string","enum":["INTERNAL_SERVER_ERROR"],"description":"Standardized error codes for API responses"}},"responses":{"BadRequest":{"description":"Bad request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RequestError"}}}},"InternalServerError":{"description":"Internal server error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ServerError"}}}}}}}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.reya.xyz/developers/readme/order-entry.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
