Replace Order
OrderReplaceOrderResponse v1().orders().replaceOrder(OrderReplaceOrderParamsparams, RequestOptionsrequestOptions = RequestOptions.none())
PATCH/v1/accounts/{account_id}/orders/{order_id}
Replace Order
package com.clear_street.api.example;
import com.clear_street.api.client.ClearStreetClient;
import com.clear_street.api.client.okhttp.ClearStreetOkHttpClient;
import com.clear_street.api.models.v1.orders.OrderReplaceOrderParams;
import com.clear_street.api.models.v1.orders.OrderReplaceOrderResponse;
public final class Main {
private Main() {}
public static void main(String[] args) {
ClearStreetClient client = ClearStreetOkHttpClient.builder()
.fromEnv()
.apiKey("My API Key")
.build();
OrderReplaceOrderParams params = OrderReplaceOrderParams.builder()
.accountId(0L)
.orderId("order_id")
.build();
OrderReplaceOrderResponse response = client.v1().orders().replaceOrder(params);
}
}{
"data": {
"account_id": 19816,
"average_fill_price": "149.95",
"created_at": "2025-10-31T13:30:00.000000000Z",
"filled_quantity": "50",
"id": "my-ref-id-20251001-001",
"instrument_id": "a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8",
"instrument_type": "COMMON_STOCK",
"leaves_quantity": "50",
"limit_price": "150.50",
"order_type": "LIMIT",
"quantity": "125",
"side": "BUY",
"status": "PENDING_REPLACE",
"stop_price": null,
"symbol": "AAPL",
"time_in_force": "DAY",
"updated_at": "2025-10-31T14:10:00.000000000Z"
},
"error": null,
"metadata": {
"request_id": "1d2e3f4a-5b6c-7d8e-9f0a-1b2c3d4e5f6a"
}
}{
"error": {
"code": 400,
"message": "Failed to parse the request body as JSON: expected `:` at line 2 column 14"
},
"metadata": {
"request_id": "633c15ef-d2e7-4f27-b905-2819455248bb"
}
}{
"error": {
"code": 403,
"message": "The caller does not have permission to execute the specified operation"
},
"metadata": {
"request_id": "5518f0c6-58ff-4b4a-81a5-701556d41206"
}
}{
"error": {
"code": 404,
"message": "Order 019c7b89-feea-7600-9e56-f15ef0557835 not found for account 100001"
},
"metadata": {
"request_id": "9e290ec2-378f-4d08-a729-0a9ab155acbf"
}
}Returns Examples
{
"data": {
"account_id": 19816,
"average_fill_price": "149.95",
"created_at": "2025-10-31T13:30:00.000000000Z",
"filled_quantity": "50",
"id": "my-ref-id-20251001-001",
"instrument_id": "a1a2a3a4-b1b2-c1c2-d1d2-d3d4d5d6d7d8",
"instrument_type": "COMMON_STOCK",
"leaves_quantity": "50",
"limit_price": "150.50",
"order_type": "LIMIT",
"quantity": "125",
"side": "BUY",
"status": "PENDING_REPLACE",
"stop_price": null,
"symbol": "AAPL",
"time_in_force": "DAY",
"updated_at": "2025-10-31T14:10:00.000000000Z"
},
"error": null,
"metadata": {
"request_id": "1d2e3f4a-5b6c-7d8e-9f0a-1b2c3d4e5f6a"
}
}{
"error": {
"code": 400,
"message": "Failed to parse the request body as JSON: expected `:` at line 2 column 14"
},
"metadata": {
"request_id": "633c15ef-d2e7-4f27-b905-2819455248bb"
}
}{
"error": {
"code": 403,
"message": "The caller does not have permission to execute the specified operation"
},
"metadata": {
"request_id": "5518f0c6-58ff-4b4a-81a5-701556d41206"
}
}{
"error": {
"code": 404,
"message": "Order 019c7b89-feea-7600-9e56-f15ef0557835 not found for account 100001"
},
"metadata": {
"request_id": "9e290ec2-378f-4d08-a729-0a9ab155acbf"
}
}