Deployment failed via API

I did try to deploy:
const accountId = process.env.CLOUDFLARE_ACCOUNT_ID;
const apiToken = process.env.CLOUDFLARE_API_TOKEN;

const endpoint = `https://api.cloudflare.com/client/v4/accounts/${accountId}/pages/projects/${projectName}/deployments`;

try {
const response = await fetch(endpoint, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${apiToken}`,
},
});
const accountId = process.env.CLOUDFLARE_ACCOUNT_ID;
const apiToken = process.env.CLOUDFLARE_API_TOKEN;

const endpoint = `https://api.cloudflare.com/client/v4/accounts/${accountId}/pages/projects/${projectName}/deployments`;

try {
const response = await fetch(endpoint, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${apiToken}`,
},
});
` Got this error:
Deployment failed: {
result: null,
success: false,
errors: [
{
code: 8000096,
message: 'A "manifest" field was expected in the request body but was not provided.'
}
],
messages: []
}
Deployment failed: {
result: null,
success: false,
errors: [
{
code: 8000096,
message: 'A "manifest" field was expected in the request body but was not provided.'
}
],
messages: []
}
24 Replies
Walshy
Walshy2mo ago
As the error states, you'd need a manifest We don't really recommend manual deployments, the deploy process isn't simple or documented. How come you aren't doing wrangler pages deploy?
NoOperation
NoOperationOP2mo ago
I need to create the pages connected to git via remote (API) The pages project is already created earlier and I need to trigger a deployment when I create it, not after I deploy to my github but only by creating it. I need to auto deploy it on creation. Is this possible, because as of now I do first create it and then try to deploy it (like the code above).
Walshy
Walshy2mo ago
I see, that error is for non-Git connected projects For Git connected, that endpoint should indeed just trigger a new deploy Are you making these as Git projects?
NoOperation
NoOperationOP2mo ago
Would you need two different API calls in order to trigger a deploy or can I do it with some parameter on init? Yes, these are all git repos
Walshy
Walshy2mo ago
2 API calls yeah, make project -> trigger deploy
NoOperation
NoOperationOP2mo ago
Got you
Walshy
Walshy2mo ago
what's your API call to make the project
NoOperation
NoOperationOP2mo ago
const body = {
name: gitRepoId,
production_branch: "master",
source: {
type: "github",
config: {
owner: "xxx-labs-projects",
repo_name: getGitRepoNameByGitRepoId(gitRepoId),
},
},
build_config: {
build_caching: true,
build_command: "npm run build",
dev_command: "npm run dev",
destination_dir: "dist",
root_dir: "",
web_analytics_token: "",
wait_for_ci: false
},
deployment_configs: {
production: {
env: {},
compatibility_date: "2025-01-01",
usage_model: "bundled"
},
preview: {
env: {},
compatibility_date: "2025-01-01",
usage_model: "bundled"
}
}
};

const gitRepoName = await getGitRepoNameByGitRepoId(gitRepoId);
const cloudflareProjectName = `${gitRepoId.toString()}-${gitRepoName}`;

const response: Cloudflare.Pages.Projects.Project = await cloudflare.pages.projects.create({
account_id: process.env.CLOUDFLARE_ACCOUNT_ID || '',
name: cloudflareProjectName,
production_branch: "master",
build_config: body.build_config,
deployment_configs: body.deployment_configs,
});
const body = {
name: gitRepoId,
production_branch: "master",
source: {
type: "github",
config: {
owner: "xxx-labs-projects",
repo_name: getGitRepoNameByGitRepoId(gitRepoId),
},
},
build_config: {
build_caching: true,
build_command: "npm run build",
dev_command: "npm run dev",
destination_dir: "dist",
root_dir: "",
web_analytics_token: "",
wait_for_ci: false
},
deployment_configs: {
production: {
env: {},
compatibility_date: "2025-01-01",
usage_model: "bundled"
},
preview: {
env: {},
compatibility_date: "2025-01-01",
usage_model: "bundled"
}
}
};

const gitRepoName = await getGitRepoNameByGitRepoId(gitRepoId);
const cloudflareProjectName = `${gitRepoId.toString()}-${gitRepoName}`;

const response: Cloudflare.Pages.Projects.Project = await cloudflare.pages.projects.create({
account_id: process.env.CLOUDFLARE_ACCOUNT_ID || '',
name: cloudflareProjectName,
production_branch: "master",
build_config: body.build_config,
deployment_configs: body.deployment_configs,
});
It is a Vite project with React.
Walshy
Walshy2mo ago
huh weird, that is a git project
NoOperation
NoOperationOP2mo ago
No description
NoOperation
NoOperationOP2mo ago
This is what I see after the creation process
Walshy
Walshy2mo ago
And that shows as direct upload Interesting.. Oh You aren't passing source into projects.create()
NoOperation
NoOperationOP2mo ago
oh really, let me check
NoOperation
NoOperationOP2mo ago
?
No description
NoOperation
NoOperationOP2mo ago
Do you mean like this? It does not like source in there.
Walshy
Walshy2mo ago
bleh, the sdk may be incorrectly rejecting source..
NoOperation
NoOperationOP2mo ago
Error: 400 {"result":null,"success":false,"errors":[{"code":8000006,"message":"Request body is incorrect. The request body may have an invalid JSON type or missing required keys. Refer to https://developers.cloudflare.com/api."}],"messages":[]}
Walshy
Walshy2mo ago
NoOperation
NoOperationOP2mo ago
No description
NoOperation
NoOperationOP2mo ago
Where is source?
Walshy
Walshy2mo ago
i linked to
NoOperation
NoOperationOP2mo ago
No description
NoOperation
NoOperationOP2mo ago
There yep Any idea?
Walshy
Walshy2mo ago
for the error, best i can suggest is to use a manual fetch for now and avoid the sdk I'm not sure why the sdk is wrong, the schema looks fine

Did you find this page helpful?