Place Order

POSTJSONRest API
0

Daily API Calls

100%

Success Rate

150ms

Avg. Response Time


The Order API is the backbone of the trading system as it allows the application to place an order through the client’s demat account. 

The API requires authentication for successful execution. The authentication can be provided by passing the Access token(Bearer token).

The API is flexible with a variety of orders and allows the users to place the following type of orders:

  • Limit Order
  • Market Order
  • Stop Loss Order
  • Stop Loss – Market Order
  • After Market Order
  • IOC Order

The above-mentioned types of orders can be placed as intraday or delivery. 

The API works either with ScripCode or ScripData, ScripData format is mentioned here. 

Order Tracking

Once an order is placed, its status can be tracked through the following methods:

  • Order Status API
  • Order Book
  • Order Confirmation via WebSocket (recommended)

Upon placing an order, the API returns a BrokerOrderId. This BrokerOrderId can then be used to fetch the ExchangeOrderId. All three of the aforementioned order APIs can help you map the BrokerOrderId to the ExchangeOrderId.

RemoteOrderId Usage

Overview

We have introduced the RemoteOrderId field as a user-defined identifier. Partners or clients can create their own RemoteOrderId and include it when placing an order. This identifier serves several purposes:

  • Track Order Status: Use the RemoteOrderId to track the order status via the Order Stand API.
  • Obtain ExchangeOrderId: Retrieve the ExchangeOrderId using the RemoteOrderId, which can then be used to modify the order.

 

Usage and Benefits

In certain scenarios, specifically with Stop-Loss (SL) orders, we have observed issues where the BrokerOrderId changes, causing clients to be unable to map the ExchangeOrderId from the broker ID. To mitigate this issue, we recommend using the RemoteOrderId.

REQUEST URL
https://Openapi.5paisa.com/VendorsAPI/Service1.svc/V1/PlaceOrderRequest

Headers

KEYVALUE

Content-Type

application/json

Authorization

bearer {Your Access Token}

Request body

FIELD NAMEMANDATORYDESCRIPTION
p_Data

head

Key

STRING

Yes

AppKey of User or Partner 
 

body

OrderType

STRING

Yes

Represents if it is buy or sell order.

B: Buy
S: Sell

Exchange

STRING

Yes

This is the exchange of the instrument

N: NSE
B: BSE
M: MCX

ExchangeType

STRING

Yes

This is the exchange segment of the instrument

C: Cash
D: Derivatives (FnO of NSE, BSE & MCX)
U: Currency

ScriCode

STRING

YesScripCode of the instrument

ScriData

STRING

Yes

It is the unique symbol of the instrument for which order needs to be placed, format is mentioned below.

Price

DOUBLE

No

It is the price at which order needs to be placed. (0 for market orders).

Qty

INTEGER

Yes

Total quantity in the modified order

StopLossPrice

DOUBLE

No

It is the stop loss price for the order

DisQty

INTEGER

No

It is the quantity to be disclosed publicly 

IsIntraday

BOOLEAN

No

It specifies if the order is intraday or delivery order

Intraday: true
Delivery: false

AHPlaced

STRING

No

It specifies if the order is after market order or not

After Market: Y
Limt/At-market: N

RemoteOrderID

STRING

Yes

This is a unique ID which user can generate for his/her reference

 

Note

  1. If the price is not passed in the request body, its value will be considered as 0. The 0 value of price indicates order to be of at-market type. It takes market price by default.
  2. Disclosed quantity passed in the field “DisQty” should always be less than or equal to the value of the field “Qty”.
  3. The values of exchange, exchange type, ScripCode , symbol name, expiry, option type and strike can be fetched from the scrip master.
  4. The field “ScripData” follows a particular structure for the stocks which is mentioned below:
     

Symbol Format - scripData

INSTRUMENT TYPESYMBOL FORMATSAMPLE VALUE

Cash

Symbol Name_EQ

RELIANCE_EQ

Derivatives

Futures-

SYMBOL Name_yyyymmdd

Derivatives -SYMBOL_YYYYMMDD_CE/PE_STRIKE

Futures - NIFTY 30 Sep 2021_20210930

Options - BANKNIFTY 29 Mar 2023 CE 41600.00_20230329_CE_41600

 

Currency

Symbol Name_Expiry_Option Type_Strike Rate

GBPINR 29 Dec 2021 CE 107.2500_1325255400_CE_107.25

Commodity

Symbol Name_Expiry_Option Type_Strike Rate

SILVER 27 Aug 2021 CE 63750.00_1314489600_CE_63750

SAMPLE REQUEST BODY  :

{
    "head": {
        "key": "{{Your App Key}}"
    },
    "body": {
        "Exchange":"N",
        "ExchangeType":"C",
        "ScripCode":"1660",
        "Price": "445",
        "StopLossPrice": "0",
        "OrderType": "Buy",
        "Qty": 1,
        "DisQty": "0",
        "IsIntraday": true,
        "iOrderValidity": "0",
        "AHPlaced":"N"
    }
}

Response body

FIELD NAMEVALUESDESCRIPTION

head

responseCode

STRING

5PPlaceOrdReqV1

This is the unique response code for the API.

status

STRING

-1: Server unable to process your request

0: Success

1: Invalid input parameters.

2: Invalid head parameters.

This is the status code which depicts the status of API request to the server.

statusDescription

STRING

Server unable to process your request

Success

Invalid input parameters.

Invalid head parameters.

This is the description of the status received from the server for the API request.

body

BrokerOrderID

INTEGER

-

This is the order ID generated from the Broker's end

ClientCode

STRING

-

This is the 5paisa demat account client code of the user

Exch

STRING

N: NSE
B: BSE
M: MCX

This is the exchange of the instrument

ExchOrderID

INTEGER

-

This is the order ID generated by the exchange.

ExchType

STRING

C: Cash
D: Derivatives (FnO of NSE, BSE & MCX)
U: Currency 

This is the exchange segment for the order

LocalOrderID

INTEGER

-

This is the numeric local order ID generated by the user

Message

STRING

0: Success
1: 5paisa System (RMS) Response
2: Invalid Input Parameters.
9: Authentication Fails
 

This is the status description of the order API request based on input parameters

RMSResponseCode

INTEGER

-

This is the status code of the order received from 5paisa Securities system

RemoteOrderID

STRING

-

This is the unique order ID passed for the order while sending the request

ScripCode

INTEGER

-

This is the numeric code for the instrument in which order has been placed

Status

INTEGER

0: Success
1: 5paisa System (RMS) Response
2: Invalid Input Parameters.
9: Authentication Fails

This is the status code of the API response

Time

DATETIME

-
 

This is the time at which order has been placed

 SAMPLE SUCCESS RESPONSE  
{
    "body": {
        "BrokerOrderID": 672112769,
        "ClientCode": "CLIENT_CODE",
        "Exch": "N",
        "ExchOrderID": "0",
        "ExchType": "C",
        "LocalOrderID": 0,
        "Message": "Success",
        "RMSResponseCode": 1,
        "RemoteOrderID": "YESBANKTESTING15",
        "ScripCode": 11915,
        "Status": 0,
        "Time": "/Date(1658255400000+0530)/"
    },
    "head": {
        "responseCode": "5PPlaceOrdReqV1",
        "status": "0",
        "statusDescription": "Success"
    }
}
 SAMPLE FAILURE RESPONSE  Failure due to invalid user key being passed in the request
{
    "body": null,
    "head": {
        "responseCode": "5PPlaceOrdReqV1",
        "status": "2",
        "statusDescription": "Invalid Head Parameters"
    }
}
 SAMPLE FAILURE RESPONSE  Failure due to invalid JWT token passed in the request
{
    "body": {
        "BrokerOrderID": 0,
        "ClientCode": "",
        "Exch":"?”, 
        "ExchOrderID": "",
        "ExchType":"?”, 
        "LocalOrderID": 0,
        "Message": "Authentication Fails",
        "RMSResponseCode": 0,
        "ScripCode": 0,
        "Status": 9,
        "Time": "/Date(1637494442204+0530)/"
    },
    "head": {
        "responseCode": "5PPlaceOrdReqV1",
        "status": "0",
        "statusDescription": "Fail"
    }
}
 SAMPLE FAILURE RESPONSE  Failure when client code is not passed respective to the user's JWT token
{
    "body": {
        "BrokerOrderID": 0,
        "ClientCode": "",
        "Exch":"?”, 
        "ExchOrderID": "",
        "ExchType":"?”, 
        "LocalOrderID": 0,
        "Message": "Invalid Session",
        "RMSResponseCode": 0,
        "ScripCode": 0,
        "Status": 9,
        "Time": "/Date(1637494569494+0530)/"
    },
    "head": {
        "responseCode": "5PPlaceOrdReqV1",
        "status": "0",
        "statusDescription": "Fail"
    }
}
Failure due to missing mandatory parameters in the request
{
    "body": {
        "BrokerOrderID": 0,
        "ClientCode": "5paisa_Client",
        "Exch":"?”, 
        "ExchOrderID": "0",
        "ExchType":"?”, 
        "LocalOrderID": 0,
        "Message": "Invalid Input Parameters.",
        "RMSResponseCode": 0,
        "ScripCode": 0,
        "Status": 2,
        "Time": "/Date(1637494757568+0530)/"
    },
    "head": {
        "responseCode": "5PPlaceOrdReqV1",
        "status": "0",
        "statusDescription": "Success"
    }
}
On this Page

Knowledge base

Order modification API is the next thing to checkout
Modify Order API
How to use this API that suits your work flow best
Start using our APIs

Contribute and get rewarded

Help make these Dev Docs great, contribute to the APIs and get rewarded for your contribution

Need Help

Ask Developer Community

Contact Support

 

Changelog

Changes made to our APIs - Changelog

AVENUES