IBKR Session Management

Maintain active sessions with Interactive Brokers to keep your API connection alive and functional. IBKR sessions require periodic validation and refresh to prevent timeout.

Overview

IBKR API sessions have timeouts and require active maintenance. This guide covers the endpoints needed to validate, refresh, and manage your session state.

Key Endpoints

1. Initialize Session

Initialize a new session with Interactive Brokers.

IBKR Documentation

Endpoint:

POST https://api.ibkr.com/v1/api/iserver/auth/ssodh/init

Purpose: Start a new session to establish connection and receive session tokens

Request:

{
  "publish": true,
  "compete": true
}

Response:

{
  "success": {
    "value": {
      "authenticated": true,
      "established": true,
      "competing": false,
      "connected": true,
      "message": "",
      "MAC": "98:F2:B3:23:BF:A0",
      "serverInfo": {
        "serverName": "JifN19053",
        "serverVersion": "Build 10.25.0p, Dec 5, 2023 5:48:12 PM"
      }
    }
  }
}

2. Validate Session

Check if your current session is valid.

IBKR Documentation

Endpoint:

GET https://api.ibkr.com/v1/api/sso/validate

Purpose: Confirm session validity before executing trades

Response:

{
  "success": {
    "value": {
      "USER_ID": 123456789,
      "USER_NAME": "user1234",
      "RESULT": true,
      "AUTH_TIME": 1702580846836,
      "SF_ENABLED": false,
      "IS_FREE_TRIAL": false,
      "CREDENTIAL": "user1234",
      "IP": "12.345.678.901",
      "EXPIRES": 415890,
      "QUALIFIED_FOR_MOBILE_AUTH": null,
      "LANDING_APP": "UNIVERSAL",
      "IS_MASTER": false,
      "lastAccessed": 1702581069652,
      "LOGIN_TYPE": 2,
      "PAPER_USER_NAME": "user1234",
      "features": {
        "env": "PROD",
        "wlms": true,
        "realtime": true,
        "bond": true,
        "optionChains": true,
        "calendar": true,
        "newMf": true
      },
      "region": "NJ"
    }
  }
}

Status Codes:

  • 200 - Session is valid
  • 401 - Session expired or invalid

3. Authentication Status

Get detailed authentication and connection status.

IBKR Documentation

Endpoint:

GET https://api.ibkr.com/v1/api/iserver/auth/status

Purpose: Check if you're authenticated, connected, and competitive (no other sessions)

Response:

{
  "MAC": "12:B:B3:23:BF:A0",
  "authenticated": true,
  "established": true,
  "competing": false,
  "connected": true,
  "hardware_info": "21026956|06:8E:04:45:DA:8F",
  "message": "",
  "serverInfo": {
    "serverName": "JifN19053",
    "serverVersion": "Build 10.25.0p, Dec 5, 2023 5:48:12 PM"
  },
  "fail": ""
}

Response Fields:

FieldMeaning
authenticatedUser is authenticated
connectedAPI connection established
competingAnother session exists (conflicts)

4. Tickle (Keep-Alive)

Send a keep-alive signal to maintain session.

IBKR Documentation

Endpoint:

GET https://api.ibkr.com/v1/api/tickle

Purpose: Refresh session timeout timer. Must be called regularly to keep the session alive.

Response:

{
  "session": "abc123xyz"
}

Keep-Alive Interval: Call every 60 seconds to maintain an active session. If no tickle is received for an extended period, the session will timeout.


5. Suppress Messages

Suppress IBKR confirmation dialogs for specific order types.

IBKR Documentation

Endpoint:

POST https://api.ibkr.com/v1/api/iserver/questions/suppress

Purpose: Avoid confirmation prompts for programmatic trading

Request:

{
  "messageIds": [
    "o163",
    "o354",
    "o382",
    "o383",
    "o403",
    "o451",
    "o2136",
    "o2137",
    "o2165",
    "o10082",
    "o10138",
    "o10151",
    "o10152",
    "o10153",
    "o10164",
    "o10223",
    "o10288",
    "o10331",
    "o10332",
    "o10333",
    "o10334",
    "o10335",
    "o10336",
    "p6",
    "p12"
  ]
}

Response:

{
  "status": "submitted"
}

Common Message IDs:

IDDescription
o163Order confirmation dialogs
o354Risk management warnings
o382Commission warnings
p6General confirmations

Session Maintenance Flow

1. Get Bearer Token
   └─> /brokerage-bearer-token

2. Initialize Session
   └─> POST /v1/api/iserver/auth/ssodh/init

3. Verify Connected
   └─> GET /v1/api/iserver/auth/status

4. Suppress Messages
   └─> POST /v1/api/iserver/questions/suppress

5. Keep Alive (every 60 seconds)
   └─> GET /v1/api/tickle

6. Before Trading
   └─> GET /v1/api/sso/validate
   └─> GET /v1/api/iserver/auth/status

7. Place Orders / Check Status
   └─> POST /v1/api/iserver/account/{acctId}/orders/whatif
   └─> POST /v1/api/iserver/account/{acctId}/orders
   └─> GET /v1/api/iserver/account/order/status/{orderId}

Implementation Example

const IBKR_BASE_PATH = "https://api.ibkr.com";

class SessionManager {
  constructor(bearerToken) {
    this.bearerToken = bearerToken;
    this.sessionId = null;
    this.keepAliveInterval = null;
  }

  async initializeSession() {
    const response = await fetch(
      `${IBKR_BASE_PATH}/v1/api/iserver/auth/ssodh/init`,
      {
        method: "POST",
        headers: {
          Authorization: `Bearer ${this.bearerToken}`,
          "Content-Type": "application/json",
          "User-Agent": "Your Application/1.0",
        },
        body: JSON.stringify({
          publish: true,
          compete: true,
        }),
      },
    );

    const data = await response.json();
    this.sessionId = data.sessionId;
    return data;
  }

  async validateSession() {
    const response = await fetch(`${IBKR_BASE_PATH}/v1/api/sso/validate`, {
      headers: {
        Authorization: `Bearer ${this.bearerToken}`,
        "User-Agent": "Your Application/1.0",
      },
    });

    return response.status === 200;
  }

  async getAuthStatus() {
    const response = await fetch(
      `${IBKR_BASE_PATH}/v1/api/iserver/auth/status`,
      {
        headers: {
          Authorization: `Bearer ${this.bearerToken}`,
          "User-Agent": "Your Application/1.0",
        },
      },
    );

    return response.json();
  }

  async suppressMessages() {
    await fetch(`${IBKR_BASE_PATH}/v1/api/iserver/questions/suppress`, {
      method: "POST",
      headers: {
        Authorization: `Bearer ${this.bearerToken}`,
        "Content-Type": "application/json",
        "User-Agent": "Your Application/1.0",
      },
      body: JSON.stringify({
        messageIds: ["o163", "o354", "o382", "o383", "o403", "o451"],
      }),
    });
  }

  async tickleSession() {
    await fetch(`${IBKR_BASE_PATH}/v1/api/tickle`, {
      headers: {
        Authorization: `Bearer ${this.bearerToken}`,
        "User-Agent": "Your Application/1.0",
      },
    });
  }

  startKeepAlive() {
    this.keepAliveInterval = setInterval(
      () => this.tickleSession(),
      60 * 1000, // Every 60 seconds
    );
  }

  stopKeepAlive() {
    if (this.keepAliveInterval) {
      clearInterval(this.keepAliveInterval);
    }
  }
}

Best Practices

  1. Validate Before Trading - Always check validateSession() before placing orders
  2. Keep Alive - Call tickle every 60 seconds to prevent session timeout
  3. Monitor Status - Regularly check getAuthStatus() for competing sessions
  4. Suppress Early - Suppress messages during session initialization
  5. Handle Errors - Implement retry logic for failed session calls
  6. Session Cleanup - Stop keep-alive timer when done

Troubleshooting

IssueSolution
Session expiredRequest new bearer token and reinitialize
Competing sessionAnother login exists; stop other sessions
Validation failsTickle session and retry
Messages not suppressedEnsure message IDs are correct

Next Steps

Was this page helpful?

PiTrade

PiTrade gives investors in over 190 countries access to the U.S. stock market through real, transparent portfolios you can build yourself or invest in Strategizer Portfolios. As an SEC-registered investment adviser, powered by Interactive Brokers, PiTrade makes investing more transparent and accessible.

This content is provided for informational purposes only and is not intended as and may not be relied on in any manner as investment advice, a recommendation of any interest in any security offered herein. All investments involve risk, including the possible loss of principal. Past performance does not guarantee future results, and investors should consider their own investment goals, risk tolerance, and financial situation before investing. The information contained herein is subject to change.

The platform "PiTrade" is operated by Pioneer Advisory LLC, a subsidiary of Pioneer Investing Inc. which holds ownership rights related hereto.

Advisory services are provided by Pioneer Advisory LLC, an SEC-registered investment adviser.

Brokerage and clearing services are provided by Interactive Brokers LLC, a SEC-registered broker-dealer, member FINRA/SIPC, to retail customers for US-listed, registered securities and ETFs on a self-directed basis.

The registrations and memberships above in no way imply that the SEC, FINRA, or SIPC has endorsed the entities, products or services discussed herein.

Interactive Brokers LLC is a registered Broker-Dealer, Futures Commission Merchant and Forex Dealer Member, regulated by the U.S. Securities and Exchange Commission (SEC), the Commodity Futures Trading Commission (CFTC) and the National Futures Association (NFA), and is a member of the Financial Industry Regulatory Authority (FINRA) and several other self-regulatory organizations. Interactive Brokers does not endorse or recommend any introducing brokers, third-party financial advisors or hedge funds, including Pioneer Advisory LLC. Interactive Brokers provides execution and clearing services to customers. None of the information contained herein constitutes a recommendation, offer, or solicitation of an offer by Interactive Brokers to buy, sell or hold any security, financial product or instrument or to engage in any specific investment strategy. Interactive Brokers makes no representation, and assumes no liability to the accuracy or completeness of the information provided on this website.

For more information regarding Interactive Brokers, please visit www.interactivebrokers.com

© 2026 Pioneer Investing Inc. All Rights Reserved.