Skip to main content

projects

Creates, updates, deletes, gets or lists a projects resource.

Overview

Nameprojects
TypeResource
Idcloudflare.pages.projects

Fields

The following fields are returned by SELECT queries:

Get project response.

NameDatatypeDescription
idstringID of the project. (example: 7b162ea7-7367-4d67-bcde-1160995d5)
namestringName of the project. (example: this-is-my-project-01)
preview_script_namestringName of the preview script. (example: pages-worker--1234567-preview)
production_script_namestringName of the production script. (example: pages-worker--1234567-production)
build_configobjectConfigs for the project build process.
canonical_deploymentobjectMost recent production deployment of the project.
created_onstring (date-time)When the project was created. (example: 2017-01-01T00:00:00Z)
deployment_configsobjectConfigs for deployments in a project.
domainsarrayA list of associated custom domains for the project.
frameworkstringFramework the project is using.
framework_versionstringVersion of the framework the project is using.
latest_deploymentobjectMost recent deployment of the project.
production_branchstringProduction branch of the project. Used to identify production deployments. (example: main)
sourceobjectConfigs for the project source control.
subdomainstringThe Cloudflare subdomain associated with the project. (example: helloworld.pages.dev)
uses_functionsbooleanWhether the project uses functions.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectproject_name, account_idFetch a project by name.
listselectaccount_idpage, per_pageFetch a list of all user projects.
createinsertaccount_id, name, production_branchCreate a new project.
editupdateproject_name, account_idSet new attributes for an existing project. Modify environment variables. To delete an environment variable, set the key to null.
deletedeleteproject_name, account_idDelete a project by name.
purge_build_cacheexecproject_name, account_idPurge all cached build artifacts for a Pages project

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
account_idstringThe Cloudflare account ID.
project_namestringThe Pages project name.
pageinteger
per_pageinteger

SELECT examples

Fetch a project by name.

SELECT
id,
name,
preview_script_name,
production_script_name,
build_config,
canonical_deployment,
created_on,
deployment_configs,
domains,
framework,
framework_version,
latest_deployment,
production_branch,
source,
subdomain,
uses_functions
FROM cloudflare.pages.projects
WHERE project_name = '{{ project_name }}' -- required
AND account_id = '{{ account_id }}' -- required
;

INSERT examples

Create a new project.

INSERT INTO cloudflare.pages.projects (
build_config,
deployment_configs,
name,
production_branch,
source,
account_id
)
SELECT
'{{ build_config }}',
'{{ deployment_configs }}',
'{{ name }}' /* required */,
'{{ production_branch }}' /* required */,
'{{ source }}',
'{{ account_id }}'
RETURNING
errors,
messages,
result,
success
;

UPDATE examples

Set new attributes for an existing project. Modify environment variables. To delete an environment variable, set the key to null.

UPDATE cloudflare.pages.projects
SET
build_config = '{{ build_config }}',
deployment_configs = '{{ deployment_configs }}',
name = '{{ name }}',
production_branch = '{{ production_branch }}',
source = '{{ source }}'
WHERE
project_name = '{{ project_name }}' --required
AND account_id = '{{ account_id }}' --required
RETURNING
errors,
messages,
result,
success;

DELETE examples

Delete a project by name.

DELETE FROM cloudflare.pages.projects
WHERE project_name = '{{ project_name }}' --required
AND account_id = '{{ account_id }}' --required
;

Lifecycle Methods

Purge all cached build artifacts for a Pages project

EXEC cloudflare.pages.projects.purge_build_cache
@project_name='{{ project_name }}' --required,
@account_id='{{ account_id }}' --required
;