Orders & Reports

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

Document

POST

/cancelOcoOrder

URL:

https://api.firstock.in/V1/cancelOcoOrder

Headers:

Order Placement API Parameters
Name Value
Content-Type

application/json

Body:

Order Placement API Parameters
Field Type Mandatory Description Example
userId

string

Yes

Unique identifier for
your Firstock account
(same as used during login).

AB1234

jKey

string

Yes

Active session token
obtained from a successful
login.

6c83407h89jbt8om0n8...

exchange

string

Yes

Exchange segment for
both legs.

NSE

tradingSymbol

string

Yes

Trading symbol for
both legs.

VIKASECO-EQ

validity

string

No

Order validity. Defaults
internally to GTT
(Good Till Triggered)
regardless of value sent.

GTT

ltp

string

No

Last traded price to
validate against.
If omitted, the server
fetches the live LTP internally.

1.03

OrderParamsLeg1

object

Yes

Parameters for the first
leg (e.g. stop-loss).
See table below.

-

OrderParamsLeg2

object

Yes

Parameters for the second leg
(e.g. target). See table below.

-

Order Placement API Parameters
Field Type Mandatory Description Example
userId

string

Yes

Unique identifier for
your Firstock account

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

Multiple Tabbed Interfaces
Curl
curl --location 'https://api.firstock.in/V1/cancelOcoOrder' \
--header 'Content-Type: application/json' \
--data '{
  "userId": "{{userId}}",
  "jKey": "{{jKey}}",
  "OCOid": "26100600000035"
}'




Response

Multiple Tabbed Interfaces
200
400
{
  "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"
  }
}