> ## Documentation Index
> Fetch the complete documentation index at: https://docs.daya.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Replace Order

> Atomically cancel and re-place an open order

## Overview

Atomically cancel an existing open order and submit a new one in its place. The matching engine performs both steps in one operation, so you never end up holding both. Useful for amending limit orders as the market moves.

The replacement is a *new* order, not a mutation — the response returns a fresh order ID. Track that ID for follow-up cancels and webhook events.

Requires **Trade** scope. Only orders that are still resting (status `open` or `partially_filled`) can be replaced — terminal orders return 404.

## Authentication

<ParamField header="X-Api-Key" type="string" required>
  Your API key with Trade scope
</ParamField>

## Path Parameters

<ParamField path="id" type="string" required>
  Order ID (UUID) to replace
</ParamField>

## Request Body

<ParamField body="side" type="string" required>
  Order side for the new order.

  **Allowed values:** `buy`, `sell`
</ParamField>

<ParamField body="type" type="string" required>
  Order type for the new order.

  **Allowed values:** `limit`, `market`
</ParamField>

<ParamField body="quantity" type="string" required>
  Quantity for the new order.

  **Example:** `120.00`
</ParamField>

<ParamField body="price" type="string">
  Limit price (required when `type` is `limit`).

  **Example:** `1550.00`
</ParamField>

## Request Example

<CodeGroup>
  ```bash cURL theme={"dark"}
  curl --request PUT \
    --url https://api.pro.daya.co/public/v1/orders/550e8400-e29b-41d4-a716-446655440000 \
    --header 'X-Api-Key: daya_sk_YOUR_API_KEY' \
    --header 'Content-Type: application/json' \
    --data '{
      "side": "buy",
      "type": "limit",
      "price": "1550.00",
      "quantity": "120.00"
    }'
  ```
</CodeGroup>

## Response

Same shape as [Get Order](/pro/api-reference/get-order). The returned `id` is the **new** order — track it for follow-up cancels and webhook events.

<ResponseExample>
  ```json 200 OK theme={"dark"}
  {
    "success": true,
    "message": "Order replaced successfully",
    "data": {
      "id": "8c5b2e8e-1f8e-4b4f-9e5a-2b3c4d5e6f70",
      "symbol": "USDT-NGN",
      "side": "buy",
      "type": "limit",
      "status": "open",
      "price": "1550.00",
      "quantity": "120.00",
      "filled_quantity": "0.00",
      "created_at": "2026-05-06T10:00:00Z"
    }
  }
  ```
</ResponseExample>

## Error Responses

| Code  | Meaning                                                                         |
| ----- | ------------------------------------------------------------------------------- |
| `400` | Invalid body — missing side/type/quantity, or price supplied for a market order |
| `403` | API key missing Trade scope, or account frozen                                  |
| `404` | Order not found, or already terminal                                            |
