Cancel OCO Order
Overview
The Cancel OCO Order API lets you withdraw an existing OCO order pair before either leg has triggered. This is used when you no longer want the stop-loss/target condition to remain active on a position.
Key benefits:
- Single Call Cancels Both Legs: Cancelling the OCOid removes both linked legs together — no need to cancel each leg separately.
- No Market Re-Validation Required: Unlike Place and Modify, cancellation doesn't require trigger prices to straddle the current LTP, since you're withdrawing the order, not changing its condition.
- Immediate Effect: Once cancelled, neither leg can trigger, freeing up any margin or quantity blocked against the order.
Endpoint & Method
POST
/cancelOcoOrder
URL:
https://api.firstock.in/V1/cancelOcoOrderHeaders:
| Name | Value |
|---|---|
| Content-Type |
application/json |
Body:
| Field | Type | Mandatory | Description | Example |
|---|---|---|---|---|
| userId |
string |
Yes |
Unique identifier for |
AB1234 |
| jKey |
string |
Yes |
Active session token obtained from a successful login. |
6c83407h89jbt8om0n8... |
| exchange |
string |
Yes |
Exchange segment for |
NSE |
| tradingSymbol |
string |
Yes |
Trading symbol for |
VIKASECO-EQ |
| validity |
string |
No |
Order validity. Defaults |
GTT |
| ltp |
string |
No |
Last traded price to |
1.03 |
| OrderParamsLeg1 |
object |
Yes |
Parameters for the first |
- |
| OrderParamsLeg2 |
object |
Yes |
Parameters for the second leg |
- |
| Field | Type | Mandatory | Description | Example |
|---|---|---|---|---|
| userId |
string |
Yes |
Unique identifier for |
AB1234 |
| jKey |
string |
Yes |
Active session token obtained from a successful login. |
6c83407h89jbt8om0n8... |
| OCOid |
string |
Yes |
The OCO order ID to cancel. |
26100600000035 |
| exch |
string |
Yes |
Exchange segment. |
NSE |
| tradingSymbol |
string |
Yes |
Trading symbol. |
VIKASECO-EQ |
Request:
{
"userId": "{{userId}}",
"jKey": "{{jKey}}",
"OCOid": "26100600000035",
"exch": "NSE",
"tradingSymbol": "VIKASECO-EQ"
}
Example Usage
curl --location 'https://api.firstock.in/V1/cancelOcoOrder' \
--header 'Content-Type: application/json' \
--data '{
"userId": "{{userId}}",
"jKey": "{{jKey}}",
"OCOid": "26100600000035"
}'
Response
{
"status": "success",
"message": "OCO order cancelled",
"data": {
"OCOid": "26100600000035",
"Status": "OI deleted"
}
}
{
"status": "failed",
"code": "401",
"name": "UNAUTHORIZED",
"error": {
"field": "auth",
"message": "User ID not found in context"
}
}