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

# Cloudflare

> Connect Cloudflare to CloudThinker for DNS management, CDN optimization, and security configuration

Connect your Cloudflare account to enable CloudThinker agents to access documentation, analyze DNS traffic, and query analytics data.

***

## Prerequisites

* Cloudflare account with API access
* Account ID (found in Cloudflare dashboard)
* API Token with appropriate permissions for your selected services

***

## Setup

<Steps>
  <Step title="Get Your Account ID">
    Log in to [Cloudflare Dashboard](https://dash.cloudflare.com/) → select any domain → copy your **Account ID** from the right sidebar under API section.
  </Step>

  <Step title="Create API Token">
    Go to **My Profile → API Tokens → Create Token**.

    Select permissions based on the services you want to enable (see [Required Permissions](#required-permissions) below).
  </Step>

  <Step title="Connect in CloudThinker">
    Navigate to **Connections → Cloudflare** and enter:

    * **API Token**: The token you created
    * **Account ID**: Your Cloudflare account ID
    * **Enabled Services**: Select the services you want to use
  </Step>
</Steps>

<Frame>
  <img src="https://mintcdn.com/cloudthinker/f645vAiA_merh7DD/images/cloudflare/01-connection-dialog.png?fit=max&auto=format&n=f645vAiA_merh7DD&q=85&s=1b39199c51c0187bb31b519f623ce333" alt="Cloudflare connection dialog showing API token, Account ID, and service selection fields" width="1610" height="1018" data-path="images/cloudflare/01-connection-dialog.png" />
</Frame>

<p style={{textAlign: 'center', fontSize: '0.9em', color: '#666', marginTop: '8px'}}>Cloudflare connection dialog with API token, Account ID, and service selection</p>

***

## Connection Details

| Field                       | Description                | Required |
| --------------------------- | -------------------------- | -------- |
| **CLOUDFLARE\_API\_TOKEN**  | Your Cloudflare API token  | Yes      |
| **CLOUDFLARE\_ACCOUNT\_ID** | Your Cloudflare account ID | Yes      |
| **ENABLED\_SERVICES**       | Services to enable         | Yes      |

***

## Supported Services

| Service               | Description                          | Use Case                                   |
| --------------------- | ------------------------------------ | ------------------------------------------ |
| **Documentation**     | Access Cloudflare documentation      | Reference docs during troubleshooting      |
| **DNS Analytics**     | DNS query analytics and traffic data | Analyze DNS patterns, identify issues      |
| **GraphQL Analytics** | Advanced analytics via GraphQL API   | Custom analytics queries, detailed reports |

***

## Required Permissions

### Documentation

No special permissions required. This service provides access to Cloudflare's public documentation.

### DNS Analytics

Create a custom token with these permissions:

| Permission       | Access Level |
| ---------------- | ------------ |
| Zone             | Read         |
| Analytics        | Read         |
| DNS              | Read         |
| Account Settings | Read         |

### GraphQL Analytics

Create a custom token with these permissions:

| Permission        | Access Level |
| ----------------- | ------------ |
| Account Analytics | Read         |
| Zone Analytics    | Read         |

<Tip>
  When creating your API token, you can combine permissions for multiple services into a single token.
</Tip>

***

## Creating an API Token

<Steps>
  <Step title="Navigate to API Tokens">
    Go to [Cloudflare Dashboard](https://dash.cloudflare.com/) → **My Profile** (top right) → **API Tokens**
  </Step>

  <Step title="Create Custom Token">
    Click **Create Token** → **Create Custom Token** (at bottom)
  </Step>

  <Step title="Configure Permissions">
    Add the permissions needed for your selected services:

    **For DNS Analytics:**

    * Account → Account Settings → Read
    * Zone → Zone → Read
    * Zone → Analytics → Read
    * Zone → DNS → Read

    **For GraphQL Analytics:**

    * Account → Account Analytics → Read
    * Zone → Zone Analytics → Read
  </Step>

  <Step title="Set Zone Resources">
    Under **Zone Resources**, select:

    * **Include** → **All zones** (or specific zones)
  </Step>

  <Step title="Create and Copy">
    Click **Continue to summary** → **Create Token**

    **Copy the token immediately** — it won't be shown again.
  </Step>
</Steps>

<Warning>
  Copy your API token immediately after creation. Cloudflare will not display it again, and you'll need to create a new token if lost.
</Warning>

***

## Troubleshooting

<Accordion title="Authentication failed">
  * Verify your API token is correct and hasn't been revoked
  * Check that the token has the required permissions for your selected services
  * Ensure the Account ID matches the account the token was created for
</Accordion>

<Accordion title="Missing analytics data">
  * Verify the token has Analytics read permissions
  * Check that the zones have traffic generating data
  * Analytics data may take up to 24 hours to appear for new zones
</Accordion>

<Accordion title="DNS Analytics not working">
  * Ensure all four permissions are granted: Zone, Analytics, DNS, Account Settings
  * Verify the token has access to the specific zones you're querying
  * Check that DNS is proxied through Cloudflare (orange cloud enabled)
</Accordion>

<Accordion title="GraphQL queries failing">
  * Verify Account Analytics and Zone Analytics permissions
  * Check the query syntax against Cloudflare's GraphQL schema
  * Ensure you're querying within the allowed time range
</Accordion>

***

## Security Best Practices

* **Minimal permissions** — Only enable permissions for services you need
* **Token rotation** — Rotate API tokens every 90 days
* **Zone restrictions** — Limit token access to specific zones when possible
* **IP restrictions** — Consider adding IP restrictions to your token
* **Audit regularly** — Review active tokens in Cloudflare dashboard

***

## Related

<CardGroup cols={2}>
  <Card title="MCP Connections" icon="https://mintcdn.com/cloudthinker/aLd-ttc-SCW-aFky/images/icons/mcp.svg?fit=max&auto=format&n=aLd-ttc-SCW-aFky&q=85&s=c89b6087a9d233901dea5e354452eff6" href="/guide/connections/mcp" width="24" height="24" data-path="images/icons/mcp.svg">
    Learn about MCP-based integrations
  </Card>

  <Card title="AWS Connection" icon="https://mintcdn.com/cloudthinker/aLd-ttc-SCW-aFky/images/icons/aws.svg?fit=max&auto=format&n=aLd-ttc-SCW-aFky&q=85&s=45d526a3e9345214c0345f277da2e829" href="/guide/connections/aws" width="24" height="24" data-path="images/icons/aws.svg">
    Connect your AWS infrastructure
  </Card>
</CardGroup>
