Skip to content

Place Order

POST /order/placeOrder

This API allows you to place an equity/derivative order to the exchange i.e the place order request typically registers the order with OMS and when it happens successfully, a success response is returned. Successful placement of an order via the API does not imply its successful execution. To be precise, under normal scenarios, the whole flow of order execution starting with order placement, routing to OMS and transfer to the exchange, order execution, and confirmation from exchange happen real time. But due to various reasons like market hours, exchange related checks etc. This may not happen instantly. So when an order is successfully placed the placeOrder API returns an orderNumber in response, and in scenarios as above the actual order status can be checked separately using the orderStatus API call.This is for Placing CNC, MIS and NRML Orders.

In the BFO exchange, only SENSEX and BANKEX trades are allowed.

Parameters

NameTypeRequiredDescription
symbolNamestringtruePass the "name" in the symbolName parameter for Equity Cash symbols, and the "Trading Symbol" for all F&O contracts (both 'name' and 'tradingSymbol' are available in the ScripMaster.csv).
exchangestringtrueName of the exchange. Valid exchange values are BSE, NSE, NFO, BFO, MCX, and CDS. If the user does not provide an exchange name, the default is NSE. For trading on BSE, NFO, BFO, CDS, and MCX, the exchange is mandatory.
transactionTypestringtrueThe transaction type should be either BUY or SELL.
orderTypestringtrueThe type of order. It can be one of the following: L (Limit Order), SL (Stop Loss Limit).
quantitystringtrueThe quantity with which the order is being placed.
disclosedQuantitystringfalseIf provided, it should be a minimum of 10% of the actual quantity.
pricestringfalsePrice is mandatory when the order type is L (Limit Order) or SL (Stop Loss Limit).
orderValiditystringtrueOrder validity can be DAY or IOC. DAY is valid for the entire trading day and stays pending until executed, while IOC (Immediate or Cancel) means the order hits the exchange and is cancelled if not executed immediately.
afterMarketOrderFlagstringfalseAfter Market Order Flag. Acceptable values are YES or NO.
productTypestringtrueThe product type of the order. It can be CNC (Cash and Carry), NRML (Normal), or MIS (Intraday).
triggerPricestringfalseThe price at which an order should be triggered in the case of SL (Stop Loss).

Sample Request Body

json
requestBody={ 
"symbolName":"IDEA",
"exchange":"NSE",
"transactionType":"BUY",
"orderType":"L",
"quantity": "1",
"disclosedQuantity":"1",
"orderValidity":"DAY",
"productType":"CNC",
"afterMarketOrderFlag":"NO",
"price":"13.40"
}
json
requestBody={ 
"symbolName":"IDEA",
"exchange":"NSE",
"transactionType":"BUY",
"orderType":"SL",
"quantity": "1",
"orderValidity":"DAY",
"productType":"CNC",
"price":"13.40",
"triggerPrice":"14.9"
}

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.

Code Sample

bash
curl -X POST 'https://tradeapi.samco.in/order/placeOrder' \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'x-session-token: <SESSION_TOKEN>' \
  -d '{"symbolName":"IDEA","exchange":"NSE","transactionType":"BUY","orderType":"L","quantity":"1","disclosedQuantity":"1","orderValidity":"DAY","productType":"CNC","afterMarketOrderFlag":"NO","price":"13.40"}'
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 = """
        {
          "symbolName": "IDEA",
          "exchange": "NSE",
          "transactionType": "BUY",
          "orderType": "L",
          "quantity": "1",
          "disclosedQuantity": "1",
          "orderValidity": "DAY",
          "productType": "CNC",
          "afterMarketOrderFlag": "NO",
          "price": "13.40"
        }
        """;

    HttpClient client = HttpClient.newHttpClient();

    HttpRequest request = HttpRequest.newBuilder()
        .uri(URI.create("https://tradeapi.samco.in/order/placeOrder"))
        .header("Content-Type", "application/json")
        .header("Accept", "application/json")
        .header("x-session-token", "<SESSION_TOKEN>")
        .POST(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 = {
    symbolName: "IDEA",
    exchange: "NSE",
    transactionType: "BUY",
    orderType: "L",
    quantity: "1",
    disclosedQuantity: "1",
    orderValidity: "DAY",
    productType: "CNC",
    afterMarketOrderFlag: "NO",
    price: "13.40"
  };

  const response = await fetch('https://tradeapi.samco.in/order/placeOrder', {
    method: 'POST',
    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 = {
  "symbolName": "IDEA",
  "exchange": "NSE",
  "transactionType": "BUY",
  "orderType": "L",
  "quantity": "1",
  "disclosedQuantity": "1",
  "orderValidity": "DAY",
  "productType": "CNC",
  "afterMarketOrderFlag": "NO",
  "price": "13.40"
}

r = requests.post('https://tradeapi.samco.in/order/placeOrder',
  data=json.dumps(requestBody),
  headers=headers)

print(r.json())

Sample responses

json
{
    "serverTime": "22/05/24 17:17:15",
    "msgId": "dc1a9957-8bee-4895-9b7e-8e5e5f627a1a",
    "status": "Success",
    "orderNumber": "240522000162545",
    "statusMessage": "CNC Order request placed successfully",
    "exchangeOrderStatus": "PENDING",
    "rejectionReason": "",
    "orderDetails": {
        "pendingQuantity": 1,
        "avgExecutionPrice": "0.00",
        "orderPlacedBy": "--",
        "tradingSymbol": "IDEA-EQ",
        "triggerPrice": "0.00",
        "exchange": "NSE",
        "totalQuantity": 1,
        "transactionType": "B",
        "productType": "CNC",
        "orderType": "L",
        "quantity": 1,
        "filledQuantity": 0,
        "orderPrice": "13.40",
        "filledPrice": "0.00",
        "orderValidity": "DAY",
        "orderTime": "22/05/2024 17:17:15"
    }
}
json
{
    "serverTime": "22/05/24 17:25:06",
    "msgId": "810d707d-b23e-4dd4-bf72-f4f9dfb2d688",
    "status": "Success",
    "orderNumber": "240522000162594",
    "statusMessage": "CNC Order request placed successfully",
    "exchangeOrderStatus": "PENDING",
    "rejectionReason": "",
    "orderDetails": {
        "pendingQuantity": 1,
        "avgExecutionPrice": "0.00",
        "orderPlacedBy": "--",
        "tradingSymbol": "IDEA-EQ",
        "triggerPrice": "14.90",
        "exchange": "NSE",
        "totalQuantity": 1,
        "transactionType": "B",
        "productType": "CNC",
        "orderType": "SL",
        "quantity": 1,
        "filledQuantity": 0,
        "orderPrice": "13.40",
        "filledPrice": "0.00",
        "orderValidity": "DAY",
        "orderTime": "22/05/2024 17:25:06"
    }
}

Response Schema

Status Code 200

NameTypeDescription
serverTimestringTime at Server.
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.
orderNumberstringUnique Order identifier generated after placing an order which could be used for tracking order status.
statusstringStatus of the order. It would be success or failure.
statusMessagestringOrder placement status Message.
exchangeOrderStatusstringStatus of the order execution at the Exchange side. Most common values are PENDING, COMPLETE, REJECTED, CANCELLED, and OPEN.
rejectionReasonstringIf an order is rejected, the cause of order rejection, which comes as a user-friendly textual description.
orderDetailsobjectnone
pendingQuantitystringQuantity which is in a waiting state to be filled in a specific trade.
avgExecutionPricestringAverage price at which the quantities were bought/sold during the day.
orderPlacedBystringClient code of the user who placed the order.
tradingSymbolstringTrading Symbol of the scrip.
triggerPricestringThe price at which an order should be triggered in the case of SL.
exchangestringName of the exchange. Valid exchange values are BSE, NSE, NFO, MCX, and CDS. If not provided, the default is NSE. For BSE, NFO, CDS, and MCX, it is mandatory.
totalQuantitystringTotal Quantity.
expirystringExpiry date of the trading symbol.
transactionTypestringType of the transaction, BUY / SELL.
productTypestringProduct Type of order as placed by the user. It can be CNC (Cash and Carry), BO (Bracket Order), CO (Cover Order), NRML (Normal), MIS (Intraday).
orderTypestringType of order the user has placed. It can be L (Limit Order), SL (Stop Limit).
quantitystringOrder Quantity as placed by the user.
filledQuantitystringQuantity filled in a specific trade. Can be less than or equal to the total quantity.
orderPricestringLimit price entered at the time of placing the order.
filledPricestringPrice at which the exchange has filled the order.
exchangeOrderNostringOrder identifier at the exchange.
orderValiditystringValidity of the order.
orderTimestringOrder placement time.