Replace Order
client.V1.Orders.ReplaceOrder(ctx, orderID, params) (*V1OrderReplaceOrderResponse, error)
PATCH/v1/accounts/{account_id}/orders/{order_id}
Replace Order
package main
import (
"context"
"fmt"
"github.com/clear-street/clear-street-go"
"github.com/clear-street/clear-street-go/option"
)
func main() {
client := clearstreet.NewClient(
option.WithAPIKey("My API Key"),
)
response, err := client.V1.Orders.ReplaceOrder(
context.TODO(),
"order_id",
clearstreet.V1OrderReplaceOrderParams{
AccountID: 0,
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response)
}
{
"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"
}
}