Skip to main content
We publish frequent updates to our documentation, and translation of this page may still be in progress. For the most current information, please visit the English documentation.

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.

Páginas

Use a API REST para interagir com os sites e compilações do GitHub Pages.

Get a GitHub Enterprise Server Pages site

Works with GitHub Apps

Parameters

Headers
Nome, Type, Descrição
acceptstring

Setting to application/vnd.github+json is recommended.

Path parameters
Nome, Type, Descrição
ownerstringRequired

The account owner of the repository. The name is not case sensitive.

repostringRequired

The name of the repository. The name is not case sensitive.

HTTP response status codes

Status codeDescrição
200

OK

404

Resource not found

Code samples

get/repos/{owner}/{repo}/pages
curl \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/pages

Response

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 }

Create a GitHub Enterprise Server Pages site

Works with GitHub Apps

Configures a GitHub Enterprise Server Pages site. For more information, see "About GitHub Pages."

To use this endpoint, you must be a repository administrator, maintainer, or have the 'manage GitHub Pages settings' permission. A token with the repo scope or Pages write permission is required. GitHub Apps must have the administration:write and pages:write permissions.

Parameters

Headers
Nome, Type, Descrição
acceptstring

Setting to application/vnd.github+json is recommended.

Path parameters
Nome, Type, Descrição
ownerstringRequired

The account owner of the repository. The name is not case sensitive.

repostringRequired

The name of the repository. The name is not case sensitive.

Body parameters
Nome, Type, Descrição
build_typestring

The process in which the Page will be built. Possible values are "legacy" and "workflow".

Can be one of: legacy, workflow

sourceobject

The source branch and directory used to publish your Pages site.

Nome, Type, Descrição
branchstringRequired

The repository branch used to publish your site's source files.

pathstring

The repository directory that includes the source files for the Pages site. Allowed paths are / or /docs. Default: /

Default: /

Can be one of: /, /docs

HTTP response status codes

Status codeDescrição
201

Created

409

Conflict

422

Validation failed, or the endpoint has been spammed.

Code samples

post/repos/{owner}/{repo}/pages
curl \ -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/pages \ -d '{"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 }

Update information about a GitHub Enterprise Server Pages site

Works with GitHub Apps

Updates information for a GitHub Enterprise Server Pages site. For more information, see "About GitHub Pages.

To use this endpoint, you must be a repository administrator, maintainer, or have the 'manage GitHub Pages settings' permission. A token with the repo scope or Pages write permission is required. GitHub Apps must have the administration:write and pages:write permissions.

Parameters

Headers
Nome, Type, Descrição
acceptstring

Setting to application/vnd.github+json is recommended.

Path parameters
Nome, Type, Descrição
ownerstringRequired

The account owner of the repository. The name is not case sensitive.

repostringRequired

The name of the repository. The name is not case sensitive.

Body parameters
Nome, Type, Descrição
cnamestring or null

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_enforcedboolean

Specify whether HTTPS should be enforced for the repository.

build_typestring

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.

Can be one of: legacy, workflow

sourceobject

Update the source for the repository. Must include the branch name and path.

Nome, Type, Descrição
branchstringRequired

The repository branch used to publish your site's source files.

pathstringRequired

The repository directory that includes the source files for the Pages site. Allowed paths are / or /docs.

Can be one of: /, /docs

HTTP response status codes

Status codeDescrição
204

No Content

400

Bad Request

409

Conflict

422

Validation failed, or the endpoint has been spammed.

Code samples

put/repos/{owner}/{repo}/pages
curl \ -X PUT \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/pages \ -d '{"cname":"octocatblog.com","source":{"branch":"main","path":"/"}}'

Response

Status: 204

Delete a GitHub Enterprise Server Pages site

Works with GitHub Apps

Deletes a GitHub Enterprise Server Pages site. For more information, see "About GitHub Pages.

To use this endpoint, you must be a repository administrator, maintainer, or have the 'manage GitHub Pages settings' permission. A token with the repo scope or Pages write permission is required. GitHub Apps must have the administration:write and pages:write permissions.

Parameters

Headers
Nome, Type, Descrição
acceptstring

Setting to application/vnd.github+json is recommended.

Path parameters
Nome, Type, Descrição
ownerstringRequired

The account owner of the repository. The name is not case sensitive.

repostringRequired

The name of the repository. The name is not case sensitive.

HTTP response status codes

Status codeDescrição
204

No Content

404

Resource not found

409

Conflict

422

Validation failed, or the endpoint has been spammed.

Code samples

delete/repos/{owner}/{repo}/pages
curl \ -X DELETE \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/pages

Response

Status: 204

List GitHub Enterprise Server Pages builds

Works with GitHub Apps

Parameters

Headers
Nome, Type, Descrição
acceptstring

Setting to application/vnd.github+json is recommended.

Path parameters
Nome, Type, Descrição
ownerstringRequired

The account owner of the repository. The name is not case sensitive.

repostringRequired

The name of the repository. The name is not case sensitive.

Query parameters
Nome, Type, Descrição
per_pageinteger

The number of results per page (max 100).

Default: 30

pageinteger

Page number of the results to fetch.

Default: 1

HTTP response status codes

Status codeDescrição
200

OK

Code samples

get/repos/{owner}/{repo}/pages/builds
curl \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/pages/builds

Response

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" } ]

Request a GitHub Enterprise Server Pages build

Works with GitHub Apps

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.

Parameters

Headers
Nome, Type, Descrição
acceptstring

Setting to application/vnd.github+json is recommended.

Path parameters
Nome, Type, Descrição
ownerstringRequired

The account owner of the repository. The name is not case sensitive.

repostringRequired

The name of the repository. The name is not case sensitive.

HTTP response status codes

Status codeDescrição
201

Created

Code samples

post/repos/{owner}/{repo}/pages/builds
curl \ -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/pages/builds

Response

Status: 201
{ "url": "https://api.github.com/repos/github/developer.github.com/pages/builds/latest", "status": "queued" }

Get latest Pages build

Works with GitHub Apps

Parameters

Headers
Nome, Type, Descrição
acceptstring

Setting to application/vnd.github+json is recommended.

Path parameters
Nome, Type, Descrição
ownerstringRequired

The account owner of the repository. The name is not case sensitive.

repostringRequired

The name of the repository. The name is not case sensitive.

HTTP response status codes

Status codeDescrição
200

OK

Code samples

get/repos/{owner}/{repo}/pages/builds/latest
curl \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/pages/builds/latest

Response

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" }

Get GitHub Enterprise Server Pages build

Works with GitHub Apps

Parameters

Headers
Nome, Type, Descrição
acceptstring

Setting to application/vnd.github+json is recommended.

Path parameters
Nome, Type, Descrição
ownerstringRequired

The account owner of the repository. The name is not case sensitive.

repostringRequired

The name of the repository. The name is not case sensitive.

build_idintegerRequired

HTTP response status codes

Status codeDescrição
200

OK

Code samples

get/repos/{owner}/{repo}/pages/builds/{build_id}
curl \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/pages/builds/BUILD_ID

Response

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" }