We've recently moved some of the REST API documentation. If you can't find what you're looking for, you might try the new Branches, Collaborators, Commits, Deploy Keys, Deployments, GitHub Pages, Releases, Metrics, Webhooks REST API pages.
Pages
The GitHub Pages API allows you to interact with GitHub Pages sites and build information.
Get a GitHub Pages site
get /repos/{owner}/{repo}/pagesParameters
| Name | Type | In | Description |
|---|---|---|---|
accept | string | header | Setting to |
owner | string | path | |
repo | string | path |
Code samples
Example
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/OWNER/REPO/pagesawait octokit.request('GET /repos/{owner}/{repo}/pages', {
owner: 'OWNER',
repo: 'REPO'
})gh api \
-H "Accept: application/vnd.github.v3+json" \
/repos/OWNER/REPO/pagesResponse
Status: 200{
"url": "https://api.github.com/repos/github/developer.github.com/pages",
"status": "built",
"cname": "developer.github.com",
"custom_404": false,
"html_url": "https://developer.github.com",
"source": {
"branch": "master",
"path": "/"
},
"public": true,
"https_certificate": {
"state": "approved",
"description": "Certificate is approved",
"domains": [
"developer.github.com"
],
"expires_at": "2021-05-22"
},
"https_enforced": true
}Status codes
| HTTP Status Code | Description |
|---|---|
200 | OK |
404 | Resource not found |
Notes
Create a GitHub Pages site
Configures a GitHub Pages site. For more information, see "About GitHub Pages."
post /repos/{owner}/{repo}/pagesParameters
| Name | Type | In | Description | ||||||
|---|---|---|---|---|---|---|---|---|---|
accept | string | header | Setting to | ||||||
owner | string | path | |||||||
repo | string | path | |||||||
source | object | body | Required. The source branch and directory used to publish your Pages site. | ||||||
Properties of the | |||||||||
| Name (Type) | Description |
|---|---|
branch (string) | Required. The repository branch used to publish your site's source files. |
path (string) | The repository directory that includes the source files for the Pages site. Allowed paths are |
Code samples
Example
curl \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/OWNER/REPO/pages \
-d '{"source":{"branch":"main","path":"/docs"}}'await octokit.request('POST /repos/{owner}/{repo}/pages', {
owner: 'OWNER',
repo: 'REPO',
source: {
branch: 'main',
path: '/docs'
}
})Response
Status: 201{
"url": "https://api.github.com/repos/github/developer.github.com/pages",
"status": "built",
"cname": "developer.github.com",
"custom_404": false,
"html_url": "https://developer.github.com",
"source": {
"branch": "master",
"path": "/"
},
"public": true,
"https_certificate": {
"state": "approved",
"description": "Certificate is approved",
"domains": [
"developer.github.com"
],
"expires_at": "2021-05-22"
},
"https_enforced": true
}Status codes
| HTTP Status Code | Description |
|---|---|
201 | Created |
409 | Conflict |
422 | Validation failed |
Notes
Update information about a GitHub Pages site
Updates information for a GitHub Pages site. For more information, see "About GitHub Pages.
put /repos/{owner}/{repo}/pagesParameters
| Name | Type | In | Description |
|---|---|---|---|
accept | string | header | Setting to |
owner | string | path | |
repo | string | path | |
cname | string or null | body | Specify a custom domain for the repository. Sending a |
https_enforced | boolean | body | Specify whether HTTPS should be enforced for the repository. |
public | boolean | body | Configures access controls for the GitHub Pages site. If public is set to |
source | body |
Code samples
Example
curl \
-X PUT \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/OWNER/REPO/pages \
-d '{"cname":"octocatblog.com","source":{"branch":"main","path":"/"}}'await octokit.request('PUT /repos/{owner}/{repo}/pages', {
owner: 'OWNER',
repo: 'REPO',
cname: 'octocatblog.com',
source: {
branch: 'main',
path: '/'
}
})Response
Status: 204Status codes
| HTTP Status Code | Description |
|---|---|
204 | No Content |
400 | Bad Request |
422 | Validation failed |
Notes
Delete a GitHub Pages site
delete /repos/{owner}/{repo}/pagesParameters
| Name | Type | In | Description |
|---|---|---|---|
accept | string | header | Setting to |
owner | string | path | |
repo | string | path |
Code samples
Example
curl \
-X DELETE \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/OWNER/REPO/pagesawait octokit.request('DELETE /repos/{owner}/{repo}/pages', {
owner: 'OWNER',
repo: 'REPO'
})gh api \
--method DELETE \
-H "Accept: application/vnd.github.v3+json" \
/repos/OWNER/REPO/pagesResponse
Status: 204Status codes
| HTTP Status Code | Description |
|---|---|
204 | No Content |
404 | Resource not found |
422 | Validation failed |
Notes
List GitHub Pages builds
get /repos/{owner}/{repo}/pages/buildsParameters
| Name | Type | In | Description |
|---|---|---|---|
accept | string | header | Setting to |
owner | string | path | |
repo | string | path | |
per_page | integer | query | Results per page (max 100) Default: |
page | integer | query | Page number of the results to fetch. Default: |
Code samples
Example
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/OWNER/REPO/pages/buildsawait octokit.request('GET /repos/{owner}/{repo}/pages/builds', {
owner: 'OWNER',
repo: 'REPO'
})gh api \
-H "Accept: application/vnd.github.v3+json" \
/repos/OWNER/REPO/pages/buildsResponse
Status: 200[
{
"url": "https://api.github.com/repos/github/developer.github.com/pages/builds/5472601",
"status": "built",
"error": {
"message": null
},
"pusher": {
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"commit": "351391cdcb88ffae71ec3028c91f375a8036a26b",
"duration": 2104,
"created_at": "2014-02-10T19:00:49Z",
"updated_at": "2014-02-10T19:00:51Z"
}
]Status codes
| HTTP Status Code | Description |
|---|---|
200 | OK |
Notes
Request a GitHub Pages build
You can request that your site be built from the latest revision on the default branch. This has the same effect as pushing a commit to your default branch, but does not require an additional commit. Manually triggering page builds can be helpful when diagnosing build warnings and failures.
Build requests are limited to one concurrent build per repository and one concurrent build per requester. If you request a build while another is still in progress, the second request will be queued until the first completes.
post /repos/{owner}/{repo}/pages/buildsParameters
| Name | Type | In | Description |
|---|---|---|---|
accept | string | header | Setting to |
owner | string | path | |
repo | string | path |
Code samples
Example
curl \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/OWNER/REPO/pages/buildsawait octokit.request('POST /repos/{owner}/{repo}/pages/builds', {
owner: 'OWNER',
repo: 'REPO'
})gh api \
--method POST \
-H "Accept: application/vnd.github.v3+json" \
/repos/OWNER/REPO/pages/buildsResponse
Status: 201{
"url": "https://api.github.com/repos/github/developer.github.com/pages/builds/latest",
"status": "queued"
}Status codes
| HTTP Status Code | Description |
|---|---|
201 | Created |
Notes
Get latest Pages build
get /repos/{owner}/{repo}/pages/builds/latestParameters
| Name | Type | In | Description |
|---|---|---|---|
accept | string | header | Setting to |
owner | string | path | |
repo | string | path |
Code samples
Example
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/OWNER/REPO/pages/builds/latestawait octokit.request('GET /repos/{owner}/{repo}/pages/builds/latest', {
owner: 'OWNER',
repo: 'REPO'
})gh api \
-H "Accept: application/vnd.github.v3+json" \
/repos/OWNER/REPO/pages/builds/latestResponse
Status: 200{
"url": "https://api.github.com/repos/github/developer.github.com/pages/builds/5472601",
"status": "built",
"error": {
"message": null
},
"pusher": {
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"commit": "351391cdcb88ffae71ec3028c91f375a8036a26b",
"duration": 2104,
"created_at": "2014-02-10T19:00:49Z",
"updated_at": "2014-02-10T19:00:51Z"
}Status codes
| HTTP Status Code | Description |
|---|---|
200 | OK |
Notes
Get GitHub Pages build
get /repos/{owner}/{repo}/pages/builds/{build_id}Parameters
| Name | Type | In | Description |
|---|---|---|---|
accept | string | header | Setting to |
owner | string | path | |
repo | string | path | |
build_id | integer | path |
Code samples
Example
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/OWNER/REPO/pages/builds/BUILD_IDawait octokit.request('GET /repos/{owner}/{repo}/pages/builds/{build_id}', {
owner: 'OWNER',
repo: 'REPO',
build_id: 'BUILD_ID'
})gh api \
-H "Accept: application/vnd.github.v3+json" \
/repos/OWNER/REPO/pages/builds/BUILD_IDResponse
Status: 200{
"url": "https://api.github.com/repos/github/developer.github.com/pages/builds/5472601",
"status": "built",
"error": {
"message": null
},
"pusher": {
"login": "octocat",
"id": 1,
"node_id": "MDQ6VXNlcjE=",
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"commit": "351391cdcb88ffae71ec3028c91f375a8036a26b",
"duration": 2104,
"created_at": "2014-02-10T19:00:49Z",
"updated_at": "2014-02-10T19:00:51Z"
}Status codes
| HTTP Status Code | Description |
|---|---|
200 | OK |
Notes
Get a DNS health check for GitHub Pages
Gets a health check of the DNS settings for the CNAME record configured for a repository's GitHub Pages.
The first request to this endpoint returns a 202 Accepted status and starts an asynchronous background task to get the results for the domain. After the background task completes, subsequent requests to this endpoint return a 200 OK status with the health check results in the response.
Users must have admin or owner permissions. GitHub Apps must have the pages:write and administration:write permission to use this endpoint.
get /repos/{owner}/{repo}/pages/healthParameters
| Name | Type | In | Description |
|---|---|---|---|
accept | string | header | Setting to |
owner | string | path | |
repo | string | path |
Code samples
Example
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/OWNER/REPO/pages/healthawait octokit.request('GET /repos/{owner}/{repo}/pages/health', {
owner: 'OWNER',
repo: 'REPO'
})gh api \
-H "Accept: application/vnd.github.v3+json" \
/repos/OWNER/REPO/pages/healthResponse
Status: 200{
"domain": {
"host": "example.com",
"uri": "http://example.com/",
"nameservers": "default",
"dns_resolves": true,
"is_proxied": false,
"is_cloudflare_ip": false,
"is_fastly_ip": false,
"is_old_ip_address": false,
"is_a_record": true,
"has_cname_record": false,
"has_mx_records_present": false,
"is_valid_domain": true,
"is_apex_domain": true,
"should_be_a_record": true,
"is_cname_to_github_user_domain": false,
"is_cname_to_pages_dot_github_dot_com": false,
"is_cname_to_fastly": false,
"is_pointed_to_github_pages_ip": true,
"is_non_github_pages_ip_present": false,
"is_pages_domain": false,
"is_served_by_pages": true,
"is_valid": true,
"reason": null,
"responds_to_https": true,
"enforces_https": true,
"https_error": null,
"is_https_eligible": true,
"caa_error": null
},
"alt_domain": {
"host": "www.example.com",
"uri": "http://www.example.com/",
"nameservers": "default",
"dns_resolves": true,
"is_proxied": false,
"is_cloudflare_ip": false,
"is_fastly_ip": false,
"is_old_ip_address": false,
"is_a_record": true,
"has_cname_record": false,
"has_mx_records_present": false,
"is_valid_domain": true,
"is_apex_domain": true,
"should_be_a_record": true,
"is_cname_to_github_user_domain": false,
"is_cname_to_pages_dot_github_dot_com": false,
"is_cname_to_fastly": false,
"is_pointed_to_github_pages_ip": true,
"is_non_github_pages_ip_present": false,
"is_pages_domain": false,
"is_served_by_pages": true,
"is_valid": true,
"reason": null,
"responds_to_https": true,
"enforces_https": true,
"https_error": null,
"is_https_eligible": true,
"caa_error": null
}
}Status codes
| HTTP Status Code | Description |
|---|---|
200 | OK |
202 | Empty response |
400 | Custom domains are not available for GitHub Pages |
404 | Resource not found |
422 | There isn't a CNAME for this page |