> For the complete documentation index, see [llms.txt](https://docs.octoxlabs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.octoxlabs.com/adapters/c/cloudflare-zero-trust-network-access.md).

# Cloudflare Zero Trust Network Access

Cloudflare Zero Trust provides secure access to applications. OctoXLabs uses it to add enrolled physical devices and Access users, and optionally their sessions and failed logins, to the inventory.

## Use cases

* List devices enrolled in Cloudflare Zero Trust.

```
Adapters = cloudflare-ztna
```

* Find enrolled devices not seen in the last 30 days.

```
Adapters = cloudflare-ztna AND NOT LastSeen last now-30d/d
```

## Before you begin

### Network

| Source              | Destination        | Port | Protocol |
| ------------------- | ------------------ | ---- | -------- |
| OctoXLabs connector | api.cloudflare.com | 443  | HTTPS    |

### Required permissions

| Scope or role                                                                                     | Permission | Needed for                                        |
| ------------------------------------------------------------------------------------------------- | ---------- | ------------------------------------------------- |
| Audit Logs: Read                                                                                  | Read       | Users and the enrichment data (required for both) |
| Zero Trust, Access: Apps and Policies, Access: Device Posture, Access: Audit Logs (Account scope) | Read       | Account tokens                                    |

## Create credentials in Cloudflare Zero Trust Network Access

{% stepper %}
{% step %}

### Find the Account ID

Go to **Cloudflare Dashboard > Account Home** (top left). The Account ID is under your account name.
{% endstep %}

{% step %}

### Open API tokens (user token)

Open **Cloudflare Dashboard > My Profile > API Tokens** and click **Create Token**.
{% endstep %}

{% step %}

### Open API tokens (account token)

Open the API Tokens page at `https://dash.cloudflare.com/profile/api-tokens` and click **Create Token**.
{% endstep %}

{% step %}

### Set permissions

Grant **Audit Logs Read**. For an account token also grant **Zero Trust**, **Access: Apps and Policies**, **Access: Device Posture** and **Access: Audit Logs** with Account scopes.
{% endstep %}
{% endstepper %}

## Connection parameters

| Parameter         | Required | Type     | Default | Description                                                                                                            |
| ----------------- | -------- | -------- | ------- | ---------------------------------------------------------------------------------------------------------------------- |
| Account ID        | Yes      | Text     |         | Cloudflare Account ID.                                                                                                 |
| API Token         | Yes      | Password |         | Cloudflare API token.                                                                                                  |
| Is Account Token? | No       | Boolean  | False   | Turn on when you use an account token. The token verification URL differs.                                             |
| HTTPS Proxy       | No       | Text     |         | Proxy URL.                                                                                                             |
| Users Enrichment  | No       | Boolean  | False   | Fetch active sessions, failed login attempts and last seen identity of each user. Sends three extra requests per user. |
| Timeout           | No       | Number   | 30      | Seconds to wait for API responses.                                                                                     |

## Troubleshooting

No adapter-specific error messages are documented for this adapter.

## Change history

{% hint style="info" %}
Available starting from version 5.6.1.
{% endhint %}
