How to link GitHub Repo Using Cloudflare Pages API Create Project E

Regarding Cloudflare Pages API - Create Project
https://developers.cloudflare.com/api/operations/pages-project-create-project

I see the above API has a reference to the “branch” of what seems to be a repository.

Is this the GitHub repository?

I have the cloudflare pages GitHub App enabled for all repositories in my org.

When I create a new Repo, how can that new repo be linked to the cloudflare pages project using the API?

I am fully automating pages project creation and deployment and don’t want to have to go to the Cloudflare Pages dashboard just to link the GitHub repo during the process.
I was expecting a post parameter that somehow links the GitHub Repo to the Cloudflare Project when calling Create.

There’s a source field in which you put an object with type (github/gitlab). Then config object with owner and repo_name

Example curl:

curl -X POST 'https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/pages/projects' \
  -H 'Authorization: $API_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "pages-project",
    "production_branch": "main",
    "source": {
        "type": "github",
        "config": {
            "owner": "GitHubUser",
            "repo_name": "RepoName"
        }
    }
}'

Worked great.
Thanks.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.