> For the complete documentation index, see [llms.txt](https://docs.stackai.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.stackai.com/integrations/catalog/cloudflare.md).

# Cloudflare

Deploy Cloudflare Workers and Pages, manage R2 objects and DNS records, purge cache, and start workflows from account audit changes.

### Connectors

Choose the connector that matches your authentication method. The options below use the names shown in StackAI.

| Connector  | Authentication |
| ---------- | -------------- |
| Cloudflare | API Token      |

#### Cloudflare

Connect to Cloudflare with a scoped user or account-owned API token to deploy Workers and Pages, manage R2 objects and DNS records, purge cache, and poll audit changes.

**Set up in Cloudflare**

1. Prepare the Cloudflare account or service that the workflow will access. Grant access to the required resources and operations.
2. **API Token:** A Cloudflare user or account-owned API token with only the permissions your workflows need. The scoped actions use Workers R2 Storage Write, Pages Write, Workers Scripts Write, DNS Write, Cache Purge, Zone Read, and Account Settings Read. R2 REST uploads require an account-wide R2 Admin token, not a bucket-scoped R2 Object token.

**Set up in StackAI**

1. Open **Settings → Connections**, add a connection, and select **Cloudflare**.
2. Enter the credentials and connection details in the fields below.
3. Save the connection and check its connection status. Select this saved connection when configuring an action or feature that uses it.

**Connection fields**

| StackAI field                      | Required                 | What to enter                                                                                                                                                                                                                                                                                                                                                                                                        |
| ---------------------------------- | ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| API Token                          | Yes                      | A Cloudflare user or account-owned API token with only the permissions your workflows need. The scoped actions use Workers R2 Storage Write, Pages Write, Workers Scripts Write, DNS Write, Cache Purge, Zone Read, and Account Settings Read. R2 REST uploads require an account-wide R2 Admin token, not a bucket-scoped R2 Object token. [Provider instructions](https://dash.cloudflare.com/profile/api-tokens). |
| Account ID for account-owned token | Optional / as applicable | Enter the owning Cloudflare account ID only for an account-owned API token. Leave this blank when using a user API token. [Provider instructions](https://developers.cloudflare.com/fundamentals/api/get-started/account-owned-tokens/).                                                                                                                                                                             |

#### Verify the connection

Check that the connection is healthy. Then run a read operation against a resource the connected account can access. A successful connection check confirms authentication; it does not guarantee permission for every action.

If access is denied, check the credential or OAuth permissions, the selected account or environment, and access to the specific resource. Update expired credentials or reconnect after permissions change.

### Use an action

1. Add the required **Cloudflare** action to the workflow.
2. Select a connection when the action requests one.
3. Complete the required fields. Use the reference picker when a value comes from another workflow step.
4. Run the workflow and inspect the action’s output. Check the result before using it in a later step.

### Actions

#### Put R2 object

Upload a file from a URL to an existing Cloudflare R2 bucket.

**Required permissions:** `Workers R2 Storage Write`.

**Inputs**

| Field           | Type            | Required | Description                                                                                                                                             |
| --------------- | --------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Account         | select (string) | Yes      | Cloudflare account that owns the R2 bucket. Options load from the selected connection.                                                                  |
| Jurisdiction    | select (string) | No       | R2 data jurisdiction for the target bucket. Available values: Default, European Union, United States, FedRAMP Moderate, FedRAMP High. Default: default. |
| R2 bucket       | select (string) | Yes      | Existing R2 bucket that will receive the object. Options load from the selected connection.                                                             |
| Object key      | string          | Yes      | Path and filename to use inside the bucket.                                                                                                             |
| Source file URL | string          | Yes      | HTTPS URL of the file to upload, up to 300 MB.                                                                                                          |
| Content type    | string          | No       | MIME type stored with the object. Leave empty to store application/octet-stream.                                                                        |
| Storage class   | select (string) | No       | Storage class to assign to the uploaded object. Available values: Standard, Infrequent Access. Default: Standard.                                       |

**Outputs**

| Field         | Type     | Description                                    |
| ------------- | -------- | ---------------------------------------------- |
| Object key    | string   | Path and filename of the uploaded object.      |
| ETag          | string   | Entity tag for the uploaded object.            |
| Size in bytes | string   | Uploaded object size in bytes.                 |
| Storage class | string   | Storage class assigned to the uploaded object. |
| Uploaded at   | datetime | When Cloudflare stored the object.             |
| Version       | string   | Version identifier for the uploaded object.    |

#### Create Pages Deployment

Start a Git-backed deployment for an existing Cloudflare Pages project.

**Required permissions:** `Pages Write`.

**Inputs**

| Field             | Type            | Required | Description                                                                                |
| ----------------- | --------------- | -------- | ------------------------------------------------------------------------------------------ |
| Account           | select (string) | Yes      | Cloudflare account that owns the Pages project. Options load from the selected connection. |
| Pages project     | select (string) | Yes      | Existing Pages project to deploy. Options load from the selected connection.               |
| Git branch        | string          | No       | Branch whose current HEAD should be deployed; leave empty for the production branch.       |
| Commit message    | string          | No       | Optional message shown with the deployment.                                                |
| Mark commit dirty | boolean         | No       | Mark the deployment metadata as containing uncommitted changes. Default: false.            |

**Outputs**

| Field          | Type     | Description                                            |
| -------------- | -------- | ------------------------------------------------------ |
| Deployment ID  | string   | Identifier of the new Pages deployment.                |
| Environment    | string   | Environment targeted by the deployment.                |
| Deployment URL | string   | URL of the deployed Pages site.                        |
| Stage          | string   | Latest deployment stage, when available.               |
| Stage status   | string   | Status of the latest deployment stage, when available. |
| Created at     | datetime | When Cloudflare created the deployment.                |

#### Deploy Worker

Deploy a modern JavaScript module Worker from a source file URL.

**Required permissions:** `Workers Scripts Write`.

**Inputs**

| Field                 | Type            | Required | Description                                                                                      |
| --------------------- | --------------- | -------- | ------------------------------------------------------------------------------------------------ |
| Account               | select (string) | Yes      | Cloudflare account where the Worker will be deployed. Options load from the selected connection. |
| Worker name           | string          | Yes      | Name of the Worker script to create or replace.                                                  |
| JavaScript source URL | string          | Yes      | HTTPS URL of the ES module Worker source file.                                                   |
| Entry filename        | string          | No       | Filename used for the module entry part in the Worker upload. Default: index.js.                 |
| Compatibility date    | date            | Yes      | Cloudflare Workers runtime behavior date for this deployment.                                    |
| Compatibility flags   | string          | No       | Comma-separated Workers compatibility flags to enable.                                           |

**Outputs**

| Field        | Type     | Description                                         |
| ------------ | -------- | --------------------------------------------------- |
| Script ID    | string   | Identifier of the deployed Worker script.           |
| ETag         | string   | Current version tag for the deployed Worker.        |
| Created at   | datetime | When the Worker script was created.                 |
| Modified at  | datetime | When the Worker script was last modified.           |
| Startup time | number   | Worker startup time in milliseconds, when reported. |

#### Create DNS record

Create a common content-based DNS record in a Cloudflare zone.

**Required permissions:** `DNS Write`, `Zone Read`.

**Inputs**

| Field                    | Type            | Required | Description                                                                                      |
| ------------------------ | --------------- | -------- | ------------------------------------------------------------------------------------------------ |
| Zone                     | select (string) | Yes      | Cloudflare zone where the DNS record will be created. Options load from the selected connection. |
| Record type              | select (string) | Yes      | DNS record type to create. Available values: A, AAAA, CNAME, MX, NS, PTR, TXT.                   |
| Record name              | string          | Yes      | Fully qualified hostname for the DNS record.                                                     |
| Record value             | textarea        | Yes      | Address, target hostname, or text value stored in the record.                                    |
| MX priority              | integer         | No       | Mail server priority, required only for MX records.                                              |
| TTL                      | integer         | No       | Time to live in seconds; 1 uses Cloudflare automatic TTL. Default: 1.                            |
| Proxy through Cloudflare | boolean         | No       | Route supported A, AAAA, or CNAME traffic through Cloudflare. Default: false.                    |
| Comment                  | string          | No       | Optional note stored with the DNS record.                                                        |
| Tags                     | string          | No       | Comma-separated Cloudflare DNS record tags.                                                      |

**Outputs**

| Field        | Type     | Description                                      |
| ------------ | -------- | ------------------------------------------------ |
| Record ID    | string   | Identifier of the created DNS record.            |
| Record type  | string   | Type of the created DNS record.                  |
| Record name  | string   | Hostname stored on the created record.           |
| Record value | string   | Address, hostname, or text stored on the record. |
| TTL          | integer  | Time to live assigned to the record.             |
| Proxied      | boolean  | Whether Cloudflare proxying is enabled.          |
| Created at   | datetime | When Cloudflare created the DNS record.          |

#### Purge cache

Purge selected URLs, tags, hostnames, prefixes, or an entire Cloudflare zone cache.

**Required permissions:** `Cache Purge`, `Zone Read`.

**Inputs**

| Field                      | Type            | Required | Description                                                                                                                                             |
| -------------------------- | --------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Zone                       | select (string) | Yes      | Cloudflare zone whose cache should be purged. Options load from the selected connection.                                                                |
| Purge mode                 | select (string) | Yes      | Type of cached content to invalidate. Available values: URLs (recommended), Cache tags, Hostnames, URL prefixes, Everything in the zone. Default: urls. |
| Purge targets              | textarea        | No       | Comma-separated URLs, tags, hostnames, or prefixes to purge.                                                                                            |
| Confirm entire cache purge | boolean         | No       | Confirm that every cached asset in the selected zone should be invalidated. Default: false.                                                             |

**Outputs**

| Field    | Type   | Description                                      |
| -------- | ------ | ------------------------------------------------ |
| Purge ID | string | Identifier of the completed cache purge request. |

### Triggers

A trigger starts a workflow when its configured event occurs. Configure the event and filters before enabling the trigger.

#### Cloudflare resource changed

Poll Cloudflare Audit Logs v2 every five minutes for created, updated, or deleted account and zone resources.

Enter the exact Cloudflare account ID and optionally narrow the change types or resource type. The API token needs Account Settings Read.

**Required permissions:** `Account Settings Read`.

**Configuration**

| Field                | Type                      | Required | Description                                                                                                                     |
| -------------------- | ------------------------- | -------- | ------------------------------------------------------------------------------------------------------------------------------- |
| Account              | select (string)           | Yes      | Cloudflare account whose audit changes should start the workflow. Options load from the selected connection.                    |
| Change types         | multiple\_select (string) | No       | Audit change types that start the workflow. Available values: Create, Update, Delete. Default: \["create", "update", "delete"]. |
| Resource type filter | string                    | No       | Optional Cloudflare audit resource type to match.                                                                               |

**Event inputs**

| Field          | Type     | Required | Description                                             |
| -------------- | -------- | -------- | ------------------------------------------------------- |
| Audit event ID | string   | Yes      | Unique identifier of the Cloudflare audit event.        |
| Change type    | string   | Yes      | Whether the resource was created, updated, or deleted.  |
| Occurred at    | datetime | Yes      | Time Cloudflare recorded the change.                    |
| Resource ID    | string   | No       | Identifier of the Cloudflare resource that changed.     |
| Resource type  | string   | No       | Type of Cloudflare resource that changed.               |
| Resource name  | string   | No       | Human-readable name of the changed resource.            |
| Actor email    | string   | No       | Email of the user that made the change, when available. |
| Zone ID        | string   | No       | Zone associated with the change, when available.        |
| HTTP method    | string   | No       | API method that caused the audited change.              |
| Status code    | integer  | No       | HTTP status Cloudflare recorded for the change.         |

**Outputs**

| Field          | Type     | Description                                             |
| -------------- | -------- | ------------------------------------------------------- |
| Audit event ID | string   | Unique identifier of the Cloudflare audit event.        |
| Change type    | string   | Whether the resource was created, updated, or deleted.  |
| Occurred at    | datetime | Time Cloudflare recorded the change.                    |
| Resource ID    | string   | Identifier of the Cloudflare resource that changed.     |
| Resource type  | string   | Type of Cloudflare resource that changed.               |
| Resource name  | string   | Human-readable name of the changed resource.            |
| Actor email    | string   | Email of the user that made the change, when available. |
| Zone ID        | string   | Zone associated with the change, when available.        |
| HTTP method    | string   | API method that caused the audited change.              |
| Status code    | integer  | HTTP status Cloudflare recorded for the change.         |

### Important behavior

Actions that create, update, send, or delete data can change the connected service. Review their inputs before running them. A retry can repeat an operation; consider this when configuring retries for actions that change data.

The catalog lists the fields and capabilities available in the supplied provider definition. Availability can also depend on your deployment and organization’s Feature Access settings.


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.stackai.com/integrations/catalog/cloudflare.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
