# Cloudflare

URL: https://docs.hanzo.ai/docs/cli/cloudflare

> The `hanzo cloudflare` commands.

Also for this capability: [API](https://docs.hanzo.ai/docs/openapi/cloudflare) · **CLI** · [SDKs](https://docs.hanzo.ai/docs/sdks)

Your Cloudflare account, managed from Hanzo: zones, Pages, Workers, Workers AI, R2, KV and D1.

[API reference →](https://docs.hanzo.ai/docs/openapi/cloudflare)

```bash
hanzo cloudflare zones list
```

Every command takes `--json` for the raw response and `--help` for its own flags. Sign in once with `hanzo auth login`; the commands below use that session, and the org they act in is the one it carries.

### D1

| Command                                          | What it does                                            |
| ------------------------------------------------ | ------------------------------------------------------- |
| `hanzo cloudflare d1 databases create`           | Creates a D1 database on the org's Cloudflare account.  |
| `hanzo cloudflare d1 databases list`             | Lists the D1 databases on the org's Cloudflare account. |
| `hanzo cloudflare d1 databases query <database>` | Runs one SQL statement against a D1 database.           |
| `hanzo cloudflare d1 databases rm <database>`    | Deletes a D1 database and everything stored in it.      |

### KV

| Command                                                       | What it does                                                     |
| ------------------------------------------------------------- | ---------------------------------------------------------------- |
| `hanzo cloudflare kv namespaces create`                       | Creates a Workers KV namespace on the org's Cloudflare account.  |
| `hanzo cloudflare kv namespaces list`                         | Lists the Workers KV namespaces on the org's Cloudflare account. |
| `hanzo cloudflare kv namespaces rm <namespace>`               | Deletes a Workers KV namespace and every key in it.              |
| `hanzo cloudflare kv namespaces values get <namespace> <key>` | Read a Workers KV value as its stored bytes                      |
| `hanzo cloudflare kv namespaces values rm <namespace> <key>`  | Removes one key from a Workers KV namespace.                     |
| `hanzo cloudflare kv namespaces values set <namespace> <key>` | Write a Workers KV value from the request body                   |

### Pages

| Command                                                         | What it does                                                                                     |
| --------------------------------------------------------------- | ------------------------------------------------------------------------------------------------ |
| `hanzo cloudflare pages projects create`                        | Creates a Cloudflare Pages project on the org's account.                                         |
| `hanzo cloudflare pages projects deployments <project>`         | Trigger a new Pages deployment for a project                                                     |
| `hanzo cloudflare pages projects domains create <project>`      | Attaches a custom domain to a Cloudflare Pages project.                                          |
| `hanzo cloudflare pages projects domains rm <project> <domain>` | Detaches a custom domain from a Cloudflare Pages project.                                        |
| `hanzo cloudflare pages projects get <project>`                 | Reads one Cloudflare Pages project — its build config, deployment configs and latest deployment. |
| `hanzo cloudflare pages projects list`                          | Lists the org's Cloudflare Pages projects.                                                       |
| `hanzo cloudflare pages projects rm <project>`                  | Deletes a Cloudflare Pages project, and with it every deployment it has ever made.               |

### R2

| Command                                   | What it does                                          |
| ----------------------------------------- | ----------------------------------------------------- |
| `hanzo cloudflare r2 buckets create`      | Creates an R2 bucket on the org's Cloudflare account. |
| `hanzo cloudflare r2 buckets list`        | Lists the R2 buckets on the org's Cloudflare account. |
| `hanzo cloudflare r2 buckets rm <bucket>` | Deletes an R2 bucket.                                 |

### Workers

| Command                                                   | What it does                                                                                                   |
| --------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
| `hanzo cloudflare workers scripts list`                   | Lists the Worker scripts on the org's Cloudflare account.                                                      |
| `hanzo cloudflare workers scripts rm <script>`            | Removes a Worker script from the org's Cloudflare account.                                                     |
| `hanzo cloudflare workers scripts set <script>`           | Uploads or replaces a module Worker script.                                                                    |
| `hanzo cloudflare workers scripts subdomain <script>`     | Publishes or withdraws one Worker script on the account's workers.dev subdomain.                               |
| `hanzo cloudflare workers subdomain`                      | Reads the org account's workers.dev subdomain — the name under which every subdomain-enabled script is served. |
| `hanzo cloudflare workers zones routes create <zone>`     | Binds a URL pattern in a zone to a Worker script.                                                              |
| `hanzo cloudflare workers zones routes list <zone>`       | Lists the Worker routes bound within one zone — the URL patterns that dispatch to a script.                    |
| `hanzo cloudflare workers zones routes rm <zone> <route>` | Unbinds a Worker route, so its pattern stops dispatching to a script.                                          |

### Zones

| Command                                   | What it does                                                                                                                            |
| ----------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
| `hanzo cloudflare zones analytics <zone>` | Reads a zone's Cloudflare traffic dashboard — requests, bandwidth, threats and pageviews over the since/until window.                   |
| `hanzo cloudflare zones get <zone>`       | Reads one Cloudflare zone the org's token can see.                                                                                      |
| `hanzo cloudflare zones list`             | Lists the Cloudflare zones the org's connected API token can see, paged and filtered by the query parameters Cloudflare itself accepts. |
| `hanzo cloudflare zones purge <zone>`     | Drops a zone's Cloudflare edge cache — either the whole zone (purge\_everything) or exactly the listed file URLs.                       |
