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
| Name | Type | Required | Description |
|---|---|---|---|
symbolName | string | true | Pass 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). |
exchange | string | true | Name 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. |
transactionType | string | true | The transaction type should be either BUY or SELL. |
orderType | string | true | The type of order. It can be one of the following: L (Limit Order), SL (Stop Loss Limit). |
quantity | string | true | The quantity with which the order is being placed. |
disclosedQuantity | string | false | If provided, it should be a minimum of 10% of the actual quantity. |
price | string | false | Price is mandatory when the order type is L (Limit Order) or SL (Stop Loss Limit). |
orderValidity | string | true | Order 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. |
afterMarketOrderFlag | string | false | After Market Order Flag. Acceptable values are YES or NO. |
productType | string | true | The product type of the order. It can be CNC (Cash and Carry), NRML (Normal), or MIS (Intraday). |
triggerPrice | string | false | The price at which an order should be triggered in the case of SL (Stop Loss). |
Sample Request Body
requestBody={
"symbolName":"IDEA",
"exchange":"NSE",
"transactionType":"BUY",
"orderType":"L",
"quantity": "1",
"disclosedQuantity":"1",
"orderValidity":"DAY",
"productType":"CNC",
"afterMarketOrderFlag":"NO",
"price":"13.40"
}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
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"}'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());
}
}(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);
})();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
{
"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"
}
}{
"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
| Name | Type | Description |
|---|---|---|
serverTime | string | Time at Server. |
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. |
orderNumber | string | Unique Order identifier generated after placing an order which could be used for tracking order status. |
status | string | Status of the order. It would be success or failure. |
statusMessage | string | Order placement status Message. |
exchangeOrderStatus | string | Status of the order execution at the Exchange side. Most common values are PENDING, COMPLETE, REJECTED, CANCELLED, and OPEN. |
rejectionReason | string | If an order is rejected, the cause of order rejection, which comes as a user-friendly textual description. |
orderDetails | object | none |
pendingQuantity | string | Quantity which is in a waiting state to be filled in a specific trade. |
avgExecutionPrice | string | Average price at which the quantities were bought/sold during the day. |
orderPlacedBy | string | Client code of the user who placed the order. |
tradingSymbol | string | Trading Symbol of the scrip. |
triggerPrice | string | The price at which an order should be triggered in the case of SL. |
exchange | string | Name 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. |
totalQuantity | string | Total Quantity. |
expiry | string | Expiry date of the trading symbol. |
transactionType | string | Type of the transaction, BUY / SELL. |
productType | string | Product 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). |
orderType | string | Type of order the user has placed. It can be L (Limit Order), SL (Stop Limit). |
quantity | string | Order Quantity as placed by the user. |
filledQuantity | string | Quantity filled in a specific trade. Can be less than or equal to the total quantity. |
orderPrice | string | Limit price entered at the time of placing the order. |
filledPrice | string | Price at which the exchange has filled the order. |
exchangeOrderNo | string | Order identifier at the exchange. |
orderValidity | string | Validity of the order. |
orderTime | string | Order placement time. |