OpenapiCloudflare
Creates a Cloudflare Pages project on the org's account.
Creates a Cloudflare Pages project on the org's account. Requires org admin.
| 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 | 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 | PagesDeploymentConfigs | — | |
deployment_configs.preview | body | 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 | 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 | 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. Under type "secret_text" Cloudflare encrypts it on arrival and never reads it back, so a later read of the project shows the… |
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 | 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 | 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 | 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 | 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 | 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. Under type "secret_text" Cloudflare encrypts it on arrival and never reads it back, so a later read of the project shows the… |
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 | 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 | 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 |
200 body — 1 field.
| Field | In | Type | Always | Description |
|---|---|---|---|---|
(body) | body | any | yes |
Failure carries the platform error shape — see Errors.
Examples
hanzo cloudflare pages projects createimport { 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":{}}} });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":{}}})cfg := cloud.NewConfiguration()
cfg.AddDefaultHeader("Authorization", "Bearer "+os.Getenv("HANZO_API_KEY"))
client := cloud.NewAPIClient(cfg)
resp, _, err := client.CloudflareAPI.PostCloudflarePagesProjects(context.Background()).Execute()
if err != nil {
return err
}use hanzo_cloud::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?;import ai.hanzo.cloud.ApiClient;
import ai.hanzo.cloud.api.CloudflareApi;
ApiClient client = new ApiClient();
client.setRequestInterceptor(b -> b.header("Authorization", "Bearer " + System.getenv("HANZO_API_KEY")));
var result = new CloudflareApi(client).postCloudflarePagesProjects();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": {}
}
}
}'The door reaches cloudflare through the cloudflare tool, which names its 33 operations with its own verbs — this one among them, under a name only the door declares. describe explains any of them:
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"
}
}
}'How is this guide?