Skip to Main Content
POST/NorenWClientAPI/SetAlert

Set Alert

Create a price/condition-based alert on a symbol. A plain notification-only condition — GTT orders use the dedicated Place GTT Order endpoint instead.

API Endpoint

MethodPOST
URLhttps://api.shoonya.com/NorenWClientAPI/SetAlert
Content-Typeapplication/x-www-form-urlencoded
PayloadjData=<JSON payload>&jKey=<AccessToken> — requires a valid AccessToken from Login.

Overview

Set Alert registers a condition evaluated against the live LTP feed. Use Get Enabled GTT Orders to see which ai_t values your account supports before setting one. For an order that should fire automatically on trigger, use Place GTT Order instead — that's a separate endpoint, not this one with a different validity.

Parameters

FieldTypeRequiredDescriptionAllowed Values
uidstringRequiredUser ID of the logged-in user.Account-specific
tsymstringRequiredTrading symbol the alert is set on.Must exist in Symbol Master
exchstringRequiredExchange segment.See Exchange Segment Codes
ai_tstringRequiredAlert type — what the condition is evaluated against.See Get Enabled GTT Orders
validitystringRequiredAlert validity.DAY, GTT
dstringOptionalValue to compare against LTP to decide when the alert fires.Numeric string
remarksstringRequiredFree-text message stored with the alert for identification.Free text

Request Examples

import requests
import json
 
payload = {
    "uid": "AB1234",
    "tsym": "RELIANCE-EQ",
    "exch": "NSE",
    "ai_t": "LTP",
    "validity": "DAY",
    "d": "2500",
    "remarks": "breakout-watch",
}
data = f"jData={json.dumps(payload)}&jKey={accessToken}"
 
response = requests.post(
    "https://api.shoonya.com/NorenWClientAPI/SetAlert",
    data=data,
)
result = response.json()
 
if result.get("al_id"):
    print("Alert created:", result["al_id"])
else:
    print("Alert rejected:", result.get("emsg"))
const payload = {
  uid: "AB1234",
  tsym: "RELIANCE-EQ",
  exch: "NSE",
  ai_t: "LTP",
  validity: "DAY",
  d: "2500",
  remarks: "breakout-watch",
};
 
const data = `jData=${JSON.stringify(payload)}&jKey=${accessToken}`;
 
const res = await fetch("https://api.shoonya.com/NorenWClientAPI/SetAlert", {
  method: "POST",
  headers: { "Content-Type": "application/x-www-form-urlencoded" },
  body: data,
});
const result = await res.json();
console.log(result.al_id ? `Alert created: ${result.al_id}` : `Rejected: ${result.emsg}`);
curl -X POST https://api.shoonya.com/NorenWClientAPI/SetAlert \
  -H "Content-Type: application/x-www-form-urlencoded" \
  --data-urlencode 'jData={"uid":"AB1234","tsym":"RELIANCE-EQ","exch":"NSE","ai_t":"LTP","validity":"DAY","d":"2500","remarks":"breakout-watch"}' \
  --data-urlencode "jKey=$ACCESS_TOKEN"

Response

json
// Success
{
  "request_time": "11:22:26 08-04-2021",
  "stat": "OI created",
  "al_id": "210408000000004"
}
 
// Failure
{
  "stat": "Not_Ok",
  "emsg": "Session Expired : Invalid Session Key"
}
FieldDescription
statSuccess/failure indication. On success this is a status message rather than a plain Ok flag — check for al_id being present as the reliable success signal.
request_timePresent only on success.
al_idAlert ID, needed for Cancel Alert / Modify Alert.
emsgPresent only on failure — e.g. Invalid Input, Session Expired.

Best Practices

  • Store the returned al_id immediately — there's no idempotency key on this call, so a network timeout leaves you unable to tell whether the alert was created without listing your alerts and matching on tsym + remarks.
  • Validate ai_t against Get Enabled GTT Orders before calling this, rather than discovering an unsupported type from emsg.
  • Use a distinct, greppable remarks value per alert so you can reconcile alerts against your own system after the fact, the same way Place Order recommends for orders.