I tried to modify the SL order using the endpoint https://api-hft.upstox.com/v3/order/modify and the pay load values are payload = {
“validity”: “DAY”,
“price”: price,
“order_id”: str(order_id),
“order_type”: order_type,
“trigger_price”: trigger_price,
}
I am getting the error message as 2025-01-21 15:07:52 - ERROR - Failed to update the order 250121000538195. Response code = 400, error message = {‘status’: ‘error’, ‘errors’: [{‘errorCode’: ‘UDAPI100038’, ‘message’: ‘Invalid input passed to the API’, ‘propertyPath’: None, ‘invalidValue’: None, ‘error_code’: ‘UDAPI100038’, ‘property_path’: None, ‘invalid_value’: None}]}
I don’t know which input value is invalid. Please check .
I can able to execute other requests, so it is not the problem with ‘ACCESS_TOKEN’.
Hi @AE9225,
Welcome to the Upstox Community!
We are checking this and will get back to you soon, thanks.
Hi @AE9225,
Could you please share a cURL request for the payload mentioned above? The message you provided is unclear about the format of each value in the key-value pairs. For reference, you can check out example codes at Upstox API Documentation - Modify Order.
Thank you!
The problem is in request invocation. I change the invocation code to
response = requests.put(url, headers=headers, json=payload)
Now it is resolved. Please close this.
Thanks @AE9225 for confirming.
Hi,
Today I updated the SL order# 250123000208649 multiple times and I got the success response.
Response = {‘status’: ‘success’, ‘data’: {‘order_id’: ‘250123000208649’}
But the order is not updated. I started updated it for every five seconds from 2025-01-23 11:30:57 onwards. In all the times I got the success status only.
At the end of the day. I cancelled the order and it’s values are same as when I created the order. Please check the attachment.
Below are some of the timings where the update order API gets executed.
2025-01-23 11:30:57
2025-01-23 11:31:02
2025-01-23 11:31:12
2025-01-23 11:31:18
Let me know if you need any more details.
Hi @AE9225,
We are checking this and will get back to you soon, thanks.
Hi,
I usually execute the script on an Ubuntu system, and the modify order functionality has never updated the SL order. I tested the same script on my Windows machine using the same values, and it worked correctly for the first two executions. However, after that, it started behaving the same way as on Linux. On the Windows machine as well, I am receiving a success message, but the SL order is not being updated.
Please find the log message below for reference:
2025-01-27 12:34:06 - INFO - SL order for instrument is executed successfully. Response = {‘status’: ‘success’, ‘data’: {‘order_id’: ‘250127000269111’}, ‘metadata’: {‘latency’: 10}}
Today, I encountered this issue with order #250127000269111.
Is there any restriction on the number of requests based on the IP address? Actually I waited 2 seconds before and after the API invocation.
Kindly look into this and let me know.
Hi,
I am using below code to update the order.
def update_order(order_id, price, trigger_price, logger, order_type=“SL”):
url = “https://api-hft.upstox.com/v3/order/modify”
headers = {
‘Accept’: ‘application/json’,
‘Authorization’: f’Bearer {ACCESS_TOKEN}',
‘Content-Type’: ‘application/json’ # Specify the content type as JSON
}
payload = {
"validity": "DAY",
"price": price,
"order_id": str(order_id),
"order_type": order_type,
"trigger_price": trigger_price,
}
try:
response = requests.put(url, headers=headers, json=payload)
if response.status_code == 200:
logging.info(f"{order_type} order for instrument is executed successfully. Response = {response.json()}")
return response.json()
else:
logger.error(f"Failed to update the order {order_id}. Response code = {response.status_code}, "
f"error message = {response.json()}")
return None
except requests.exceptions.RequestException as e:
logger.error(f"Network-related error while updating the order {order_id}: {e}")
return None
except ValueError as e:
logger.error(f"Error parsing JSON response for update order {order_id}: {e}")
return None
except Exception as e:
logger.error(f"Unexpected error while modifying the order {order_id}: {e}")
return None
In the payload I am passing price & trigger_price are float type.
Let me know if there is any mistake in the invocation?
Hi @AE9225
We reviewed the logs and found that for a stop-loss limit (SL) buy order, you are passing a trigger price that is greater than the limit price. This is incorrect for SL buy orders.
If you intend to use a trigger price higher than the limit price, you should place a Limit order instead of an SL order. Please refer to the following article for detailed explanations of different order types: What are the different stock market order types on Upstox?
You can verify the same through the Order History API: Order History API Documentation. For example, I placed a Yes Bank SL order with a trigger price greater than the limit price and received the status message: The limit price is worse than the trigger price
, indicating that the modification was unsuccessful.
I hope this clarifies things!
Thank you.
Thank you. It is updating now. Please close this thread.