Get Query ID (Activity Flex Query ID)

The Query ID is a unique identifier that tells the IBKR system exactly which data points to retrieve—such as trades, cash transactions, or account balances—via the Flex Web Service.

1. Log in to the Client Portal:
Start by logging into your Interactive Brokers Client Portal.

2. Navigate to Flex Queries:
Go to the main menu and select "Performance & Reports" > "Flex Queries".

Interactive Brokers main menu with "Performance & Reports" selected and the "Flex Queries" option highlighted.
Interactive Brokers main menu with "Performance & Reports" selected and the "Flex Queries" option highlighted.

3. Add a Flex Query:
Click the plus "+" icon located next to Activity Flex Query.

Clicking the plus "+" icon next to Activity Flex Query to create a new report.
Clicking the plus "+" icon next to Activity Flex Query to create a new report.

4. Create "Activity Flex Query":
Name your query in the Query Name (e.g., "trades_report").

Screenshot showing how to enter a query name in the Query Name field.
Screenshot showing how to enter a query name in the Query Name field.

Under the Sections menu, choose the data you require, such as Trades.
Ensure you click Select all for the necessary fields within each section.

Interface showing the selection of the Trades section and clicking "Select All" for data fields.
Interface showing the selection of the Trades section and clicking "Select All" for data fields.

In "Delivery Configuration",

"Format" field, choose "CSV".
"Include column headers", choose "Yes".
"Period", select the time range you want to cover (e.g., Last 365 Calendar Days or Year to Date).

Setting Delivery Configuration to CSV format with column headers and a 365-day time range.
Setting Delivery Configuration to CSV format with column headers and a 365-day time range.

In "General Configuration",
"Date Format" choose "yyyyMMdd".
"Time Format" choose "HHmmss".
"Date/Time Separator" choose "; (semi-colon)".

Click "Continue", to final review the setting.

Click "Create" to confirm the setting.

Configuring date format as yyyyMMdd and time format as HHmmss with a semi-colon separator.
Configuring date format as yyyyMMdd and time format as HHmmss with a semi-colon separator.

5. Locate the Created Query:
You should able to see the complete page, click "Ok" to finish.

You will return to the main Flex Queries page. Your new report will now be listed under the "Activity Flex Query" section.

The completed query configuration page with the "Ok" button highlighted to finish.
The completed query configuration page with the "Ok" button highlighted to finish.

6. Retrieve the "Query ID":
Click the information ("i" icon) icon located to the left of your query's name.

Clicking the small information i icon located to the left of the saved query name.
Clicking the small information i icon located to the left of the saved query name.

A pop-up will appear. Copy the "Query ID" number displayed at the top.

A pop-up window displaying the Query ID number available for copying.
A pop-up window displaying the Query ID number available for copying.