Sample - GitHub REST API
PUT/repos/{owner}/{repo}/pages

Update a GitHub Pages site

Replaces configuration information for a repository's GitHub Pages site. Provide at least one of build_type, source, or cname, and include https_enforced when you want to change HTTPS enforcement. The authenticated user must be a repository administrator, maintainer, or have the manage GitHub Pages settings permission.

  • RetriesRetries up to 2×, 500ms backoff, 30s timeout.

2 parameters · 4 body fields
ownerstringrequired
The account owner of the repository; the name is not case sensitive.
repostringrequired
The repository name without the `.git` extension; the name is not case sensitive.

GitHub Pages configuration fields; provide at least one of build_type, source, or cname.

cnamestringoptional
Specify a custom domain for the repository. Sending a `null` value will remove the custom domain. For more about custom domains, see "[Using a custom domain with GitHub Pages](https://docs.github.com/pages/configuring-a-custom-domain-for-your-github-pages-site)."
https_enforcedbooleanoptional
Specify whether HTTPS should be enforced for the repository.
build_typestringrequired
The process by which the GitHub Pages site will be built. `workflow` means that the site is built by a custom GitHub Actions workflow. `legacy` means that the site is built by GitHub when changes are pushed to a specific branch.
Allowed:legacyworkflow
sourcestringoptional
The repository source for the Pages site: gh-pages, master, or master /docs, or an object containing both a branch and path.
Allowed:gh-pagesmastermaster /docs

4 status codes
204Indicates that the GitHub Pages site information was updated successfully.
400Returned when the request is malformed or cannot be parsed.
messagestringoptional
documentation_urlstringoptional
urlstringoptional
statusstringoptional
409Returned when the requested Pages configuration conflicts with the current repository or site state.
messagestringoptional
documentation_urlstringoptional
urlstringoptional
statusstringoptional
422Returned when validation fails or the endpoint has been spammed.
messagestringrequired
documentation_urlstringrequired
errorsarray<object>optional

Error handling

A 400 is returned when the request is malformed, a 409 when the Pages site configuration conflicts with the repository state, and a 422 when validation fails or the endpoint has been spammed. Provide at least one of build_type, source, or cname; build_type must be legacy or workflow, and a structured source must include both branch and path.