Create projects

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

POST /v1/cloudflare/pages/projects

Addresshttps://api.hanzo.ai/v1/cloudflare/pages/projects
MethodPOST
Operationpost_cloudflare_pages_projects
AuthAuthorization: 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).

FieldInTypeRequiredDescription
build_configbodycloudflare.PagesBuildConfig—
build_config.build_commandbodystring—BuildCommand is what Cloudflare runs to build the site ("npm run build").
build_config.destination_dirbodystring—DestinationDir is the directory the build leaves the site in ("dist"), relative to RootDir.
build_config.root_dirbodystring—RootDir is where in the repository the build runs, for a project that is not at the repository root.
deployment_configsbodycloudflare.PagesDeploymentConfigs—
deployment_configs.previewbodycloudflare.PagesDeploymentConfig—
deployment_configs.preview.compatibility_datebodystring—CompatibilityDate pins which Workers runtime behaviour the functions run under, as a date ("2024-01-01").
deployment_configs.preview.compatibility_flagsbodystring[]—CompatibilityFlags turn individual runtime behaviours on or off ahead of, or behind, the date above ("nodejs_compat").
deployment_configs.preview.d1_databasesbodyobject—D1Databases binds D1 databases in, keyed by binding name.
deployment_configs.preview.d1_databases.*bodycloudflare.PagesD1Binding—
deployment_configs.preview.d1_databases.*.idbodystring—ID is the D1 database this binding points at, by Cloudflare's uuid.
deployment_configs.preview.env_varsbodyobject—EnvVars are the environment variables the functions see, KEYED BY VARIABLE NAME.
deployment_configs.preview.env_vars.*bodycloudflare.PagesEnvVar—
deployment_configs.preview.env_vars.*.typebodystring—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.*.valuebodystring—Value is the variable's value.
deployment_configs.preview.kv_namespacesbodyobject—KVNamespaces binds KV namespaces into the functions, KEYED BY THE BINDING NAME the code reads (env.SESSIONS).
deployment_configs.preview.kv_namespaces.*bodycloudflare.PagesKVBinding—
deployment_configs.preview.kv_namespaces.*.namespace_idbodystring—NamespaceID is the KV namespace this binding points at, by Cloudflare's id rather than its title.
deployment_configs.preview.r2_bucketsbodyobject—R2Buckets binds R2 buckets in, keyed by binding name.
deployment_configs.preview.r2_buckets.*bodycloudflare.PagesR2Binding—
deployment_configs.preview.r2_buckets.*.namebodystring—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.productionbodycloudflare.PagesDeploymentConfig—
deployment_configs.production.compatibility_datebodystring—CompatibilityDate pins which Workers runtime behaviour the functions run under, as a date ("2024-01-01").
deployment_configs.production.compatibility_flagsbodystring[]—CompatibilityFlags turn individual runtime behaviours on or off ahead of, or behind, the date above ("nodejs_compat").
deployment_configs.production.d1_databasesbodyobject—D1Databases binds D1 databases in, keyed by binding name.
deployment_configs.production.d1_databases.*bodycloudflare.PagesD1Binding—
deployment_configs.production.d1_databases.*.idbodystring—ID is the D1 database this binding points at, by Cloudflare's uuid.
deployment_configs.production.env_varsbodyobject—EnvVars are the environment variables the functions see, KEYED BY VARIABLE NAME.
deployment_configs.production.env_vars.*bodycloudflare.PagesEnvVar—
deployment_configs.production.env_vars.*.typebodystring—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.*.valuebodystring—Value is the variable's value.
deployment_configs.production.kv_namespacesbodyobject—KVNamespaces binds KV namespaces into the functions, KEYED BY THE BINDING NAME the code reads (env.SESSIONS).
deployment_configs.production.kv_namespaces.*bodycloudflare.PagesKVBinding—
deployment_configs.production.kv_namespaces.*.namespace_idbodystring—NamespaceID is the KV namespace this binding points at, by Cloudflare's id rather than its title.
deployment_configs.production.r2_bucketsbodyobject—R2Buckets binds R2 buckets in, keyed by binding name.
deployment_configs.production.r2_buckets.*bodycloudflare.PagesR2Binding—
deployment_configs.production.r2_buckets.*.namebodystring—Name is the R2 bucket this binding points at, by bucket name — R2 addresses buckets by name where KV and D1 use ids.
namebodystring—Name is the project name, and it is also the address: the site answers at <name>.pages.dev.
production_branchbodystring—ProductionBranch is which git branch builds to production; every other branch builds a preview.

Response

StatusBodyMeaning
200ok
defaultproblem-detailsrefused

200 body — 1 field.

FieldInTypeAlwaysDescription
(body)bodyanyyes

Failure carries the platform error shape — see Errors.

Examples

hanzo cloudflare pages projects create
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":{}}} });
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 := 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
}
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?;
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();
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 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:

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 · All Hanzo APIs · Interactive reference

Was this page useful?