Skip to Main Content
POST/NorenWClientAPI/Logout

Logout

Terminate the current session with the server.

Overview

Call this endpoint to explicitly invalidate the active session token before your application exits or restarts. Shoonya session tokens are otherwise flushed automatically during the daily Beginning of Day (BOD) process, but an explicit logout is recommended whenever your app controls its own lifecycle — it immediately revokes the token server-side and frees up any WebSocket subscriptions tied to that session.

API Endpoint

MethodPOST
URLhttps://api.shoonya.com/NorenWClientAPI/Logout
Content-Typetext/plain
AuthorizationBearer <AccessToken> — requires a valid AccessToken from Login.
PayloadjData=<JSON payload>

Request

The jData payload:

FieldTypeRequiredDescription
uidstringYesUser ID of the logged-in session.
bash
curl -X POST https://api.shoonya.com/NorenWClientAPI/Logout \
  -H "Content-Type: text/plain" \
  -H "Authorization: Bearer <AccessToken>" \
  -d 'jData={"uid": "FA12345"}'

Response

FieldPossible valueDescription
statOk or Not_OkLogout success or failure status.
request_timePresent only on successful logout.
emsgPresent only if logout fails.
json
{
  "stat": "Ok",
  "request_time": "10:43:41 28-05-2026"
}

On failure:

json
{
  "stat": "Not_Ok",
  "emsg": "Server Timeout : "
}

Python example

python
ret = api.logout()
print(ret)

JavaScript example

javascript
const data = { uid: "FA12345" };

const response = await fetch("https://api.shoonya.com/NorenWClientAPI/Logout", {
  method: "POST",
  headers: {
    "Content-Type": "text/plain",
    "Authorization": `Bearer ${accessToken}`,
  },
  body: "jData=" + JSON.stringify(data),
});

const result = await response.text();
console.log(result);

Behavior notes

  • Once invalidated, the access token cannot be reused — any subsequent API call returns Session Expired and requires a fresh OAuth login.
  • Logging out does not cancel open orders or close positions — it only terminates the API session. Use Cancel Order or Exit Order explicitly if that's the intent.
  • Any active WebSocket connection tied to the session is disconnected once the token is invalidated — reconnect with a fresh token rather than reusing the old socket.