Skip to main content

Order & Report

Cancel Order

A cancelled order is a previously submitted order to buy or sell a security that gets cancelled before it executes on an exchange.

As long as an order remains active or in a state of pending in the system, it can be canceled.

Method: POST

https://connect.thefirstock.com/api/V4/cancelOrder

Request details

API Parameters
Parameter Description Example
userId
string
Identifier for the user upon login, unique
to each user in the system.
AA0013
jKey
string
Authentication token obtained from
the login API
be1ab734ae55aed00d2b730bb592136c
orderNumber
string
Order number,which needs to be
cancelled
89089875

Libraries and SDKs

Tabbed Interface
from thefirstock import thefirstock

cancelOrder = thefirstock.firstock_cancelOrder(
   userId="{{userId}}",
   orderNumber="23111100000112"
)
curl --location --request POST 'https://connect.thefirstock.com/api/V4/cancelOrder' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jKey": "{{jKey}}",
    "userId": "{{userID}}",
    "orderNumber": "23111100000112"
}'
const Firstock = require("thefirstock");

const firstock = new Firstock();

firstock.cancelOrder(userId: {{userId}},{ orderNumber: "11030800009600" }, (err, result) => {
  console.log("Error, ", err);
  console.log("Result: ", result);
});
using thefirstock;

class Program
{
    public static void Main()
    {
        Firstock firstock = new Firstock();
        var result = firstock.cancelOrder(( userId="{{userId}}" ),orderNumber: "11030800009600");
    }
}

Success response details

API Parameters
Parameter Description Example
data.requestTime
string
Indicates the time at which the response
was received, providing a timestamp for
the transaction.
14:45:38 15-02-2023
status
string
Represents the status of the API
request, indicating whether it
was processed successfully or not.
success
data.orderNumber
string
Unique identifier for the order,
provided upon successful placement
23111100000112
{
  "status": "success",  
  "data": {    
    "requestTime": "14:45:38 15-02-2023",  
    "orderNumber": "1234567890111"  
	}
}

Failure response details

API Error Parameters
Parameter Description Example
status
String
Indicates the result status of the API operation failed
code
String
HTTP status code associated with the error 404
name
String
Specifies the type or category of the
error encountered
ORDER_NOT_FOUND
error.field
String
Field in the request that triggered the error orderNumber
error.message
String
Detailed message describing the error Order not found to cancel
{ 
  "status": "failed",
  "code": "404", 
    "name": "ORDER_NOT_FOUND",
    "error": {   
      "field": "orderNumber",    
      "message": "Order not found to cancel"  
  }
}