> ## Documentation Index
> Fetch the complete documentation index at: https://docs.devtune.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Connect GitBook

> Measure AI crawls, answer fetches and 404 page views on GitBook-hosted docs with a GitBook API token. No code changes.

DevTune pulls hourly AI bot counts for a published GitBook site from GitBook's site insights. Use it for docs hosted on GitBook, where you can't put Cloudflare in front of the domain or run edge middleware.

GitBook doesn't share visitors' IP addresses or response status codes, so every GitBook count is **unverified**: DevTune can't [confirm a bot is who it claims to be](https://docs.devtune.ai/ai-traffic/advanced-setup.md#crawler-identity-checks). GitBook reports a 404 only for page views on the site itself, so 404 Demand gets GitBook's 404 page views, never its server-side or Markdown fetches.

## Before you start

* A paid plan that includes AI Traffic, and the project Admin role. See [Set up AI Traffic](https://docs.devtune.ai/ai-traffic/setup.md#before-you-start).
* A **published** GitBook site. DevTune records counts under the site's published URL.
* A GitBook API token that can read the site. Create one in GitBook under **Settings › Developer settings**. DevTune uses it only to read the site's analytics.

Each project connects one GitBook site.

## Connect the site

1. Open the site's dashboard in GitBook and copy the two IDs from its URL: `app.gitbook.com/o/<organization ID>/sites/<site ID>`. The site ID starts with `site_`.
2. In DevTune, open **Settings › Integrations** and select **Set up** on **GitBook** under **Crawler sensors**.
3. Enter the **Organization ID**, the **Site ID** and the **GitBook API token**.
4. Select **Connect GitBook**.

DevTune reads the site from GitBook to check the token and find its published URL, then stores the token encrypted. It never shows the token again.

If Cloudflare or edge middleware already counts the site's hostname, the GitBook row says so, and GitBook's counts for that hostname are not added. Keep [one crawler sensor per hostname](https://docs.devtune.ai/ai-traffic/choosing-sensors.md#keep-each-site-on-one-crawler-sensor).

## What happens next

The pull runs hourly. The first sync reads the last 30 days, so a site AI crawlers already visit arrives with last month's crawls and answer fetches in it. Later syncs read the hours since the last one.

GitBook counts appear in **Insights › AI Traffic** as crawls and answer fetches on the site's hostname, and its 404 page views appear in **404 Demand**. When a window includes GitBook counts, AI Traffic and 404 Demand say so and name the hostnames. Over the [API](https://docs.devtune.ai/api-reference/overview.md), `GET /projects/{projectId}/traffic/summary` labels them the same way in its `gitbook` field, as does the [MCP server](https://docs.devtune.ai/api-reference/mcp-server.md)'s `devtune_get_traffic_summary` tool.

## Check GitBook is working

1. Until the first sync runs, the **GitBook** row reads **Waiting for first sync**.
2. After the next hourly sync, reload **Settings › Integrations**. The row reads **Active**, with **Last synced** and the time of the sync.
3. Open **Insights › AI Traffic** and select **Crawls & fetches**. The first sync's 30 days appear here.

## Fix a connection error

| Message | What to do |
| - | - |
| **Check the organization ID, site ID and token: IDs are letters, numbers, hyphens and underscores from the site's dashboard URL, and the token can't be empty.** | Copy both IDs again from the site's dashboard URL, and paste the token. |
| **GitBook rejected the token. Check it can read this site, or create a new one.** | Create a token whose account can read the site, and connect again. |
| **GitBook found no site with that organization and site ID. Copy both from the site's dashboard URL.** | Copy the IDs from the site's own dashboard, not another site's. |
| **Publish the site in GitBook first: DevTune records counts under its published URL.** | Publish the site in GitBook, then connect again. |
| **This project already has a GitBook site connected. Disconnect it first.** | Disconnect the current site to connect a different one. |
| **GitBook could not be reached. Try again.** | Try again in a few minutes. |

## If GitBook stops syncing

When GitBook rejects the token, for example after it was revoked, the row reads **Reconnect needed** and syncing pauses. DevTune tells the account owners in the app and by email. Select **Manage**, then **Reconnect with a new token**, and paste a new token. Syncing resumes on the next hourly run.

## Disconnect GitBook

Select **Manage** on the **GitBook** row, then **Disconnect GitBook**, and confirm. DevTune deletes the API token and stops reading the site. Counts already recorded stay, still labelled as unverified GitBook counts. Revoke the token in GitBook to remove its access there.

You can disconnect GitBook without AI Traffic in your plan, so a connection is never stuck after a downgrade. Connecting or reconnecting needs AI Traffic again.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.