Modify Order
PUT /order/modifyOrder/{orderNumber}
To modify an order in the system, you can only do so while the order is in an open or pending status. orderNumber is mandatory for any modification request. Along with the orderNumber, you may send the specific attribute(s) that you wish to modify. If no optional parameters are provided, the system will retain the original order's default attributes.
Please note that this API cannot be used to modify orders that have already been executed, rejected, or canceled. Ensure that you only send the attribute(s) that need to be modified in the request, along with the required order identifier.
Steps to modify an order :
- Fetch all today's orders using the Order Book API. From these, note down the order number of the orders that have a status of 'pending' or 'open' and that you want to modify.
- Then, check the current status of that order using the order status API. You can only modify the order if its status is still 'pending'.Then, based on the parameters provided below, you can modify your order.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
orderNumber | string | true | Unique Order identifier of the order which needs to be modified. |
orderType | string | false | Type of order user has placed. It can be one of the following: L - Limit Order, SL - Stop Loss Limit. |
quantity | string | false | Quantity of the order user wants to modify. |
disclosedQuantity | string | false | Quantity to disclose publicly. |
orderValidity | string | true | Order validity can be DAY or IOC. |
price | string | false | Price at which the order was placed. |
triggerPrice | string | false | The price at which an order should be triggered in case of SL. |
Sample Request Body
requestBody={
"orderType": "L",
"quantity": "3",
"disclosedQuantity": "1",
"orderValidity": "DAY",
"price": "1240.00",
"triggerPrice": "1070.00"
}Live trading endpoint
This sample sends a real request against your trading account. Replace <SESSION_TOKEN> and review every field before running — Samco does not provide a sandbox, and any successful call affects live positions and balances.
Sample Code
curl -X PUT 'https://tradeapi.samco.in/order/modifyOrder/240820000131756' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'x-session-token: <SESSION_TOKEN>' \
-d '{"orderType":"L","quantity":"3","disclosedQuantity":"1","orderValidity":"DAY","price":"1240.00","triggerPrice":"1070.00"}'import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Sample {
public static void main(String[] args) throws Exception {
String requestBody = """
{
"orderType": "L",
"quantity": "3",
"disclosedQuantity": "1",
"orderValidity": "DAY",
"price": "1240.00",
"triggerPrice": "1070.00"
}
""";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://tradeapi.samco.in/order/modifyOrder/240820000131756"))
.header("Content-Type", "application/json")
.header("Accept", "application/json")
.header("x-session-token", "<SESSION_TOKEN>")
.PUT(HttpRequest.BodyPublishers.ofString(requestBody))
.build();
HttpResponse<String> response =
client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}(async () => {
const headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'x-session-token': '<SESSION_TOKEN>',
};
const requestBody = {
orderType: "L",
quantity: "3",
disclosedQuantity: "1",
orderValidity: "DAY",
price: "1240.00",
triggerPrice: "1070.00"
};
const response = await fetch('https://tradeapi.samco.in/order/modifyOrder/240820000131756', {
method: 'PUT',
headers,
body: JSON.stringify(requestBody),
});
const data = await response.json();
console.log(data);
})();import requests
import json
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'x-session-token': '<SESSION_TOKEN>',
}
requestBody = {
"orderType": "L",
"quantity": "3",
"disclosedQuantity": "1",
"orderValidity": "DAY",
"price": "1240.00",
"triggerPrice": "1070.00"
}
r = requests.put('https://tradeapi.samco.in/order/modifyOrder/240820000131756',
data=json.dumps(requestBody),
headers=headers)
print(r.json())Sample Responses
{
"serverTime": "20/08/24 18:43:33",
"msgId": "6178372c-d2e4-47d0-937a-e1122f30633a",
"status": "Success",
"statusMessage": "Order modified successfully.",
"ordernumber": "240820000131756"
}
{
"serverTime": "20/08/24 18:22:22",
"msgId": "471550bd-3677-471b-bc83-8b2de1535ae1",
"status": "Failure",
"statusMessage": "Invalid Order number.",
"ordernumber": "240812000073930"
}Response Schema
Status Code 200
| Name | Type | Description |
|---|---|---|
serverTime | string | This key indicates the time when the server processed the request. |
msgId | string | This is a unique identifier for every request into the system. Please quote this identifier to the support team if you face issues with the API request. |
status | string | Status of the order. It would be success, error, or failure. |
statusMessage | string | This provides a more detailed message regarding the status. |
orderNumber | string | This is the unique identifier for the order that was modified. It can be used to reference the specific order within the system for further operations or inquiries. |