Skip to content

Create Basket Order

POST basket/createOrder

The create order API is used to add a new order to a specified basket. This operation allows users to specify the details of the order, including the product, quantity, and any special instructions.

Parameters

NameTypeRequiredDescription
basketIDstringtrueThe ID of the basket to which the order needs to be added.
symbolNamestringtrueThe stock symbol to be traded.
exchangestringtrueThe exchange where the stock is listed.
transactionTypestringtrueIndicates whether the transaction is BUY or SELL.
orderTypestringtrueSpecifies the order type (e.g., L - Limit, SL - Stop Limit).
orderValiditystringtrueSpecifies the order's validity duration.
productTypestringtrueSpecifies the product type (e.g., CNC - Cash and Carry, CO - Cover Order, BO - Bracket Order, NRML, MIS).
quantitystringtrueThe number of shares or units to be traded.
disclosedQuantitystringtrueThe quantity to be disclosed in the market, which can be equal to or less than the order quantity.
pricestringfalseThe execution price for the order. Mandatory for L or SL orders.
priceTypestringfalseApplicable only for BO orders. Valid options: LTP (Last Traded Price) or ATP (Average Traded Price). Default is LTP.
squareOffValuestringfalseThe value used to square off the position automatically. Applicable only for BO orders.
stopLossValuestringfalseThe stop-loss value. Applicable only for BO orders.
valueTypestringfalseThe type of value for Stop Loss and Square Off. Valid options: Absolute or Ticks. Default is Absolute. Applicable only for BO orders.
trailingStopLossstringfalseIncremental value as a percentage of the price change. The trailing stop loss moves with price increases but stays fixed if the price drops. Applicable only for BO orders.
triggerPricestringfalseThe price at which the order will be triggered. Applicable for SL orders.

Sample Request Body

json
requestBody={
  "basketID": "88",
  "symbolName": "INFY",
  "exchange": "NSE",
  "transactionType": "BUY",
  "orderType": "L",
  "orderValidity": "DAY",
  "productType": "MIS",
  "quantity": "150",
  "disclosedQuantity": "",
  "price":"1800",
  "triggerPrice": "1925.30"
}
json
requestBody={
  "basketID": "88",
  "symbolName": "HDFCBANK",
  "exchange": "NSE",
  "transactionType": "BUY",
  "orderType": "L",
  "orderValidity": "DAY",
  "productType": "CNC",
  "quantity": "50",
  "disclosedQuantity": "50",
  "price": "1600"
}
json
requestBody={
  "basketID": "88",
  "symbolName": "RELIANCE",
  "exchange": "NSE",
  "transactionType": "BUY",
  "orderType": "L",
  "orderValidity": "DAY",
  "productType": "BO",
  "quantity": "100",
  "disclosedQuantity": "50",
  "price": "2700",
  "squareOffValue": "3000",
  "stopLossValue": "2690",
  "valueType": "Absolute",
  "trailingStopLoss": "10",
  "priceType": "LTP"
}

Sample Code

bash
curl -X POST 'https://tradeapi.samco.in/basket/createOrder' \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'x-session-token: <SESSION_TOKEN>' \
  -d '{"basketID":"88","symbolName":"INFY","exchange":"NSE","transactionType":"BUY","orderType":"L","orderValidity":"DAY","productType":"MIS","quantity":"150","disclosedQuantity":"","price":"1800","triggerPrice":"1925.30"}'
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 = """
        {
          "basketID": "88",
          "symbolName": "INFY",
          "exchange": "NSE",
          "transactionType": "BUY",
          "orderType": "L",
          "orderValidity": "DAY",
          "productType": "MIS",
          "quantity": "150",
          "disclosedQuantity": "",
          "price": "1800",
          "triggerPrice": "1925.30"
        }
        """;

    HttpClient client = HttpClient.newHttpClient();

    HttpRequest request = HttpRequest.newBuilder()
        .uri(URI.create("https://tradeapi.samco.in/basket/createOrder"))
        .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 = {
    basketID: "88",
    symbolName: "INFY",
    exchange: "NSE",
    transactionType: "BUY",
    orderType: "L",
    orderValidity: "DAY",
    productType: "MIS",
    quantity: "150",
    disclosedQuantity: "",
    price: "1800",
    triggerPrice: "1925.30"
  };

  const response = await fetch('https://tradeapi.samco.in/basket/createOrder', {
    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 = {
  "basketID": "88",
  "symbolName": "INFY",
  "exchange": "NSE",
  "transactionType": "BUY",
  "orderType": "L",
  "orderValidity": "DAY",
  "productType": "MIS",
  "quantity": "150",
  "disclosedQuantity": "",
  "price": "1800",
  "triggerPrice": "1925.30"
}

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

print(r.json())

Sample Responses

json
{
    "serverTime": "26/12/24 16:21:36",
    "msgId": "c5268be4-f1c5-488b-bc86-69b06317aeb0",
    "status": "Success",
    "statusMessage": "Order Added Successfully",
    "basketDetails": {
        "clientId": "RM37283",
        "basketId": 88,
        "basketOrderId": 39,
        "displayOrder": 39,
        "exchange": "NSE",
        "tradingSymbol": "INFY-EQ",
        "transactionType": "BUY",
        "productCode": "MIS",
        "orderType": "L",
        "quantity": 150,
        "orderPrice": 1800,
        "createdAt": "2024-12-26 16:21:38"
    }
}
json
{
    "serverTime": "26/12/24 16:28:24",
    "msgId": "d1b5be1c-2dff-4e7d-a566-fd642c594015",
    "status": "Success",
    "statusMessage": "Order Added Successfully",
    "basketDetails": {
        "clientId": "RM37283",
        "basketId": 88,
        "basketOrderId": 41,
        "displayOrder": 41,
        "exchange": "NSE",
        "tradingSymbol": "HDFCBANK-EQ",
        "transactionType": "BUY",
        "productCode": "CNC",
        "orderType": "L",
        "quantity": 50,
        "orderPrice": 1680,
        "createdAt": "2024-12-26 16:28:25"
    }
}
json
{
    "serverTime": "26/12/24 16:29:21",
    "msgId": "c1f4dadb-06b0-417e-9b73-dc3020851d6d",
    "status": "Success",
    "statusMessage": "Order Added Successfully",
    "basketDetails": {
        "clientId": "RM37283",
        "basketId": 88,
        "basketOrderId": 43,
        "displayOrder": 43,
        "exchange": "NSE",
        "tradingSymbol": "RELIANCE-EQ",
        "transactionType": "BUY",
        "productCode": "BO",
        "orderType": "L",
        "quantity": 100,
        "orderPrice": 1200,
        "stoplossValue": "1190",
        "squareOffValue": "1300",
        "trailingStopLoss": "10",
        "createdAt": "2024-12-26 16:29:21"
    }
}

Response Schema

Status Code 200

NameTypeDescription
serverTimestringThe timestamp when the order response was generated by the server.
msgIdstringA unique identifier for the order response message.
statusstringThe outcome of the order request (e.g., Success, Failure).
clientIdstringA unique identifier for the client who placed the order.
basketIdstringThe identity of the user or customer associated with the order.
basketOrderIdstringThe identifier for the specific order in the user's basket.
displayOrderstringDispaly order at this number.
triggerPricestringThe price at which a conditional order, such as a Stop Loss, is triggered.
exchangestringThe stock exchange where the order is being executed (e.g., NSE).
tradingSymbolstringThe symbol representing the stock or asset being traded (e.g., AAPL).
transactionTypestringThe type of trade (e.g., BUY, SELL).
productCodestringThe type of trading product (e.g., BO, CO, MIS, CNC, NRML).
orderTypestringThe nature of the order (e.g., L for Limit, SL for Stop Loss).
quantitystringThe number of units being bought or sold.
orderPricestringThe price at which the order was executed or filled.
stoplossValuestringThe price at which the Stop Loss order will trigger.
squareOffValuestringThe price at which the order is expected to be squared off (completed).
trailingStopLossstringThe price level for a trailing stop loss, adjusting as the price moves.
createdAtstringThe timestamp when the order was initially placed.