Unable to place a BUY order with upstox Api

Hi @Pradeep_Jaiswar ,

I am unable place a BUY order using upstox Api
Please find below code
def place_order(self,quantity,instrument_token,tran_type) :
url =f’https://api-v2.upstox.com/order/place

    headers ={
        'accept': 'application/json',
        'Api-Version': '2.0' ,
        'Content-Type': 'application/json',
        'Authorization': f'Bearer {self.access_token}'
    data = {
            "quantity": quantity,
            "product": self.PRODUCT_D,
            "price": 0.0,
            "tag": self.TAG,
            "instrument_token": instrument_token, #"NSE_EQ|INE848E01016"
            "order_type": self.ORDER_TYPE_MARKET,
            "transaction_type":tran_type ,
            "disclosed_quantity": 0,
            "trigger_price": 0.0,
            "is_amo": self.IS_AMO
    response = requests.post(url,headers=headers,data=data)
    # js_reponse = response.json()["data"]["order_id"]

Status code:-

End Point:-

Please find below dictionary as data:-
{‘quantity’: 15, ‘product’: ‘D’, ‘validity’: ‘DAY’, ‘price’: 0.0, ‘tag’: ‘NA’, ‘instrument_token’: ‘NSE_FO|47344’, ‘order_type’: ‘MARKET’, ‘transaction_type’: ‘BUY’, ‘disclosed_quantity’: 0, ‘trigger_price’: 0.0, ‘is_amo’: False}

{“status”:“error”,“errors”:[{“errorCode”:“UDAPI100038”,“message”:“Invalid input passed to the API”,“propertyPath”:null,“invalidValue”:null,“error_code”:“UDAPI100038”,“property_path”:null,“invalid_value”:null}]}

Please have look and fix the issue

Thank You!!

@nagarjuna Kindly rectify the specified line within your code:

response = requests.post(url, headers=headers, json=data)

Ensure that you include json=data as indicated.

For your reference

Feel free to explore our Python SDK available at GitHub - upstox/upstox-python: Official Python SDK for accessing Upstox API, which handles the initial setup for a swift start. Give it a go and inform us about your experience - we’re here to assist you.

Sure Pradeep, I will check and let you know.
Thank you!!

Hi @Pradeep_Jaiswar ,

I am able to place order using API. Thank You!!

I have used postman for testing the calls but that’s not working

curl --location ‘https://api-v2.upstox.com/order/place
–header ‘accept: application/json’
–header ‘Api-Version: 2.0’
–header ‘Content-Type: application/json’
–header ‘Authorization: Bearer {token added here}’
–data '{
“quantity”: 1,
“product”: “I”,

“validity”: “DAY”,
“price”: 0,
“tag”: “string”,
“instrument_token”: “NSE_INDEX|Nifty Bank”,
“order_type”: “MARKET”,
“transaction_type”: “BUY”,
“disclosed_quantity”: 0,
“trigger_price”: 0,
“is_amo”: false

Response from the call:

"status": "error",
"errors": [
        "errorCode": "UDAPI10001",
        "message": "Something went wrong",
        "propertyPath": null,
        "invalidValue": null,
        "error_code": "UDAPI10001",
        "property_path": null,
        "invalid_value": null


Kindly be aware that trading on the index is prohibited. Please utilize some of the available symbols and attempt trading. Inform us if you encounter any problems with the permissible symbols and we will incorporate clear rejection reasons in our future updates.

@Pradeep_Jaiswar, Can you please provide me the available symbols for trading using API and can you also clarify the following questions.
1.If I place a buy order, what will be the order type(call or put) and the same goes for sell order.
2.If I place a order using Market as the option then in which price will it place the order.

You can locate the accessible trading symbols within the Instruments BOD data on this page: Upstox Developer API - Documentation of investment and trading platform developer API

I recommend gaining a fundamental comprehension of call and put options. You can read an article about call options at this link: What Is Call Option - Definition & Examples, How to Use It

Market orders are fulfilled at the most favorable market price available at the moment the order is placed.

I am unable to place the buy order using python upstox-sdk. I am fetching positions from the portfolio and squaring it of based on my strategy I am using the below code:-

portfolio_api_response = portfolio_api_instance.get_positions(api_version)

for position in portfolio_api_response.data:
data[position.instrument_token] = {
“quantity”: position.quantity,

order_api_instance = upstox_client.OrderApi(upstox_client.ApiClient(configuration))
body = upstox_client.PlaceOrderRequest(
) # PlaceOrderRequest |
order_api_response = order_api_instance.place_order(body, api_version)

the above code is not giving error but also it is not sending the orders to upstox

kindly help please