# Create projects

URL: https://docs.hanzo.ai/docs/openapi/cloudflare/post-cloudflare-pages-projects

> Creates a Cloudflare Pages project on the org's account.

`POST /v1/cloudflare/pages/projects`

> [Cloudflare →](https://docs.hanzo.ai/docs/openapi/cloudflare) · [All API references →](https://docs.hanzo.ai/docs/openapi) · [Get started →](https://docs.hanzo.ai/docs/guides)

|               |                                                     |
| ------------- | --------------------------------------------------- |
| **Address**   | `https://api.hanzo.ai/v1/cloudflare/pages/projects` |
| **Method**    | `POST`                                              |
| **Operation** | `post_cloudflare_pages_projects`                    |
| **Auth**      | `Authorization: Bearer $HANZO_API_KEY`              |

Creates a Cloudflare Pages project on the org's account. Requires
org admin. Only the modeled fields reach Cloudflare, so an unmodeled key in the
request is dropped rather than forwarded.

## Request

39 fields, body `application/json` (required).

| Field                                                        | In   | Type                              | Required | Description                                                                                                             |
| ------------------------------------------------------------ | ---- | --------------------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------- |
| `build_config`                                               | body | cloudflare.PagesBuildConfig       | —        |                                                                                                                         |
| `build_config.build_command`                                 | body | string                            | —        | BuildCommand is what Cloudflare runs to build the site ("npm run build").                                               |
| `build_config.destination_dir`                               | body | string                            | —        | DestinationDir is the directory the build leaves the site in ("dist"), relative to RootDir.                             |
| `build_config.root_dir`                                      | body | string                            | —        | RootDir is where in the repository the build runs, for a project that is not at the repository root.                    |
| `deployment_configs`                                         | body | cloudflare.PagesDeploymentConfigs | —        |                                                                                                                         |
| `deployment_configs.preview`                                 | body | cloudflare.PagesDeploymentConfig  | —        |                                                                                                                         |
| `deployment_configs.preview.compatibility_date`              | body | string                            | —        | CompatibilityDate pins which Workers runtime behaviour the functions run under, as a date ("2024-01-01").               |
| `deployment_configs.preview.compatibility_flags`             | body | string\[]                         | —        | CompatibilityFlags turn individual runtime behaviours on or off ahead of, or behind, the date above ("nodejs\_compat"). |
| `deployment_configs.preview.d1_databases`                    | body | object                            | —        | D1Databases binds D1 databases in, keyed by binding name.                                                               |
| `deployment_configs.preview.d1_databases.*`                  | body | cloudflare.PagesD1Binding         | —        |                                                                                                                         |
| `deployment_configs.preview.d1_databases.*.id`               | body | string                            | —        | ID is the D1 database this binding points at, by Cloudflare's uuid.                                                     |
| `deployment_configs.preview.env_vars`                        | body | object                            | —        | EnvVars are the environment variables the functions see, KEYED BY VARIABLE NAME.                                        |
| `deployment_configs.preview.env_vars.*`                      | body | cloudflare.PagesEnvVar            | —        |                                                                                                                         |
| `deployment_configs.preview.env_vars.*.type`                 | body | string                            | —        | Type is "plain\_text" or "secret\_text" and decides that: plain text is readable afterwards, secret text is write-only. |
| `deployment_configs.preview.env_vars.*.value`                | body | string                            | —        | Value is the variable's value.                                                                                          |
| `deployment_configs.preview.kv_namespaces`                   | body | object                            | —        | KVNamespaces binds KV namespaces into the functions, KEYED BY THE BINDING NAME the code reads (`env.SESSIONS`).         |
| `deployment_configs.preview.kv_namespaces.*`                 | body | cloudflare.PagesKVBinding         | —        |                                                                                                                         |
| `deployment_configs.preview.kv_namespaces.*.namespace_id`    | body | string                            | —        | NamespaceID is the KV namespace this binding points at, by Cloudflare's id rather than its title.                       |
| `deployment_configs.preview.r2_buckets`                      | body | object                            | —        | R2Buckets binds R2 buckets in, keyed by binding name.                                                                   |
| `deployment_configs.preview.r2_buckets.*`                    | body | cloudflare.PagesR2Binding         | —        |                                                                                                                         |
| `deployment_configs.preview.r2_buckets.*.name`               | body | string                            | —        | Name is the R2 bucket this binding points at, by bucket name — R2 addresses buckets by name where KV and D1 use ids.    |
| `deployment_configs.production`                              | body | cloudflare.PagesDeploymentConfig  | —        |                                                                                                                         |
| `deployment_configs.production.compatibility_date`           | body | string                            | —        | CompatibilityDate pins which Workers runtime behaviour the functions run under, as a date ("2024-01-01").               |
| `deployment_configs.production.compatibility_flags`          | body | string\[]                         | —        | CompatibilityFlags turn individual runtime behaviours on or off ahead of, or behind, the date above ("nodejs\_compat"). |
| `deployment_configs.production.d1_databases`                 | body | object                            | —        | D1Databases binds D1 databases in, keyed by binding name.                                                               |
| `deployment_configs.production.d1_databases.*`               | body | cloudflare.PagesD1Binding         | —        |                                                                                                                         |
| `deployment_configs.production.d1_databases.*.id`            | body | string                            | —        | ID is the D1 database this binding points at, by Cloudflare's uuid.                                                     |
| `deployment_configs.production.env_vars`                     | body | object                            | —        | EnvVars are the environment variables the functions see, KEYED BY VARIABLE NAME.                                        |
| `deployment_configs.production.env_vars.*`                   | body | cloudflare.PagesEnvVar            | —        |                                                                                                                         |
| `deployment_configs.production.env_vars.*.type`              | body | string                            | —        | Type is "plain\_text" or "secret\_text" and decides that: plain text is readable afterwards, secret text is write-only. |
| `deployment_configs.production.env_vars.*.value`             | body | string                            | —        | Value is the variable's value.                                                                                          |
| `deployment_configs.production.kv_namespaces`                | body | object                            | —        | KVNamespaces binds KV namespaces into the functions, KEYED BY THE BINDING NAME the code reads (`env.SESSIONS`).         |
| `deployment_configs.production.kv_namespaces.*`              | body | cloudflare.PagesKVBinding         | —        |                                                                                                                         |
| `deployment_configs.production.kv_namespaces.*.namespace_id` | body | string                            | —        | NamespaceID is the KV namespace this binding points at, by Cloudflare's id rather than its title.                       |
| `deployment_configs.production.r2_buckets`                   | body | object                            | —        | R2Buckets binds R2 buckets in, keyed by binding name.                                                                   |
| `deployment_configs.production.r2_buckets.*`                 | body | cloudflare.PagesR2Binding         | —        |                                                                                                                         |
| `deployment_configs.production.r2_buckets.*.name`            | body | string                            | —        | Name is the R2 bucket this binding points at, by bucket name — R2 addresses buckets by name where KV and D1 use ids.    |
| `name`                                                       | body | string                            | —        | Name is the project name, and it is also the address: the site answers at \<name>.pages.dev.                            |
| `production_branch`                                          | body | string                            | —        | ProductionBranch is which git branch builds to production; every other branch builds a preview.                         |

## Response

| Status    | Body            | Meaning |
| --------- | --------------- | ------- |
| `200`     |                 | ok      |
| `default` | problem-details | refused |

`200` body — 1 field.

| Field    | In   | Type | Always | Description |
| -------- | ---- | ---- | ------ | ----------- |
| `(body)` | body | any  | yes    |             |

Failure carries the platform error shape — see [Errors](https://docs.hanzo.ai/docs/errors).

## Examples

**CLI**

```bash
hanzo cloudflare pages projects create
```

**SDK**

**.ts**

```ts
import { Configuration, CloudflareApi } from 'hanzoai';

const api = new CloudflareApi(new Configuration({ accessToken: process.env.HANZO_API_KEY }));
const { data } = await api.postCloudflarePagesProjects({ build_config: {"build_command":"<build_command>","destination_dir":"<destination_dir>","root_dir":"<root_dir>"}, deployment_configs: {"preview":{"compatibility_date":"<compatibility_date>","compatibility_flags":["<compatibility_flags>"],"d1_databases":{},"env_vars":{}},"production":{"compatibility_date":"<compatibility_date>","compatibility_flags":["<compatibility_flags>"],"d1_databases":{},"env_vars":{}}} });
```

**.py**

```python
from hanzoai.cloud import ApiClient, Configuration
from hanzoai.cloud.api import CloudflareApi

client = ApiClient(Configuration(access_token=os.environ["HANZO_API_KEY"]))
result = CloudflareApi(client).post_cloudflare_pages_projects(build_config={"build_command":"<build_command>","destination_dir":"<destination_dir>","root_dir":"<root_dir>"}, deployment_configs={"preview":{"compatibility_date":"<compatibility_date>","compatibility_flags":["<compatibility_flags>"],"d1_databases":{},"env_vars":{}},"production":{"compatibility_date":"<compatibility_date>","compatibility_flags":["<compatibility_flags>"],"d1_databases":{},"env_vars":{}}})
```

**.go**

```go
cfg := hanzoai.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := hanzoai.NewAPIClient(cfg)

resp, _, err := client.CloudflareAPI.PostCloudflarePagesProjects(context.Background()).Execute()
if err != nil {
	return err
}
```

**.rs**

```rust
use hanzo_client::apis::{configuration::Configuration, cloudflare_api};

let mut cfg = Configuration::new();
cfg.bearer_access_token = std::env::var("HANZO_API_KEY").ok();

let result = cloudflare_api::post_cloudflare_pages_projects(&cfg, Default::default()).await?;
```

**.java**

```java
import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.CloudflareApi;

ApiClient client = new ApiClient();
client.setBearerToken(System.getenv("HANZO_API_KEY"));

var result = new CloudflareApi(client).postCloudflarePagesProjects();
```

**HTTP**

```bash
curl -X POST https://api.hanzo.ai/v1/cloudflare/pages/projects \
  -H "Authorization: Bearer $HANZO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
       "build_config": {
         "build_command": "<build_command>",
         "destination_dir": "<destination_dir>",
         "root_dir": "<root_dir>"
       },
       "deployment_configs": {
         "preview": {
           "compatibility_date": "<compatibility_date>",
           "compatibility_flags": [
             "<compatibility_flags>"
           ],
           "d1_databases": {},
           "env_vars": {}
         },
         "production": {
           "compatibility_date": "<compatibility_date>",
           "compatibility_flags": [
             "<compatibility_flags>"
           ],
           "d1_databases": {},
           "env_vars": {}
         }
       }
     }'
```

**MCP**

MCP reaches **cloudflare** through the `cloudflare` tool, which names its 29 operations with its own verbs — this one among them, under a name only MCP declares. `describe` explains any of them:

```bash
curl -X POST https://api.hanzo.ai/v1/mcp \
  -H "Content-Type: application/json" \
  -d '{
       "jsonrpc": "2.0",
       "id": 1,
       "method": "tools/call",
       "params": {
         "name": "describe",
         "arguments": {
           "op": "list_cloudflare_d1_databases"
         }
       }
     }'
```

---

[Cloudflare API](https://docs.hanzo.ai/docs/openapi/cloudflare) · [All Hanzo APIs](https://docs.hanzo.ai/docs/openapi) · [Interactive reference](https://docs.hanzo.ai/docs/openapi/reference)
