Set up an IBKR Flex Query for automatic trade imports

A Flex Query is a saved, read-only report in Interactive Brokers. With a Flex Web Service token, an app can download it on a schedule, so your trades update without manual CSV exports.

Updated October 7, 2026

What you will end up with: a Query ID (a number) and a Flex Web Service token (a long code). Together they let an app download that one report. They cannot place trades, move money or log in to your account.

Step by step

  1. Open the Flex Queries page. In Client Portal click Performance & Reports → Flex Queries (or Menu → Reporting → Flex Queries). If you manage several accounts, select the one to report on.
  2. Create an Activity Flex Query. Click the + next to Activity Flex Query and give it a name such as “IBKR Analyzer”.
  3. Select the Trades section. Click Trades; a pop-up lists its options and fields. Choose Executions, select all fields and click Save. Leave unrelated sections unselected; a smaller report is faster and shares less.
    SectionTradesOptionExecutionsFieldsAll
  4. Set the Delivery Configuration. Format XML, one account. Any Period works, such as Last 30 Calendar Days; an app that syncs requests the exact dates it needs.
    FormatXMLAccountsOne
  5. Set the General Configuration if these options are shown: date format yyyyMMdd, a semicolon (;) between date and time, and a New York timezone so trade dates line up with US market days. Then click Continue and Create.
    Date formatyyyyMMddDate/time separator;
  6. Note the Query ID. The saved query appears in the Activity Flex Query list with its numeric ID.
  7. Turn on Flex Web Service and generate a token. Open Flex Queries → Flex Web Service Configuration, tick Flex Web Service Status and Save. In Should Expire After, choose the longest period: the default is only 6 hours, after which automatic imports stop. Leave Valid For IP Address blank unless you restrict it to the app’s server address, then click Generate New Token. Generating another token later invalidates the previous one.
    StatusActiveShould Expire AfterLongest available
  8. Paste both values into the app. In IBKR Analyzer, open IBKR sync, paste the token and Query ID, and connect. The first sync imports up to a year of available history in batches, newest first.

IBKR’s own instructions: Create an Activity Flex Query and Configure Flex Web Service.

Daily IBKR sync with ProCharts and the P/L calendar update every day from your Flex Query, with optional weekly P/L emails.
See plans

Is a Flex token safe to share with an app?

A Flex token can only download the reports you configured. It cannot trade, transfer funds or read your password. Good practice still applies:

Troubleshooting

“Use an Activity Flex Query instead of a legacy query”

The Query ID belongs to an older query type. Create a new Activity Flex Query and use its ID.

The report has no trades

Check that the Trades section is selected with Executions, and that the account traded in the requested dates. Weekends and holidays legitimately have no executions.

The token stopped working

Tokens expire, after 6 hours by default. Generate a new one with a longer Should Expire After period in Flex Web Service Configuration and update it in the app; your imported history stays.

Numbers are in my base currency instead of the trade currency

Use the default trade-currency report rather than one converted to your base currency, so each currency’s P/L can be checked against IBKR.