Get GTT Order Details
This API allows you to fetch the current status and details of a specific GTT order. GTT orders continue to be active until they reach their expiration date, except for intraday orders which are only valid for the day they were created. The Get GTT API does not support retrieving completed GTT orders.
Request
curl --location 'https://api.upstox.com/v3/order/gtt?gtt_order_id=GTT-C25280200071351' \
--header 'Content-Type: application/json' \
--header 'accept: application/json' \
--header 'Authorization: Bearer {your_access_token}'
Additional samples in various languages are available in the Sample Code section on this page.
Query Parameters
| Name | Required | Type | Description |
|---|---|---|---|
| gtt_order_id | false | string | The GTT order reference ID for which the order details is required. |
Responses
- 200
- 4XX
Response Body
- Single-Leg
- Multi-Leg
- Trailing Stop Loss
{
"status": "success",
"data": [
{
"type": "SINGLE",
"exchange": "NSE_EQ",
"quantity": 1,
"product": "D",
"rules": [
{
"strategy": "ENTRY",
"status": "SCHEDULED",
"message": null,
"trigger_type": "ABOVE",
"trigger_price": 100,
"transaction_type": "BUY",
"order_id": null
}
],
"trading_symbol": "IDEA",
"instrument_token": "NSE_EQ|INE669E01016",
"gtt_order_id": "GTT-C25090600141213",
"expires_at": 1781029799000000,
"created_at": 1749466010000000
}
],
"metadata": {
"latency": 24
}
}
{
"status": "success",
"data": [
{
"type": "MULTIPLE",
"exchange": "NSE_EQ",
"quantity": 1,
"product": "I",
"rules": [
{
"strategy": "ENTRY",
"status": "FAILED",
"trigger_type": "IMMEDIATE",
"trigger_price": 7.7,
"transaction_type": "BUY",
"message": "The price set should be within the circuit limits. Please modify your order price.",
"order_id": "250228010168535"
},
{
"strategy": "STOPLOSS",
"status": "CANCELLED",
"trigger_type": "IMMEDIATE",
"trigger_price": 7.6,
"transaction_type": "SELL",
"message": "",
"order_id": null
},
{
"strategy": "TARGET",
"status": "CANCELLED",
"trigger_type": "IMMEDIATE",
"trigger_price": 7.64,
"transaction_type": "SELL",
"message": "",
"order_id": null
}
],
"trading_symbol": "IDEA",
"instrument_token": "NSE_EQ|INE669E01016",
"gtt_order_id": "GTT-CU25280200021010",
"expires_at": 1740767399000000,
"created_at": 1740723100000000
}
],
"metadata": {
"latency": 58
}
}
{
"status": "success",
"data": [
{
"type": "MULTIPLE",
"exchange": "NSE_EQ",
"quantity": 1,
"product": "I",
"rules": [
{
"strategy": "ENTRY",
"status": "FAILED",
"trigger_type": "IMMEDIATE",
"trigger_price": 7.7,
"transaction_type": "BUY",
"message": "The price set should be within the circuit limits. Please modify your order price.",
"order_id": "250228010168535"
},
{
"strategy": "STOPLOSS",
"status": "CANCELLED",
"trigger_type": "IMMEDIATE",
"trigger_price": 7.6,
"transaction_type": "SELL",
"message": "",
"order_id": null,
"trailing_gap": 0.5
},
{
"strategy": "TARGET",
"status": "CANCELLED",
"trigger_type": "IMMEDIATE",
"trigger_price": 7.64,
"transaction_type": "SELL",
"message": "",
"order_id": null
}
],
"trading_symbol": "IDEA",
"instrument_token": "NSE_EQ|INE669E01016",
"gtt_order_id": "GTT-CU25280200021010",
"expires_at": 1740767399000000,
"created_at": 1740723100000000
}
],
"metadata": {
"latency": 58
}
}
| Name | Type | Description |
|---|---|---|
| status | string | Indicates the outcome of the request. Typically success for successful operations. |
| data | array | Contains details of the requested GTT order(s). |
| type | string | Specifies the GTT order type. Indicates if it's a single or multi-leg order. Possible values: SINGLE, MULTIPLE. |
| exchange | string | The exchange where the order is placed. Possible values: NSE_EQ, BSE_EQ, etc. |
| quantity | integer | The number of units specified in the order. |
| product | string | Specifies whether the order is for Intraday, Delivery or MTF. Possible values: I (Intraday), D (Delivery), MTF (Margin Trading Facility). |
| instrument_token | string | Unique identifier for the instrument being traded. |
| trading_symbol | string | The symbol of the traded instrument. |
| gtt_order_id | string | Unique identifier assigned to the GTT order. |
| expires_at | integer | The timestamp indicating when the GTT order expires. |
| created_at | integer | The timestamp when the GTT order was created. |
| rules | array | Defines the conditions for order execution, such as trigger price and strategy. |
| rules[].strategy | string | Specifies the role of the rule. Possible values: ENTRY, TARGET, STOPLOSS.ENTRY - Defines the condition for the first-leg order execution (BUY or SELL). TARGET - Sets an exit condition at a predefined profit level. STOPLOSS - Sets an exit condition to limit losses. |
| rules[].status | string | Indicates the status of the rule. Possible values: SCHEDULED, TRIGGERED, EXPIRED, OPEN, COMPLETED, CANCELLED, PENDING, FAILED and INACTIVE. |
| rules[].trigger_type | string | Specifies the condition under which the order is triggered. Possible values: BELOW, ABOVE, IMMEDIATE.BELOW - Triggers when the market price falls below the trigger price. ABOVE - Triggers when the market price rises above the trigger price. IMMEDIATE - A limit order is triggered at the user-specified price irrespective of the LTP. |
| rules[].trigger_price | float | The price at which the order will be triggered based on the condition. |
| rules[].transaction_type | string | Defines whether the order is a buy or sell transaction. Possible values: BUY, SELL. |
| rules[].message | string | This field specifies the error reason when the rule fails. |
| rules[].order_id | string | Unique identifier for the order generated after execution. May be null if the order hasn't been placed yet. |
| rules[].trailing_gap | float | Only applicable for STOPLOSS strategy for TSL orders. This defines the consistent gap between your stop-loss and the market price, letting your stop-loss trail automatically. |
| metadata | object | Metadata information. |
| metadata.latency | integer | The overall time taken by API platform to process the request, measured in milliseconds. |
Error codes
| Error Code | Description |
|---|---|
| UDAPI1135 | GTT order ID must start with 'GTT-' - The order ID should follow the required format. |
Sample Code
- Python
- Node.js
- Java
- PHP
- Python SDK
- Node.js SDK
- Java SDK
import requests
url = 'https://api.upstox.com/v3/order/gtt'
params = {
'gtt_order_id': 'GTT-C25280200071351'
}
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}',
}
try:
# Send the GET request
response = requests.get(url, params=params, headers=headers)
# Print the response status code and body
print('Response Code:', response.status_code)
print('Response Body:', response.json())
except Exception as e:
# Handle exceptions
print('Error:', str(e))
const axios = require('axios');
const url = 'https://api.upstox.com/v3/order/gtt';
const params = {
gtt_order_id: 'GTT-C25280200071351'
};
const headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}'
};
axios.get(url, { headers, params })
.then(response => {
console.log('Response:', response.data);
})
.catch(error => {
console.error('Error:', error.message);
});
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) {
String url = "https://api.upstox.com/v3/order/gtt?gtt_order_id=GTT-C25280200071351";
String token = "Bearer {your_access_token}";
// Create the HttpClient
HttpClient httpClient = HttpClient.newHttpClient();
// Create the HttpRequest
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Content-Type", "application/json")
.header("Accept", "application/json")
.header("Authorization", token)
.GET()
.build();
try {
// Send the request and retrieve the response
HttpResponse<String> response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());
// Print the response status code and body
System.out.println("Response Code: " + response.statusCode());
System.out.println("Response Body: " + response.body());
} catch (Exception e) {
// Handle exceptions
e.printStackTrace();
}
}
}
<?php
$url = 'https://api.upstox.com/v3/order/gtt?gtt_order_id=GTT-C25280200071351';
$headers = [
'Content-Type: application/json',
'Accept: application/json',
'Authorization: Bearer {your_access_token}',
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
if ($response === false) {
echo 'Error: ' . curl_error($ch);
} else {
echo 'Response: ' . $response;
}
curl_close($ch);
?>
import upstox_client
from upstox_client.rest import ApiException
configuration = upstox_client.Configuration()
configuration.access_token = '{your_access_token}'
api_instance = upstox_client.OrderApiV3(upstox_client.ApiClient(configuration))
try:
api_response = api_instance.get_gtt_order_details(gtt_order_id="GTT-C25030300128840")
print("GTT order details:", api_response)
except ApiException as e:
print("Exception when calling OrderApi->get_gtt_order_details: %s\n" % e)
let UpstoxClient = require('upstox-js-sdk');
let defaultClient = UpstoxClient.ApiClient.instance;
var OAUTH2 = defaultClient.authentications['OAUTH2'];
OAUTH2.accessToken = "{your_access_token}";
let apiInstance = new UpstoxClient.OrderApiV3();
apiInstance.getGttOrderDetails({gttOrderId: 'GTT-C25130300047732'}, (error, data, response) => {
if (error) {
console.error(error.response.text);
} else {
console.log('API called successfully. Returned data:', data);
}
});
import com.upstox.ApiClient;
import com.upstox.ApiException;
import com.upstox.Configuration;
import com.upstox.api.*;
public class Main {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setAccessToken("{your_access_token}");
OrderApiV3 apiInstance = new OrderApiV3();
try {
GetGttOrderResponse result = apiInstance.getGttOrderDetails("GTT-C25040144712");
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling OrderApi->getGttOrderDetails: " + e.getMessage());
}
}
}
Loading...