> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.airtop.ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.airtop.ai/_mcp/server.

# Query a page

POST https://api.airtop.ai/api/v1/sessions/{sessionId}/windows/{windowId}/page-query
Content-Type: application/json

Submit a prompt that queries the content of a specific browser window. You may extract content from the page, or ask a question about the page and allow the AI to answer it (ex. Is the user logged in?).

Reference: https://docs.airtop.ai/api-reference/airtop-api/windows/page-query

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Request

### Path parameters

- `sessionId` (string, required) — The session id for the window.
- `windowId` (string, required) — The Airtop window id of the browser window.

### Body (application/json)

This endpoint expects a SessionPageQueryHandlerRequestBody.

- `prompt` (string, required) — The prompt to submit about the content in the browser window.
- `clientRequestId` (string, optional)
- `configuration` (PageQueryConfig, optional) — Request configuration
- `costThresholdCredits` (long, optional) — A credit threshold that, once exceeded, will cause the operation to be cancelled. Note that this is *not* a hard limit, but a threshold that is checked periodically during the course of fulfilling the request. A default threshold is used if not specified, but you can use this option to increase or decrease as needed. Set to 0 to disable this feature entirely (not recommended).
- `followPaginationLinks` (boolean, optional, default: false) — Make a best effort attempt to load more content items than are originally displayed on the page, e.g. by following pagination links, clicking controls to load more content, utilizing infinite scrolling, etc. This can be quite a bit more costly, but may be necessary for sites that require additional interaction to show the needed results. You can provide constraints in your prompt (e.g. on the total number of pages or results to consider).
- `timeThresholdSeconds` (long, optional) — A time threshold in seconds that, once exceeded, will cause the operation to be cancelled. Note that this is *not* a hard limit, but a threshold that is checked periodically during the course of fulfilling the request. A default threshold is used if not specified, but you can use this option to increase or decrease as needed. Set to 0 to disable this feature entirely (not recommended). This setting does not extend the maximum session duration provided at the time of session creation.

## Response

### 201

Created

- `data` (AiResponseEnvelope, required)
- `meta` (ExternalSessionAiResponseMetadata, required)
- `errors` (list of Issue, optional)
- `warnings` (list of Issue, optional)

## Types

### PageQueryConfig

- `experimental` (PageQueryExperimentalConfig, optional) — Experimental configuration options. These may be subject to change and are not guaranteed to be stable across versions.
- `outputSchema` (string, optional) — JSON schema defining the structure of the output. If not provided, the format of the output might vary.
- `scrape` (ScrapeConfig, optional) — Optional configuration to customize and tweak how the web page is scraped.
- `visualAnalysis` (VisualAnalysisConfig, optional) — Visual analysis configuration. When provided, enables advanced screenshot-based analysis instead of or in addition to DOM scraping.

### AiResponseEnvelope

- `modelResponse` (string, required)

### ExternalSessionAiResponseMetadata

- `status` (enum, required) — Outcome of the operation.
  - Allowed values: `success`, `partial`, `failure`
- `usage` (ExternalSessionAiResponseMetadataUsage, required)
- `clientProvided` (ClientProvidedResponseMetadata, optional)
- `requestId` (string, optional)
- `screenshots` (list of ScreenshotMetadata, optional) — Array containing any requested screenshots from the operation.

### Issue

- `message` (string, required) — Message describing the issue.
- `code` (string, optional) — Issue code.
- `details` (map from string to any, optional) — Any associated details.
- `reason` (string, optional) — Underlying reason for the issue.

### PageQueryExperimentalConfig

- `includeVisualAnalysis` (string, optional, default: auto) — If set to 'enabled', Airtop AI will also analyze the web page visually when fulfilling the request. Note that this can add to both the execution time and cost of the operation. If the page is too large, the context window can be exceeded and the request will fail. If set to 'auto' or 'disabled', no visual analysis will be conducted. If 'followPaginationLinks' is set to true, visual analysis will be conducted unless 'includeVisualAnalysis' is explicitly set to 'disabled'.

### ScrapeConfig

- `optimizeUrls` (string, optional, default: auto) — URL optimization helps improve performance during model analysis, but limits the model's ability to analyze internal details of URLs (such as individual URL parameters). This setting does not affect the ability to extract URLs or links from web pages -- those will work regardless of how this option is set. However, if you need to analyze URLs themselves and are not getting satisfactory results, try setting this option to 'disabled'. If set to 'auto', Airtop AI will automatically determine whether to apply URL optimization. If 'enabled', URLs will always be optimized to improve performance. If 'disabled', URLs will not be optimized.

### VisualAnalysisConfig

- `maxScanScrolls` (long, optional, default: 50) — Scan mode only: The maximum number of scrolls to perform. Defaults to 50.
- `overlapPercentage` (long, optional, default: 30) — The percentage of overlap between screenshot chunks. Defaults to 30 (percent).
- `partitionDirection` (enum, optional, default: vertical) — The direction to partition the screenshot into chunks: 'vertical', 'horizontal', or 'bidirectional'. Defaults to 'vertical', which is recommended for most web pages. For optimal results when partitioning in a single direction, ensure the perpendicular dimension does not exceed 1920 pixels.
  - Allowed values: `vertical`, `horizontal`, `bidirectional`
- `resultSelectionStrategy` (enum, optional, default: auto) — [Experimental] The strategy to use for selecting the match using visual analysis. Can be 'auto', 'first' or 'bestMatch'. Defaults to 'auto'. Use 'auto' to let the system decide the best strategy. Use 'first' to select the first visual element that matches the element description. This will favor results that appear higher on the page in the event of multiple matches. Use 'bestMatch' to analyze the complete page and apply judgement to select the best candidate from all potential matches.
  - Allowed values: `first`, `bestMatch`, `auto`
- `scanScrollDelay` (long, optional, default: 1000) — Scan mode only: The delay between scrolls in milliseconds. Defaults to 1000 (milliseconds).
- `scope` (enum, optional, default: auto) — Whether to analyze the current viewport or the whole page. Can be 'viewport', 'page', 'scan' or 'auto'. Defaults to 'auto', which provides the simplest out-of-the-box experience for most web pages. Use 'viewport' for analysis of the current browser view only. Use 'page' for a full page analysis. Use 'scan' for a full page analysis on sites that have compatibility or accuracy issues with 'page' mode.
  - Allowed values: `viewport`, `page`, `scan`, `auto`

### ExternalSessionAiResponseMetadataUsage

- `credits` (long, required) — The credit usage for this request
- `id` (string, required) — The id of the request

### ClientProvidedResponseMetadata

- `clientRequestId` (string, optional)

### ScreenshotMetadata

- `dataUrl` (string, optional) — Base64 encoded data URL of screenshot image data
- `fileId` (string, optional) — Unique identifier for the uploaded file
- `fileName` (string, optional) — Name of the screenshot file
- `format` (enum, optional) — Format of the screenshot data
  - Allowed values: `base64`, `url`
- `scrollPosition` (ScreenshotScrollPosition, optional) — Scroll position where the screenshot was taken
- `signedDownloadUrl` (string, optional) — Signed URL for downloading the screenshot (when format is 'url')
- `urlExpiry` (string, optional) — Expiration time for the signed URL in ISO format
- `viewportDimensions` (ScreenshotViewportDimensions, optional) — Viewport dimensions of the screenshot

### ScreenshotScrollPosition

- `left` (long, required) — Horizontal scroll position in pixels
- `top` (long, required) — Vertical scroll position in pixels

### ScreenshotViewportDimensions

- `height` (long, required) — Height of the viewport in pixels
- `width` (long, required) — Width of the viewport in pixels

## Examples

**Request**

```json
{
  "prompt": "What is the main idea of this page?"
}
```

**Response**

```json
{
  "data": {
    "modelResponse": "modelResponse"
  },
  "meta": {
    "status": "success",
    "usage": {
      "credits": 1000000,
      "id": "id"
    },
    "clientProvided": {
      "clientRequestId": "clientRequestId"
    },
    "requestId": "requestId",
    "screenshots": [
      {}
    ]
  },
  "errors": [
    {
      "message": "message",
      "code": "code",
      "details": {
        "key": "value"
      },
      "reason": "reason"
    }
  ],
  "warnings": [
    {
      "message": "message",
      "code": "code",
      "details": {
        "key": "value"
      },
      "reason": "reason"
    }
  ]
}
```

**SDK Code**

```python
import requests

url = "https://api.airtop.ai/api/v1/sessions/6aac6f73-bd89-4a76-ab32-5a6c422e8b0b/windows/0334da2a-91b0-42c5-6156-76a5eba87430/page-query"

payload = { "prompt": "What is the main idea of this page?" }
headers = {
    "Authorization": "Bearer <apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```typescript
import { AirtopClient } from "@airtop/sdk";

const client = new AirtopClient({ apiKey: "YOUR_API_KEY" });
await client.windows.pageQuery("6aac6f73-bd89-4a76-ab32-5a6c422e8b0b", "0334da2a-91b0-42c5-6156-76a5eba87430", {
    prompt: "What is the main idea of this page?"
});

```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.airtop.ai/api/v1/sessions/6aac6f73-bd89-4a76-ab32-5a6c422e8b0b/windows/0334da2a-91b0-42c5-6156-76a5eba87430/page-query"

	payload := strings.NewReader("{\n  \"prompt\": \"What is the main idea of this page?\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.airtop.ai/api/v1/sessions/6aac6f73-bd89-4a76-ab32-5a6c422e8b0b/windows/0334da2a-91b0-42c5-6156-76a5eba87430/page-query")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"prompt\": \"What is the main idea of this page?\"\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.airtop.ai/api/v1/sessions/6aac6f73-bd89-4a76-ab32-5a6c422e8b0b/windows/0334da2a-91b0-42c5-6156-76a5eba87430/page-query")
  .header("Authorization", "Bearer <apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"prompt\": \"What is the main idea of this page?\"\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.airtop.ai/api/v1/sessions/6aac6f73-bd89-4a76-ab32-5a6c422e8b0b/windows/0334da2a-91b0-42c5-6156-76a5eba87430/page-query', [
  'body' => '{
  "prompt": "What is the main idea of this page?"
}',
  'headers' => [
    'Authorization' => 'Bearer <apiKey>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.airtop.ai/api/v1/sessions/6aac6f73-bd89-4a76-ab32-5a6c422e8b0b/windows/0334da2a-91b0-42c5-6156-76a5eba87430/page-query");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"prompt\": \"What is the main idea of this page?\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <apiKey>",
  "Content-Type": "application/json"
]
let parameters = ["prompt": "What is the main idea of this page?"] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.airtop.ai/api/v1/sessions/6aac6f73-bd89-4a76-ab32-5a6c422e8b0b/windows/0334da2a-91b0-42c5-6156-76a5eba87430/page-query")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```