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

# Update Order via WebSocket

> Update the price and/or amount of an existing active order via WebSocket API

Updates the price and/or amount of an existing active order via WebSocket API. It is not possible to change a canceled or fully executed order.

## Request

<ParamField body="id" type="string" required>
  Unique request identifier for correlation
</ParamField>

<ParamField body="method" type="string" required>
  WebSocket API method. Must be `order.update`
</ParamField>

<ParamField body="params" type="object" required>
  Request parameters containing authentication and update details

  <Expandable title="Authentication">
    <ParamField body="params.api_token" type="string" required>
      API Token for authentication
    </ParamField>

    <ParamField body="params.timestamp" type="integer" required>
      Timestamp in milliseconds (UTC)
    </ParamField>

    <ParamField body="params.signature" type="string" required>
      HMAC SHA256 signature of the request
    </ParamField>
  </Expandable>

  <Expandable title="Update Parameters">
    <ParamField body="params.order_id" type="string" required>
      Order ID to update
    </ParamField>

    <ParamField body="params.price" type="number">
      New unit price. Optional, but at least one of `price` or `amount` must be provided.
    </ParamField>

    <ParamField body="params.amount" type="number">
      New order amount. Optional, but at least one of `price` or `amount` must be provided.
    </ParamField>
  </Expandable>
</ParamField>

<Note>
  At least one of `price` or `amount` must be provided. The order must be active (open or partially executed) to be updated. Canceled or fully executed orders cannot be modified.
</Note>

## Response

<ResponseField name="id" type="string">
  Request identifier for correlation
</ResponseField>

<ResponseField name="status" type="integer">
  HTTP status code (200 for success)
</ResponseField>

<ResponseField name="result" type="null">
  Always null for successful update responses. The update is confirmed by the 200 status code.
</ResponseField>

## Error Response

<ResponseField name="id" type="string">
  Request identifier for correlation
</ResponseField>

<ResponseField name="status" type="integer">
  HTTP error status code
</ResponseField>

<ResponseField name="result" type="null">
  Always null for error responses
</ResponseField>

<ResponseField name="error" type="object">
  Error details object

  <Expandable title="Error Details">
    <ResponseField name="error_code" type="integer">
      Error code (e.g., 40401 for order not found, 40408 for order not active)
    </ResponseField>

    <ResponseField name="message" type="string">
      Human-readable error message
    </ResponseField>
  </Expandable>
</ResponseField>

## Examples

<CodeGroup>
  ```json Update Price and Amount theme={null}
  {
    "id": "req-005",
    "method": "order.update",
    "params": {
      "api_token": "your-api-token",
      "timestamp": 1634567890000,
      "signature": "calculated-signature",
      "order_id": "7155ED34-9EC4-4733-8B32-1E4319CB662F",
      "price": 105000,
      "amount": 0.002
    }
  }
  ```

  ```json Update Price Only theme={null}
  {
    "id": "req-006",
    "method": "order.update",
    "params": {
      "api_token": "your-api-token",
      "timestamp": 1634567890000,
      "signature": "calculated-signature",
      "order_id": "7155ED34-9EC4-4733-8B32-1E4319CB662F",
      "price": 110000
    }
  }
  ```

  ```json Update Amount Only theme={null}
  {
    "id": "req-007",
    "method": "order.update",
    "params": {
      "api_token": "your-api-token",
      "timestamp": 1634567890000,
      "signature": "calculated-signature",
      "order_id": "7155ED34-9EC4-4733-8B32-1E4319CB662F",
      "amount": 0.003
    }
  }
  ```
</CodeGroup>

## Success Response Example

```json theme={null}
{
  "id": "req-005",
  "status": 200,
  "result": null
}
```

## Error Response Examples

### Order Not Found

```json theme={null}
{
  "id": "req-005",
  "status": 404,
  "result": null,
  "error": {
    "error_code": 40401,
    "message": "Order not found."
  }
}
```

### Order Not Active

```json theme={null}
{
  "id": "req-005",
  "status": 400,
  "result": null,
  "error": {
    "error_code": 40408,
    "message": "Cannot update a canceled or fully executed order."
  }
}
```

### Missing Price and Amount

```json theme={null}
{
  "id": "req-005",
  "status": 400,
  "result": null,
  "error": {
    "error_code": 40010,
    "message": "At least one of price or amount must be provided."
  }
}
```

### Invalid Signature

```json theme={null}
{
  "id": "req-005",
  "status": 400,
  "result": null,
  "error": {
    "error_code": 40011,
    "message": "Invalid signature or timestamp expired."
  }
}
```

## Update Scenarios

### Scenario 1: Adjust Price

If you want to change the order's price while keeping the amount the same:

* Provide only the `price` parameter
* The order amount remains unchanged

### Scenario 2: Adjust Amount

If you want to change the order's amount while keeping the price the same:

* Provide only the `amount` parameter
* The order price remains unchanged

### Scenario 3: Adjust Both Price and Amount

If you want to change both the price and amount:

* Provide both `price` and `amount` parameters
* Both values will be updated

## Important Notes

* **Order Status**: Only active orders (status `open` or `executed_partially`) can be updated
* **Canceled Orders**: Cannot be updated
* **Fully Executed Orders**: Cannot be updated
* **Partial Execution**: If an order has been partially executed, you can still update the remaining amount
* **Update Confirmation**: A successful response returns status 200 with `result: null`. This confirms the update was applied
* **Idempotency**: If you send the same update request twice with different request IDs, both updates will be applied
* **Request Correlation**: Always use a unique `id` in each request for proper correlation with responses

## Update Restrictions

### Updatable Order Types

Most order types support updates:

* Limit orders: ✓ Can update price and amount
* Market orders: May have restrictions depending on execution stage
* Stop Limit orders: ✓ Can update price and amount
* Trailing orders: ✓ Can update price and distance
* Ceiling orders: ✓ Can update value
* Iceberg orders: ✓ Can update price and step amount

### Cannot Update

* Already canceled orders
* Fully executed orders (status: `executed_completely`)
* Orders after partial execution (in some cases)

## Common Error Codes

| Error Code | Message                                          | Description                                                |
| ---------- | ------------------------------------------------ | ---------------------------------------------------------- |
| 40401      | Order not found                                  | The order ID does not exist                                |
| 40408      | Cannot update a canceled or fully executed order | The order is not in an updatable state                     |
| 40010      | At least one of price or amount must be provided | Neither price nor amount was provided                      |
| 40011      | Invalid signature or timestamp expired           | Authentication failed                                      |
| 40012      | Invalid price or amount                          | The provided values are invalid or out of acceptable range |
