> For the complete documentation index, see [llms.txt](https://docs.expel.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.expel.io/connect-your-technology/a-c-integrations/cloudflare/cloudflare-waf-setup-for-workbench.md).

# Cloudflare WAF Setup for Workbench

## Prerequisites <a href="#h_01jec6jwm33prf8djzargavdgr" id="h_01jec6jwm33prf8djzargavdgr"></a>

1. You must be a Cloudflare Enterprise customer to use this integration.
2. You must be using Cloudflare Web Application Firewall (WAF). This integration supports ONLY Cloudflare WAF events.
3. In your organization's system, create an email address to receive notifications from Cloudflare. You need this address for actions like managing your access and resetting your password.
4. You must be logged in as a Super Administrator in Cloudflare and have a verified email address.

## Step 1: Obtain Zone ID Value <a href="#h_01hye6egqwsn113hw0h4p469yf" id="h_01hye6egqwsn113hw0h4p469yf"></a>

1. [Log in to the Cloudflare dashboard](https://dash.cloudflare.com/) and select your account and domain.
2. On the **Overview** page, find the **API** section.
3. Copy these values for later. Click Click to copy. Save them in a secure place (not plaintext where others can access it).
4. Click the **Get your API token link**. Copy the token and save it, too. The X-Auth-Key is the Cloudflare API token.

## Step 2: Enable Log Retention <a href="#h_01hye6egqwznz4wd726azm5349" id="h_01hye6egqwznz4wd726azm5349"></a>

By default, HTTP request log retention isn't enabled. Enabling log retention is a requirement to support this integration. Run the following command to determine if your log retention is enabled or disabled:

```
curl -s -H "X-Auth-Email: <EMAIL>" -H "X-Auth-Key: <API_KEY>" GET "https://api.cloudflare.com/client/v4/zones/<ZONE_ID>/logs/control/retention/flag" | jq .
```

**Response**

<pre><code>{
  "errors": [],
  "messages": [],
  "result": {
<strong>    "flag": false
</strong>  },
  "success": true
}
</code></pre>

**Results**

* True = Log Retention is Enabled.
* False = Log Retention is Disabled. If Log Retention is disabled, run the command below to enable it.

**To enable log retention:**

```
curl -s -H "X-Auth-Email: <EMAIL>" -H "X-Auth-Key: <API_KEY>" POST "https://api.cloudflare.com/client/v4/zones/<ZONE_ID>/logs/control/retention/flag" -d'{"flag":true}' | jq .
```

**Response**

<pre><code>{
  "errors": [],
  "messages": [],
  "result": {
<strong>    "flag": true
</strong>  },
  "success": true
}
</code></pre>

## Step 3: Add Expel to Cloudflare <a href="#h_01hye6egqwvpye3ztctacdxysy" id="h_01hye6egqwvpye3ztctacdxysy"></a>

These steps explain how to:

* Provision an Expel account and add it to your Cloudflare account
* Grant relevant permissions to the Expel account

### Provision the Expel SOC account to Cloudflare <a href="#h_01hye6egqwsz2dwe9g3fmabck8" id="h_01hye6egqwsz2dwe9g3fmabck8"></a>

{% hint style="info" %}
You must be logged in as a Super Administrator and have a verified email address.
{% endhint %}

1. [Log in to the Cloudflare dashboard](https://dash.cloudflare.com/).
2. In the left navigation, select **Manage Account > Members**.
3. Select **Invite**.
4. Complete the following information:
   * **Invite members** - enter the email address you created for notification purposes (see [Prerequisites](https://support.expel.io/hc/en-us/articles/19320202141971-Cloudflare-WAF-Setup-for-Workbench#h_01JEC6JWM33PRF8DJZARGAVDGR) if you have not done this yet).
   * **Scope** - select the appropriate scope for your permissions.
   * **Roles** - choose **Analytics** and **Log Share Reader**.
5. Select **Continue to summary**.
6. Select **Invite**.

### Create API token for Expel SOC account <a href="#h_01hye6egqwf852anqn9geyjm9h" id="h_01hye6egqwf852anqn9geyjm9h"></a>

1. From the Cloudflare dashboard, go to **Profile > API Tokens**.
2. Select **Create Token**.
3. Scroll down to the **Custom token** section and select **Get started** to create a custom token.
4. For **Token name**, enter "Expel API Token".
5. For **Permissions**, apply the following permissions:
   * Select **Account > Account Analytics > Read**.
   * Select **Account > Logs > Read**.
   * Select **Zone > Analytics > Read**.
   * Select **Zone > Logs > Read**.<br>

     <div align="left"><figure><img src="/files/YB6c9MFKuiIDPP6wKKrM" alt="Cloudflare WAF permissions are set to the specified config above." width="563"><figcaption></figcaption></figure></div>
6. In the next sections, select the account or zone resources the token is authorized to access. These are the resources you want Expel to monitor.
7. Select **Continue to summary**.
8. Review the token summary. If you need to make adjustments, select **Edit token**. You can also edit the token later, if needed.
9. Select **Create Token** to generate the token's secret. **Copy and save the secret** to a safe place for use in a later step. *For security, the token secret is **only shown once** and will not be available again.*

## Step 4: Add Cloudflare as a Security Device in Workbench <a href="#h_01hye6egqwj5cav4kvpwkvnz2s" id="h_01hye6egqwj5cav4kvpwkvnz2s"></a>

Now that you have the correct access configured and noted the credentials, you can integrate your tech with Workbench.

1. [Log in to Workbench.](https://workbench.expel.io/auth/login?orig=%2F)
2. In the side menu, navigate to **Organization Settings > Security Devices**.
3. Select **Add Security Device**.
4. In the search field, type "Cloudflare", and select the Cloudflare integration.
5. Complete the fields as follows:
   * **Name** - enter a name that might help you more easily identify this integration, such as “CompanyName \<technology>”; this name will display in Workbench under the Name column, and is a text string that you can filter on.
   * **Location** - enter the location of your integration, for example “cloud;” this is also a text string that you can filter on, so we recommend being consistent with location naming across your Expel integrations.
   * **Expel Cloudflare email** - enter the email address you used in [Step 3](#h_01hye6egqwvpye3ztctacdxysy).
   * **API key for Expel Cloudflare email** - enter the API token you created in [Step 3](#h_01hye6egqwvpye3ztctacdxysy).<br>

     <div align="left"><figure><img src="/files/bAXNJxMjm3xafcon3jDH" alt="Cloudflare Add a Security Device page in Workbench." width="563"><figcaption></figcaption></figure></div>
6. Select **Save**.

Your device should be created successfully within a few seconds. A few reminders:

* After your connection is healthy, it will take some time for your device to begin polling.
* To check on the status, select the downward arrow for your device in the first column and choose **View details**.
* If your device does not begin polling within 15 minutes, [contact our support team](/support/how-to-reach-us.md) for help. You must refresh the page to see updates.

## Step 5: Edit the Device to Add Console Access <a href="#h_01jecbhdaen1589bnmb2n8hxmh" id="h_01jecbhdaen1589bnmb2n8hxmh"></a>

Expel requires console access to allow analysts to perform investigation and triage. Without this additional level of information, details cannot be verified by our analysts and an investigation cannot be initiated. For more information, see [Why Expel Asks for Console Access](/connect-your-technology/about-integrations/why-expel-asks-for-console-access.md).

1. In Workbench, go to **Organization Settings > Security Devices**. Next to the Cloudflare device you just connected, click the **down arrow** and click **Edit**.
2. In the Console Login section, complete the fields as follows:
   * **Console URL** - enter "<https://dash.cloudflare.com/>".
   * **Username** - type the user name you created above.
   * **Password** - type the password you created above.
   * **Two-factor secret key (32-character code)** - depending on how your organization enforces log-ins, this field may not apply to you. In these cases, you can leave it blank. This field is optional and if you have questions or concerns, [contact support](/support/how-to-reach-us.md).
3. Click **Save**.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.expel.io/connect-your-technology/a-c-integrations/cloudflare/cloudflare-waf-setup-for-workbench.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
