Skip to content

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 :

  1. 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.
  2. 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

NameTypeRequiredDescription
orderNumberstringtrueUnique Order identifier of the order which needs to be modified.
orderTypestringfalseType of order user has placed. It can be one of the following: L - Limit Order, SL - Stop Loss Limit.
quantitystringfalseQuantity of the order user wants to modify.
disclosedQuantitystringfalseQuantity to disclose publicly.
orderValiditystringtrueOrder validity can be DAY or IOC.
pricestringfalsePrice at which the order was placed.
triggerPricestringfalseThe price at which an order should be triggered in case of SL.

Sample Request Body

json
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

bash
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"}'
java
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());
  }
}
js
(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);
})();
py
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

json
{
    "serverTime": "20/08/24 18:43:33",
    "msgId": "6178372c-d2e4-47d0-937a-e1122f30633a",
    "status": "Success",
    "statusMessage": "Order  modified successfully.",
    "ordernumber": "240820000131756"
}
json

 {
    "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

NameTypeDescription
serverTimestringThis key indicates the time when the server processed the request.
msgIdstringThis 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.
statusstringStatus of the order. It would be success, error, or failure.
statusMessagestringThis provides a more detailed message regarding the status.
orderNumberstringThis 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.