Accept a repository invitation

octokit.repos.acceptInvitation({
invitation_id,
});

Parameters

namerequireddescription
invitation_idyes

invitation_id parameter

See also: GitHub Developer Guide documentation.

Add app access restrictions

Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see GitHub's products in the GitHub Help documentation.

Grants the specified apps push access for this branch. Only installed GitHub Apps with write access to the contents permission can be added as authorized actors on a protected branch.

TypeDescription
arrayThe GitHub Apps that have push access to this branch. Use the app's slug. Note: The list of users, apps, and teams in total is limited to 100 items.
octokit.repos.addAppAccessRestrictions({
owner,
repo,
branch,
apps,
});

Parameters

namerequireddescription
owneryes
repoyes
branchyes

The name of the branch.

appsyes

See also: GitHub Developer Guide documentation.

Add a repository collaborator

This endpoint triggers notifications. Creating content too quickly using this endpoint may result in abuse rate limiting. See "Abuse rate limits" and "Dealing with abuse rate limits" for details.

For more information the permission levels, see "Repository permission levels for an organization".

Note that, if you choose not to pass any parameters, you'll need to set Content-Length to zero when calling out to this endpoint. For more information, see "HTTP verbs."

The invitee will receive a notification that they have been invited to the repository, which they must accept or decline. They may do this via the notifications page, the email they receive, or by using the repository invitations API endpoints.

Rate limits

To prevent abuse, you are limited to sending 50 invitations to a repository per 24 hour period. Note there is no limit if you are inviting organization members to an organization repository.

octokit.repos.addCollaborator({
owner,
repo,
username,
});

Parameters

namerequireddescription
owneryes
repoyes
usernameyes
permissionno

The permission to grant the collaborator. Only valid on organization-owned repositories. Can be one of:
* pull - can pull, but not push to or administer this repository.
* push - can pull and push, but not administer this repository.
* admin - can pull, push and administer this repository.
* maintain - Recommended for project managers who need to manage the repository without access to sensitive or destructive actions.
* triage - Recommended for contributors who need to proactively manage issues and pull requests without write access.

permissionsno

See also: GitHub Developer Guide documentation.

Add status check contexts

Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see GitHub's products in the GitHub Help documentation.

octokit.repos.addStatusCheckContexts({
owner,
repo,
branch,
contexts,
});

Parameters

namerequireddescription
owneryes
repoyes
branchyes

The name of the branch.

contextsyes

See also: GitHub Developer Guide documentation.

Add team access restrictions

Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see GitHub's products in the GitHub Help documentation.

Grants the specified teams push access for this branch. You can also give push access to child teams.

TypeDescription
arrayThe teams that can have push access. Use the team's slug. Note: The list of users, apps, and teams in total is limited to 100 items.
octokit.repos.addTeamAccessRestrictions({
owner,
repo,
branch,
teams,
});

Parameters

namerequireddescription
owneryes
repoyes
branchyes

The name of the branch.

teamsyes

See also: GitHub Developer Guide documentation.

Add user access restrictions

Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see GitHub's products in the GitHub Help documentation.

Grants the specified people push access for this branch.

TypeDescription
arrayUsernames for people who can have push access. Note: The list of users, apps, and teams in total is limited to 100 items.
octokit.repos.addUserAccessRestrictions({
owner,
repo,
branch,
users,
});

Parameters

namerequireddescription
owneryes
repoyes
branchyes

The name of the branch.

usersyes

See also: GitHub Developer Guide documentation.

Check if a user is a repository collaborator

For organization-owned repositories, the list of collaborators includes outside collaborators, organization members that are direct collaborators, organization members with access through team memberships, organization members with access through default organization permissions, and organization owners.

Team members will include the members of child teams.

octokit.repos.checkCollaborator({
owner,
repo,
username,
});

Parameters

namerequireddescription
owneryes
repoyes
usernameyes

See also: GitHub Developer Guide documentation.

Check if vulnerability alerts are enabled for a repository

Shows whether dependency alerts are enabled or disabled for a repository. The authenticated user must have admin access to the repository. For more information, see "About security alerts for vulnerable dependencies".

octokit.repos.checkVulnerabilityAlerts({
owner,
repo,
});

Parameters

namerequireddescription
owneryes
repoyes

See also: GitHub Developer Guide documentation.

Compare two commits

Both :base and :head must be branch names in :repo. To compare branches across other repositories in the same network as :repo, use the format <USERNAME>:branch.

The response from the API is equivalent to running the git log base..head command; however, commits are returned in chronological order. Pass the appropriate media type to fetch diff and patch formats.

The response also includes details on the files that were changed between the two commits. This includes the status of the change (for example, if a file was added, removed, modified, or renamed), and details of the change itself. For example, files with a renamed status have a previous_filename field showing the previous filename of the file, and files with a modified status have a patch field showing the changes made to the file.

Working with large comparisons

The response will include a comparison of up to 250 commits. If you are working with a larger commit range, you can use the List commits to enumerate all commits in the range.

For comparisons with extremely large diffs, you may receive an error response indicating that the diff took too long to generate. You can typically resolve this error by using a smaller commit range.

Signature verification object

The response will include a verification object that describes the result of verifying the commit's signature. The following fields are included in the verification object:

NameTypeDescription
verifiedbooleanIndicates whether GitHub considers the signature in this commit to be verified.
reasonstringThe reason for verified value. Possible values and their meanings are enumerated in table below.
signaturestringThe signature that was extracted from the commit.
payloadstringThe value that was signed.

These are the possible values for reason in the verification object:

ValueDescription
expired_keyThe key that made the signature is expired.
not_signing_keyThe "signing" flag is not among the usage flags in the GPG key that made the signature.
gpgverify_errorThere was an error communicating with the signature verification service.
gpgverify_unavailableThe signature verification service is currently unavailable.
unsignedThe object does not include a signature.
unknown_signature_typeA non-PGP signature was found in the commit.
no_userNo user was associated with the committer email address in the commit.
unverified_emailThe committer email address in the commit was associated with a user, but the email address is not verified on her/his account.
bad_emailThe committer email address in the commit is not included in the identities of the PGP key that made the signature.
unknown_keyThe key that made the signature has not been registered with any user's account.
malformed_signatureThere was an error parsing the signature.
invalidThe signature could not be cryptographically verified using the key whose key-id was found in the signature.
validNone of the above errors applied, so the signature is considered to be verified.
octokit.repos.compareCommits({
owner,
repo,
base,
head,
});

Parameters

namerequireddescription
owneryes
repoyes
baseyes
headyes

See also: GitHub Developer Guide documentation.

Create a commit comment

Create a comment for a commit using its :commit_sha.

This endpoint triggers notifications. Creating content too quickly using this endpoint may result in abuse rate limiting. See "Abuse rate limits" and "Dealing with abuse rate limits" for details.

octokit.repos.createCommitComment({
owner,
repo,
commit_sha,
body,
});

Parameters

namerequireddescription
owneryes
repoyes
commit_shayes

commit_sha parameter

bodyyes

The contents of the comment.

pathno

Relative path of the file to comment on.

positionno

Line index in the diff to comment on.

lineno

Deprecated. Use position parameter instead. Line number in the file to comment on.

See also: GitHub Developer Guide documentation.

Create commit signature protection

Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see GitHub's products in the GitHub Help documentation.

When authenticated with admin or owner permissions to the repository, you can use this endpoint to require signed commits on a branch. You must enable branch protection to require signed commits.

octokit.repos.createCommitSignatureProtection({
owner,
repo,
branch,
});

Parameters

namerequireddescription
owneryes
repoyes
branchyes

The name of the branch.

See also: GitHub Developer Guide documentation.

Create a commit status

Users with push access in a repository can create commit statuses for a given SHA.

Note: there is a limit of 1000 statuses per sha and context within a repository. Attempts to create more than 1000 statuses will result in a validation error.

octokit.repos.createCommitStatus({
owner,
repo,
sha,
state,
});

Parameters

namerequireddescription
owneryes
repoyes
shayes
stateyes

The state of the status. Can be one of error, failure, pending, or success.

target_urlno

The target URL to associate with this status. This URL will be linked from the GitHub UI to allow users to easily see the source of the status.
For example, if your continuous integration system is posting build status, you would want to provide the deep link for the build output for this specific SHA:
http://ci.example.com/user/repo/build/sha

descriptionno

A short description of the status.

contextno

A string label to differentiate this status from the status of other systems. This field is case-insensitive.

See also: GitHub Developer Guide documentation.

Create a deploy key

You can create a read-only deploy key.

octokit.repos.createDeployKey({
owner,
repo,
key,
});

Parameters

namerequireddescription
owneryes
repoyes
titleno

A name for the key.

keyyes

The contents of the key.

read_onlyno

If true, the key will only be able to read repository contents. Otherwise, the key will be able to read and write.

Deploy keys with write access can perform the same actions as an organization member with admin access, or a collaborator on a personal repository. For more information, see "Repository permission levels for an organization" and "Permission levels for a user account repository."

See also: GitHub Developer Guide documentation.

Create a deployment

Deployments offer a few configurable parameters with certain defaults.

The ref parameter can be any named branch, tag, or SHA. At GitHub we often deploy branches and verify them before we merge a pull request.

The environment parameter allows deployments to be issued to different runtime environments. Teams often have multiple environments for verifying their applications, such as production, staging, and qa. This parameter makes it easier to track which environments have requested deployments. The default environment is production.

The auto_merge parameter is used to ensure that the requested ref is not behind the repository's default branch. If the ref is behind the default branch for the repository, we will attempt to merge it for you. If the merge succeeds, the API will return a successful merge commit. If merge conflicts prevent the merge from succeeding, the API will return a failure response.

By default, commit statuses for every submitted context must be in a successstate. The required_contexts parameter allows you to specify a subset of contexts that must be success, or to specify contexts that have not yet been submitted. You are not required to use commit statuses to deploy. If you do not require any contexts or create any commit statuses, the deployment will always succeed.

The payload parameter is available for any extra information that a deployment system might need. It is a JSON text field that will be passed on when a deployment event is dispatched.

The task parameter is used by the deployment system to allow different execution paths. In the web world this might be deploy:migrations to run schema changes on the system. In the compiled world this could be a flag to compile an application with debugging enabled.

Users with repo or repo_deployment scopes can create a deployment for a given ref.

Merged branch response

You will see this response when GitHub automatically merges the base branch into the topic branch instead of creating a deployment. This auto-merge happens when:

  • Auto-merge option is enabled in the repository
  • Topic branch does not include the latest changes on the base branch, which is master in the response example
  • There are no merge conflicts

If there are no new commits in the base branch, a new request to create a deployment should give a successful response.

Merge conflict response

This error happens when the auto_merge option is enabled and when the default branch (in this case master), can't be merged into the branch that's being deployed (in this case topic-branch), due to merge conflicts.

Failed commit status checks

This error happens when the required_contexts parameter indicates that one or more contexts need to have a successstatus for the commit to be deployed, but one or more of the required contexts do not have a state of success.

octokit.repos.createDeployment({
owner,
repo,
ref,
});

Parameters

namerequireddescription
owneryes
repoyes
refyes

The ref to deploy. This can be a branch, tag, or SHA.

taskno

Specifies a task to execute (e.g., deploy or deploy:migrations).

auto_mergeno

Attempts to automatically merge the default branch into the requested ref, if it's behind the default branch.

required_contextsno

The status contexts to verify against commit status checks. If you omit this parameter, GitHub verifies all unique contexts before creating a deployment. To bypass checking entirely, pass an empty array. Defaults to all unique contexts.

payloadno
environmentno

Name for the target deployment environment (e.g., production, staging, qa).

descriptionno

Short description of the deployment.

transient_environmentno

Specifies if the given environment is specific to the deployment and will no longer exist at some point in the future. Default: false
Note: This parameter requires you to use the application/vnd.github.ant-man-preview+json custom media type. Note: This parameter requires you to use the application/vnd.github.ant-man-preview+json custom media type.

production_environmentno

Specifies if the given environment is one that end-users directly interact with. Default: true when environment is production and false otherwise.
Note: This parameter requires you to use the application/vnd.github.ant-man-preview+json custom media type.

created_atno

See also: GitHub Developer Guide documentation.

Create a deployment status

Users with push access can create deployment statuses for a given deployment.

GitHub Apps require read & write access to "Deployments" and read-only access to "Repo contents" (for private repos). OAuth Apps require the repo_deployment scope.

octokit.repos.createDeploymentStatus({
owner,
repo,
deployment_id,
state,
});

Parameters

namerequireddescription
owneryes
repoyes
deployment_idyes

deployment_id parameter

stateyes

The state of the status. Can be one of error, failure, inactive, in_progress, queued pending, or success. Note: To use the inactive state, you must provide the application/vnd.github.ant-man-preview+json custom media type. To use the in_progress and queued states, you must provide the application/vnd.github.flash-preview+json custom media type. When you set a transient deployment to inactive, the deployment will be shown as destroyed in GitHub.

target_urlno

The target URL to associate with this status. This URL should contain output to keep the user updated while the task is running or serve as historical information for what happened in the deployment. Note: It's recommended to use the log_url parameter, which replaces target_url.

log_urlno

The full URL of the deployment's output. This parameter replaces target_url. We will continue to accept target_url to support legacy uses, but we recommend replacing target_url with log_url. Setting log_url will automatically set target_url to the same value. Default: ""
Note: This parameter requires you to use the application/vnd.github.ant-man-preview+json custom media type. Note: This parameter requires you to use the application/vnd.github.ant-man-preview+json custom media type.

descriptionno

A short description of the status. The maximum description length is 140 characters.

environmentno

Name for the target deployment environment, which can be changed when setting a deploy status. For example, production, staging, or qa. Note: This parameter requires you to use the application/vnd.github.flash-preview+json custom media type.

environment_urlno

Sets the URL for accessing your environment. Default: ""
Note: This parameter requires you to use the application/vnd.github.ant-man-preview+json custom media type. Note: This parameter requires you to use the application/vnd.github.ant-man-preview+json custom media type.

auto_inactiveno

Adds a new inactive status to all prior non-transient, non-production environment deployments with the same repository and environment name as the created status's deployment. An inactive status is only added to deployments that had a success state. Default: true
Note: To add an inactive status to production environments, you must use the application/vnd.github.flash-preview+json custom media type.
Note: This parameter requires you to use the application/vnd.github.ant-man-preview+json custom media type.

See also: GitHub Developer Guide documentation.

Create a repository dispatch event

You can use this endpoint to trigger a webhook event called repository_dispatch when you want activity that happens outside of GitHub to trigger a GitHub Actions workflow or GitHub App webhook. You must configure your GitHub Actions workflow or GitHub App to run when the repository_dispatch event occurs. For an example repository_dispatch webhook payload, see "RepositoryDispatchEvent."

The client_payload parameter is available for any extra information that your workflow might need. This parameter is a JSON payload that will be passed on when the webhook event is dispatched. For example, the client_payload can include a message that a user would like to send using a GitHub Actions workflow. Or the client_payload can be used as a test to debug your workflow.

This endpoint requires write access to the repository by providing either:

This input example shows how you can use the client_payload as a test to debug your workflow.

octokit.repos.createDispatchEvent({
owner,
repo,
event_type,
});

Parameters

namerequireddescription
owneryes
repoyes
event_typeyes

A custom webhook event name.

client_payloadno

JSON payload with extra information about the webhook event that your action or worklow may use.

client_payload.*no

See also: GitHub Developer Guide documentation.

Create a repository for the authenticated user

Creates a new repository for the authenticated user.

OAuth scope requirements

When using OAuth, authorizations must include:

  • public_repo scope or repo scope to create a public repository
  • repo scope to create a private repository
octokit.repos.createForAuthenticatedUser({
name,
});

Parameters

namerequireddescription
nameyes

The name of the repository.

descriptionno

A short description of the repository.

homepageno

A URL with more information about the repository.

privateno

Whether the repository is private or public.

has_issuesno

Whether issues are enabled.

has_projectsno

Whether projects are enabled.

has_wikino

Whether the wiki is enabled.

team_idno

The id of the team that will be granted access to this repository. This is only valid when creating a repository in an organization.

auto_initno

Whether the repository is initialized with a minimal README.

gitignore_templateno

The desired language or platform to apply to the .gitignore.

license_templateno

The license keyword of the open source license for this repository.

allow_squash_mergeno

Whether to allow squash merges for pull requests.

allow_merge_commitno

Whether to allow merge commits for pull requests.

allow_rebase_mergeno

Whether to allow rebase merges for pull requests.

delete_branch_on_mergeno

Whether to delete head branches when pull requests are merged

has_downloadsno

Whether downloads are enabled.

is_templateno

Whether this repository acts as a template that can be used to generate new repositories.

See also: GitHub Developer Guide documentation.

Create a fork

Create a fork for the authenticated user.

Note: Forking a Repository happens asynchronously. You may have to wait a short period of time before you can access the git objects. If this takes longer than 5 minutes, be sure to contact GitHub Support or GitHub Premium Support.

octokit.repos.createFork({
owner,
repo,
});

Parameters

namerequireddescription
owneryes
repoyes
organizationno

Optional parameter to specify the organization name if forking into an organization.

See also: GitHub Developer Guide documentation.

Create an organization repository

Creates a new repository in the specified organization. The authenticated user must be a member of the organization.

OAuth scope requirements

When using OAuth, authorizations must include:

  • public_repo scope or repo scope to create a public repository
  • repo scope to create a private repository
octokit.repos.createInOrg({
org,
name,
});

Parameters

namerequireddescription
orgyes
nameyes

The name of the repository.

descriptionno

A short description of the repository.

homepageno

A URL with more information about the repository.

privateno

Either true to create a private repository or false to create a public one.

visibilityno

Can be public or private. If your organization is associated with an enterprise account using GitHub Enterprise Cloud or GitHub Enterprise Server 2.20+, visibility can also be internal. For more information, see "Creating an internal repository" in the GitHub Help documentation.
The visibility parameter overrides the private parameter when you use both parameters with the nebula-preview preview header.

has_issuesno

Either true to enable issues for this repository or false to disable them.

has_projectsno

Either true to enable projects for this repository or false to disable them. Note: If you're creating a repository in an organization that has disabled repository projects, the default is false, and if you pass true, the API returns an error.

has_wikino

Either true to enable the wiki for this repository or false to disable it.

is_templateno

Either true to make this repo available as a template repository or false to prevent it.

team_idno

The id of the team that will be granted access to this repository. This is only valid when creating a repository in an organization.

auto_initno

Pass true to create an initial commit with empty README.

gitignore_templateno

Desired language or platform .gitignore template to apply. Use the name of the template without the extension. For example, "Haskell".

license_templateno

Choose an open source license template that best suits your needs, and then use the license keyword as the license_template string. For example, "mit" or "mpl-2.0".

allow_squash_mergeno

Either true to allow squash-merging pull requests, or false to prevent squash-merging.

allow_merge_commitno

Either true to allow merging pull requests with a merge commit, or false to prevent merging pull requests with merge commits.

allow_rebase_mergeno

Either true to allow rebase-merging pull requests, or false to prevent rebase-merging.

delete_branch_on_mergeno

Either true to allow automatically deleting head branches when pull requests are merged, or false to prevent automatic deletion.

See also: GitHub Developer Guide documentation.

Create or update file contents

Creates a new file or replaces an existing file in a repository.

octokit.repos.createOrUpdateFileContents({
owner,
repo,
path,
message,
content,
committer.name,
committer.email,
author.name,
author.email
})

Parameters

namerequireddescription
owneryes
repoyes
pathyes

path+ parameter

messageyes

The commit message.

contentyes

The new file content, using Base64 encoding.

shano

Required if you are updating a file. The blob SHA of the file being replaced.

branchno

The branch name. Default: the repository’s default branch (usually master)

committerno

The person that committed the file. Default: the authenticated user.

committer.nameyes

The name of the author or committer of the commit. You'll receive a 422 status code if name is omitted.

committer.emailyes

The email of the author or committer of the commit. You'll receive a 422 status code if email is omitted.

committer.dateno
authorno

The author of the file. Default: The committer or the authenticated user if you omit committer.

author.nameyes

The name of the author or committer of the commit. You'll receive a 422 status code if name is omitted.

author.emailyes

The email of the author or committer of the commit. You'll receive a 422 status code if email is omitted.

author.dateno

See also: GitHub Developer Guide documentation.

Create a GitHub Pages site

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

octokit.repos.createPagesSite({
owner,
repo,
source,
source.branch
})

Parameters

namerequireddescription
owneryes
repoyes
sourceyes

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

source.branchyes

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

source.pathno

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

See also: GitHub Developer Guide documentation.

Create a release

Users with push access to the repository can create a release.

This endpoint triggers notifications. Creating content too quickly using this endpoint may result in abuse rate limiting. See "Abuse rate limits" and "Dealing with abuse rate limits" for details.

octokit.repos.createRelease({
owner,
repo,
tag_name,
});

Parameters

namerequireddescription
owneryes
repoyes
tag_nameyes

The name of the tag.

target_commitishno

Specifies the commitish value that determines where the Git tag is created from. Can be any branch or commit SHA. Unused if the Git tag already exists. Default: the repository's default branch (usually master).

nameno

The name of the release.

bodyno

Text describing the contents of the tag.

draftno

true to create a draft (unpublished) release, false to create a published one.

prereleaseno

true to identify the release as a prerelease. false to identify the release as a full release.

See also: GitHub Developer Guide documentation.

Create a repository using a template

Creates a new repository using a repository template. Use the template_owner and template_repo route parameters to specify the repository to use as the template. The authenticated user must own or be a member of an organization that owns the repository. To check if a repository is available to use as a template, get the repository's information using the Get a repository endpoint and check that the is_template key is true.

OAuth scope requirements

When using OAuth, authorizations must include:

  • public_repo scope or repo scope to create a public repository
  • repo scope to create a private repository
octokit.repos.createUsingTemplate({
template_owner,
template_repo,
name,
});

Parameters

namerequireddescription
template_owneryes
template_repoyes
ownerno

The organization or person who will own the new repository. To create a new repository in an organization, the authenticated user must be a member of the specified organization.

nameyes

The name of the new repository.

descriptionno

A short description of the new repository.

include_all_branchesno

Set to true to include the directory structure and files from all branches in the template repository, and not just the default branch. Default: false.

privateno

Either true to create a new private repository or false to create a new public one.

See also: GitHub Developer Guide documentation.

Create a repository webhook

Repositories can have multiple webhooks installed. Each webhook should have a unique config. Multiple webhooks can share the same config as long as those webhooks do not have any events that overlap.

octokit.repos.createWebhook({
owner,
repo,
config,
config.url
})

Parameters

namerequireddescription
owneryes
repoyes
nameno

Use web to create a webhook. Default: web. This parameter only accepts the value web.

configyes

Key/value pairs to provide settings for this webhook. These are defined below.

config.urlyes

The URL to which the payloads will be delivered.

config.content_typeno

The media type used to serialize the payloads. Supported values include json and form. The default is form.

config.secretno

If provided, the secret will be used as the key to generate the HMAC hex digest value for delivery signature headers.

config.insecure_sslno

Determines whether the SSL certificate of the host for url will be verified when delivering payloads. Supported values include 0 (verification is performed) and 1 (verification is not performed). The default is 0. We strongly recommend not setting this to 1 as you are subject to man-in-the-middle and other attacks.

config.tokenno
config.digestno
eventsno

Determines what events the hook is triggered for.

activeno

Determines if notifications are sent when the webhook is triggered. Set to true to send notifications.

See also: GitHub Developer Guide documentation.

Decline a repository invitation

octokit.repos.declineInvitation({
invitation_id,
});

Parameters

namerequireddescription
invitation_idyes

invitation_id parameter

See also: GitHub Developer Guide documentation.

Delete a repository

Deleting a repository requires admin access. If OAuth is used, the delete_repo scope is required.

If an organization owner has configured the organization to prevent members from deleting organization-owned repositories, you will get a 403 Forbidden response.

octokit.repos.delete({
owner,
repo,
});

Parameters

namerequireddescription
owneryes
repoyes

See also: GitHub Developer Guide documentation.

Delete access restrictions

Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see GitHub's products in the GitHub Help documentation.

Disables the ability to restrict who can push to this branch.

octokit.repos.deleteAccessRestrictions({
owner,
repo,
branch,
});

Parameters

namerequireddescription
owneryes
repoyes
branchyes

The name of the branch.

See also: GitHub Developer Guide documentation.

Delete admin branch protection

Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see GitHub's products in the GitHub Help documentation.

Removing admin enforcement requires admin or owner permissions to the repository and branch protection to be enabled.

octokit.repos.deleteAdminBranchProtection({
owner,
repo,
branch,
});

Parameters

namerequireddescription
owneryes
repoyes
branchyes

The name of the branch.

See also: GitHub Developer Guide documentation.

Delete branch protection

Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see GitHub's products in the GitHub Help documentation.

octokit.repos.deleteBranchProtection({
owner,
repo,
branch,
});

Parameters

namerequireddescription
owneryes
repoyes
branchyes

The name of the branch.

See also: GitHub Developer Guide documentation.

Delete a commit comment

octokit.repos.deleteCommitComment({
owner,
repo,
comment_id,
});

Parameters

namerequireddescription
owneryes
repoyes
comment_idyes

comment_id parameter

See also: GitHub Developer Guide documentation.

Delete commit signature protection

Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see GitHub's products in the GitHub Help documentation.

When authenticated with admin or owner permissions to the repository, you can use this endpoint to disable required signed commits on a branch. You must enable branch protection to require signed commits.

octokit.repos.deleteCommitSignatureProtection({
owner,
repo,
branch,
});

Parameters

namerequireddescription
owneryes
repoyes
branchyes

The name of the branch.

See also: GitHub Developer Guide documentation.

Delete a deploy key

Deploy keys are immutable. If you need to update a key, remove the key and create a new one instead.

octokit.repos.deleteDeployKey({
owner,
repo,
key_id,
});

Parameters

namerequireddescription
owneryes
repoyes
key_idyes

key_id parameter

See also: GitHub Developer Guide documentation.

Delete a deployment

To ensure there can always be an active deployment, you can only delete an inactive deployment. Anyone with repo or repo_deployment scopes can delete an inactive deployment.

To set a deployment as inactive, you must:

  • Create a new deployment that is active so that the system has a record of the current state, then delete the previously active deployment.
  • Mark the active deployment as inactive by adding any non-successful deployment status.

For more information, see "Create a deployment" and "Create a deployment status."

octokit.repos.deleteDeployment({
owner,
repo,
deployment_id,
});

Parameters

namerequireddescription
owneryes
repoyes
deployment_idyes

deployment_id parameter

See also: GitHub Developer Guide documentation.

Delete a file

Deletes a file in a repository.

You can provide an additional committer parameter, which is an object containing information about the committer. Or, you can provide an author parameter, which is an object containing information about the author.

The author section is optional and is filled in with the committer information if omitted. If the committer information is omitted, the authenticated user's information is used.

You must provide values for both name and email, whether you choose to use author or committer. Otherwise, you'll receive a 422 status code.

octokit.repos.deleteFile({
owner,
repo,
path,
message,
sha,
});

Parameters

namerequireddescription
owneryes
repoyes
pathyes

path+ parameter

messageyes

The commit message.

shayes

The blob SHA of the file being replaced.

branchno

The branch name. Default: the repository’s default branch (usually master)

committerno

object containing information about the committer.

committer.nameno

The name of the author (or committer) of the commit

committer.emailno

The email of the author (or committer) of the commit

authorno

object containing information about the author.

author.nameno

The name of the author (or committer) of the commit

author.emailno

The email of the author (or committer) of the commit

See also: GitHub Developer Guide documentation.

Delete a repository invitation

octokit.repos.deleteInvitation({
owner,
repo,
invitation_id,
});

Parameters

namerequireddescription
owneryes
repoyes
invitation_idyes

invitation_id parameter

See also: GitHub Developer Guide documentation.

Delete a GitHub Pages site

octokit.repos.deletePagesSite({
owner,
repo,
});

Parameters

namerequireddescription
owneryes
repoyes

See also: GitHub Developer Guide documentation.

Delete pull request review protection

Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see GitHub's products in the GitHub Help documentation.

octokit.repos.deletePullRequestReviewProtection({
owner,
repo,
branch,
});

Parameters

namerequireddescription
owneryes
repoyes
branchyes

The name of the branch.

See also: GitHub Developer Guide documentation.

Delete a release

Users with push access to the repository can delete a release.

octokit.repos.deleteRelease({
owner,
repo,
release_id,
});

Parameters

namerequireddescription
owneryes
repoyes
release_idyes

release_id parameter

See also: GitHub Developer Guide documentation.

Delete a release asset

octokit.repos.deleteReleaseAsset({
owner,
repo,
asset_id,
});

Parameters

namerequireddescription
owneryes
repoyes
asset_idyes

asset_id parameter

See also: GitHub Developer Guide documentation.

Delete a repository webhook

octokit.repos.deleteWebhook({
owner,
repo,
hook_id,
});

Parameters

namerequireddescription
owneryes
repoyes
hook_idyes

See also: GitHub Developer Guide documentation.

Disable automated security fixes

Disables automated security fixes for a repository. The authenticated user must have admin access to the repository. For more information, see "Configuring automated security fixes".

octokit.repos.disableAutomatedSecurityFixes({
owner,
repo,
});

Parameters

namerequireddescription
owneryes
repoyes

See also: GitHub Developer Guide documentation.

Disable vulnerability alerts

Disables dependency alerts and the dependency graph for a repository. The authenticated user must have admin access to the repository. For more information, see "About security alerts for vulnerable dependencies".

octokit.repos.disableVulnerabilityAlerts({
owner,
repo,
});

Parameters

namerequireddescription
owneryes
repoyes

See also: GitHub Developer Guide documentation.

Download a repository archive (zip)

Deprecated: This method has been renamed to repos.downloadZipballArchive

Gets a redirect URL to download a zip archive for a repository. If you omit :ref, the repository’s default branch (usuallymaster) will be used. Please make sure your HTTP framework is configured to follow redirects or you will need to use the Location header to make a second GET request.Note: For private repositories, these links are temporary and expire after five minutes.

octokit.repos.downloadArchive({
owner,
repo,
ref,
});

Parameters

namerequireddescription
owneryes
repoyes
refyes

See also: GitHub Developer Guide documentation.

Download a repository archive (tar)

Gets a redirect URL to download a tar archive for a repository. If you omit :ref, the repository’s default branch (usuallymaster) will be used. Please make sure your HTTP framework is configured to follow redirects or you will need to use the Location header to make a second GET request.Note: For private repositories, these links are temporary and expire after five minutes.

octokit.repos.downloadTarballArchive({
owner,
repo,
ref,
});

Parameters

namerequireddescription
owneryes
repoyes
refyes

See also: GitHub Developer Guide documentation.

Download a repository archive (zip)

Gets a redirect URL to download a zip archive for a repository. If you omit :ref, the repository’s default branch (usuallymaster) will be used. Please make sure your HTTP framework is configured to follow redirects or you will need to use the Location header to make a second GET request.Note: For private repositories, these links are temporary and expire after five minutes.

octokit.repos.downloadZipballArchive({
owner,
repo,
ref,
});

Parameters

namerequireddescription
owneryes
repoyes
refyes

See also: GitHub Developer Guide documentation.

Enable automated security fixes

Enables automated security fixes for a repository. The authenticated user must have admin access to the repository. For more information, see "Configuring automated security fixes".

octokit.repos.enableAutomatedSecurityFixes({
owner,
repo,
});

Parameters

namerequireddescription
owneryes
repoyes

See also: GitHub Developer Guide documentation.

Enable vulnerability alerts

Enables dependency alerts and the dependency graph for a repository. The authenticated user must have admin access to the repository. For more information, see "About security alerts for vulnerable dependencies".

octokit.repos.enableVulnerabilityAlerts({
owner,
repo,
});

Parameters

namerequireddescription
owneryes
repoyes

See also: GitHub Developer Guide documentation.

Get a repository

When you pass the scarlet-witch-preview media type, requests to get a repository will also return the repository's code of conduct if it can be detected from the repository's code of conduct file.

The parent and source objects are present when the repository is a fork. parent is the repository this repository was forked from, source is the ultimate source for the network.

octokit.repos.get({
owner,
repo,
});

Parameters

namerequireddescription
owneryes
repoyes

See also: GitHub Developer Guide documentation.

Get access restrictions

Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see GitHub's products in the GitHub Help documentation.

Lists who has access to this protected branch.

Note: Users, apps, and teams restrictions are only available for organization-owned repositories.

octokit.repos.getAccessRestrictions({
owner,
repo,
branch,
});

Parameters

namerequireddescription
owneryes
repoyes
branchyes

The name of the branch.

See also: GitHub Developer Guide documentation.

Get admin branch protection

Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see GitHub's products in the GitHub Help documentation.

octokit.repos.getAdminBranchProtection({
owner,
repo,
branch,
});

Parameters

namerequireddescription
owneryes
repoyes
branchyes

The name of the branch.

See also: GitHub Developer Guide documentation.

Get all status check contexts

Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see GitHub's products in the GitHub Help documentation.

octokit.repos.getAllStatusCheckContexts({
owner,
repo,
branch,
});

Parameters

namerequireddescription
owneryes
repoyes
branchyes

The name of the branch.

See also: GitHub Developer Guide documentation.

Get all repository topics

octokit.repos.getAllTopics({
owner,
repo,
});

Parameters

namerequireddescription
owneryes
repoyes

See also: GitHub Developer Guide documentation.

Get apps with access to the protected branch

Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see GitHub's products in the GitHub Help documentation.

Lists the GitHub Apps that have push access to this branch. Only installed GitHub Apps with write access to the contents permission can be added as authorized actors on a protected branch.

octokit.repos.getAppsWithAccessToProtectedBranch({
owner,
repo,
branch,
});

Parameters

namerequireddescription
owneryes
repoyes
branchyes

The name of the branch.

See also: GitHub Developer Guide documentation.

Get a branch

octokit.repos.getBranch({
owner,
repo,
branch,
});

Parameters

namerequireddescription
owneryes
repoyes
branchyes

The name of the branch.

See also: GitHub Developer Guide documentation.

Get branch protection

Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see GitHub's products in the GitHub Help documentation.

octokit.repos.getBranchProtection({
owner,
repo,
branch,
});

Parameters

namerequireddescription
owneryes
repoyes
branchyes

The name of the branch.

See also: GitHub Developer Guide documentation.

Get repository clones

Get the total number of clones and breakdown per day or week for the last 14 days. Timestamps are aligned to UTC midnight of the beginning of the day or week. Week begins on Monday.

octokit.repos.getClones({
owner,
repo,
});

Parameters

namerequireddescription
owneryes
repoyes
perno

Must be one of: day, week.

See also: GitHub Developer Guide documentation.

Get the weekly commit activity

Returns a weekly aggregate of the number of additions and deletions pushed to a repository.

octokit.repos.getCodeFrequencyStats({
owner,
repo,
});

Parameters

namerequireddescription
owneryes
repoyes

See also: GitHub Developer Guide documentation.

Get repository permissions for a user

Checks the repository permission of a collaborator. The possible repository permissions are admin, write, read, and none.

octokit.repos.getCollaboratorPermissionLevel({
owner,
repo,
username,
});

Parameters

namerequireddescription
owneryes
repoyes
usernameyes

See also: GitHub Developer Guide documentation.

Get the combined status for a specific reference

Users with pull access in a repository can access a combined view of commit statuses for a given ref. The ref can be a SHA, a branch name, or a tag name.

The most recent status for each context is returned, up to 100. This field paginates if there are over 100 contexts.

Additionally, a combined state is returned. The state is one of:

  • failure if any of the contexts report as error or failure
  • pending if there are no statuses or a context is pending
  • success if the latest status for all contexts is success
octokit.repos.getCombinedStatusForRef({
owner,
repo,
ref,
});

Parameters

namerequireddescription
owneryes
repoyes
refyes

ref+ parameter

See also: GitHub Developer Guide documentation.

Get a commit

Returns the contents of a single commit reference. You must have read access for the repository to use this endpoint.

Note: If there are more than 300 files in the commit diff, the response will include pagination link headers for the remaining files, up to a limit of 3000 files. Each page contains the static commit information, and the only changes are to the file listing.

You can pass the appropriate media type to fetch diff and patch formats. Diffs with binary data will have no patch property.

To return only the SHA-1 hash of the commit reference, you can provide the sha custom media type in the Accept header. You can use this endpoint to check if a remote reference's SHA-1 hash is the same as your local reference's SHA-1 hash by providing the local SHA-1 reference as the ETag.

Signature verification object

The response will include a verification object that describes the result of verifying the commit's signature. The following fields are included in the verification object:

NameTypeDescription
verifiedbooleanIndicates whether GitHub considers the signature in this commit to be verified.
reasonstringThe reason for verified value. Possible values and their meanings are enumerated in table below.
signaturestringThe signature that was extracted from the commit.
payloadstringThe value that was signed.

These are the possible values for reason in the verification object:

ValueDescription
expired_keyThe key that made the signature is expired.
not_signing_keyThe "signing" flag is not among the usage flags in the GPG key that made the signature.
gpgverify_errorThere was an error communicating with the signature verification service.
gpgverify_unavailableThe signature verification service is currently unavailable.
unsignedThe object does not include a signature.
unknown_signature_typeA non-PGP signature was found in the commit.
no_userNo user was associated with the committer email address in the commit.
unverified_emailThe committer email address in the commit was associated with a user, but the email address is not verified on her/his account.
bad_emailThe committer email address in the commit is not included in the identities of the PGP key that made the signature.
unknown_keyThe key that made the signature has not been registered with any user's account.
malformed_signatureThere was an error parsing the signature.
invalidThe signature could not be cryptographically verified using the key whose key-id was found in the signature.
validNone of the above errors applied, so the signature is considered to be verified.
octokit.repos.getCommit({
owner,
repo,
ref,
});

Parameters

namerequireddescription
owneryes
repoyes
refyes

ref+ parameter

See also: GitHub Developer Guide documentation.

Get the last year of commit activity

Returns the last year of commit activity grouped by week. The days array is a group of commits per day, starting on Sunday.

octokit.repos.getCommitActivityStats({
owner,
repo,
});

Parameters

namerequireddescription
owneryes
repoyes

See also: GitHub Developer Guide documentation.

Get a commit comment

octokit.repos.getCommitComment({
owner,
repo,
comment_id,
});

Parameters

namerequireddescription
owneryes
repoyes
comment_idyes

comment_id parameter

See also: GitHub Developer Guide documentation.

Get commit signature protection

Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see GitHub's products in the GitHub Help documentation.

When authenticated with admin or owner permissions to the repository, you can use this endpoint to check whether a branch requires signed commits. An enabled status of true indicates you must sign commits on this branch. For more information, see Signing commits with GPG in GitHub Help.

Note: You must enable branch protection to require signed commits.

octokit.repos.getCommitSignatureProtection({
owner,
repo,
branch,
});

Parameters

namerequireddescription
owneryes
repoyes
branchyes

The name of the branch.

See also: GitHub Developer Guide documentation.

Get community profile metrics

This endpoint will return all community profile metrics, including an overall health score, repository description, the presence of documentation, detected code of conduct, detected license, and the presence of ISSUE_TEMPLATE, PULL_REQUEST_TEMPLATE, README, and CONTRIBUTING files.

The health_percentage score is defined as a percentage of how many of these four documents are present: README, CONTRIBUTING, LICENSE, and CODE_OF_CONDUCT. For example, if all four documents are present, then the health_percentage is 100. If only one is present, then thehealth_percentage is 25.

content_reports_enabled is only returned for organization-owned repositories.

octokit.repos.getCommunityProfileMetrics({
owner,
repo,
});

Parameters

namerequireddescription
owneryes
repoyes

See also: GitHub Developer Guide documentation.

Get repository content

Gets the contents of a file or directory in a repository. Specify the file path or directory in :path. If you omit:path, you will receive the contents of the repository's root directory. See the description below regarding what the API response includes for directories.

Files and symlinks support a custom media type for retrieving the raw content or rendered HTML (when supported). All content types support a custom media type to ensure the content is returned in a consistent object format.

Note:

  • To get a repository's contents recursively, you can recursively get the tree.
  • This API has an upper limit of 1,000 files for a directory. If you need to retrieve more files, use the Git Trees API.
  • This API supports files up to 1 megabyte in size.
If the content is a directory

The response will be an array of objects, one object for each item in the directory. When listing the contents of a directory, submodules have their "type" specified as "file". Logically, the valueshould be "submodule". This behavior exists in API v3 for backwards compatibility purposes. In the next major version of the API, the type will be returned as "submodule".

If the requested :path points to a symlink, and the symlink's target is a normal file in the repository, then the API responds with the content of the file (in the format shown in the example. Otherwise, the API responds with an object describing the symlink itself.

If the content is a submodule

The submodule_git_url identifies the location of the submodule repository, and the sha identifies a specific commit within the submodule repository. Git uses the given URL when cloning the submodule repository, and checks out the submodule at that specific commit.

If the submodule repository is not hosted on github.com, the Git URLs (git_url and _links["git"]) and the github.com URLs (html_url and _links["html"]) will have null values.

octokit.repos.getContent({
owner,
repo,
path,
});

Parameters

namerequireddescription
owneryes
repoyes
pathyes

path+ parameter

refno

The name of the commit/branch/tag. Default: the repository’s default branch (usually master)

See also: GitHub Developer Guide documentation.

Get all contributor commit activity

Returns the total number of commits authored by the contributor. In addition, the response includes a Weekly Hash (weeks array) with the following information:

  • w - Start of the week, given as a Unix timestamp.
  • a - Number of additions
  • d - Number of deletions
  • c - Number of commits
octokit.repos.getContributorsStats({
owner,
repo,
});

Parameters

namerequireddescription
owneryes
repoyes

See also: GitHub Developer Guide documentation.

Get a deploy key

octokit.repos.getDeployKey({
owner,
repo,
key_id,
});

Parameters

namerequireddescription
owneryes
repoyes
key_idyes

key_id parameter

See also: GitHub Developer Guide documentation.

Get a deployment

octokit.repos.getDeployment({
owner,
repo,
deployment_id,
});

Parameters

namerequireddescription
owneryes
repoyes
deployment_idyes

deployment_id parameter

See also: GitHub Developer Guide documentation.

Get a deployment status

Users with pull access can view a deployment status for a deployment:

octokit.repos.getDeploymentStatus({
owner,
repo,
deployment_id,
status_id,
});

Parameters

namerequireddescription
owneryes
repoyes
deployment_idyes

deployment_id parameter

status_idyes

See also: GitHub Developer Guide documentation.

Get latest Pages build

octokit.repos.getLatestPagesBuild({
owner,
repo,
});

Parameters

namerequireddescription
owneryes
repoyes

See also: GitHub Developer Guide documentation.

Get the latest release

View the latest published full release for the repository.

The latest release is the most recent non-prerelease, non-draft release, sorted by the created_at attribute. The created_at attribute is the date of the commit used for the release, and not the date when the release was drafted or published.

octokit.repos.getLatestRelease({
owner,
repo,
});

Parameters

namerequireddescription
owneryes
repoyes

See also: GitHub Developer Guide documentation.

Get a GitHub Pages site

octokit.repos.getPages({
owner,
repo,
});

Parameters

namerequireddescription
owneryes
repoyes

See also: GitHub Developer Guide documentation.

Get GitHub Pages build

octokit.repos.getPagesBuild({
owner,
repo,
build_id,
});

Parameters

namerequireddescription
owneryes
repoyes
build_idyes

See also: GitHub Developer Guide documentation.

Get the weekly commit count

Returns the total commit counts for the owner and total commit counts in all. all is everyone combined, including the owner in the last 52 weeks. If you'd like to get the commit counts for non-owners, you can subtract owner from all.

The array order is oldest week (index 0) to most recent week.

octokit.repos.getParticipationStats({
owner,
repo,
});

Parameters

namerequireddescription
owneryes
repoyes

See also: GitHub Developer Guide documentation.

Get pull request review protection

Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see GitHub's products in the GitHub Help documentation.

octokit.repos.getPullRequestReviewProtection({
owner,
repo,
branch,
});

Parameters

namerequireddescription
owneryes
repoyes
branchyes

The name of the branch.

See also: GitHub Developer Guide documentation.

Get the hourly commit count for each day

Each array contains the day number, hour number, and number of commits:

  • 0-6: Sunday - Saturday
  • 0-23: Hour of day
  • Number of commits

For example, [2, 14, 25] indicates that there were 25 total commits, during the 2:00pm hour on Tuesdays. All times are based on the time zone of individual commits.

octokit.repos.getPunchCardStats({
owner,
repo,
});

Parameters

namerequireddescription
owneryes
repoyes

See also: GitHub Developer Guide documentation.

Get a repository README

Gets the preferred README for a repository.

READMEs support custom media types for retrieving the raw content or rendered HTML.

octokit.repos.getReadme({
owner,
repo,
});

Parameters

namerequireddescription
owneryes
repoyes
refno

The name of the commit/branch/tag. Default: the repository’s default branch (usually master)

See also: GitHub Developer Guide documentation.

Get a release

Note: This returns an upload_url key corresponding to the endpoint for uploading release assets. This key is a hypermedia resource.

octokit.repos.getRelease({
owner,
repo,
release_id,
});

Parameters

namerequireddescription
owneryes
repoyes
release_idyes

release_id parameter

See also: GitHub Developer Guide documentation.

Get a release asset

To download the asset's binary content, set the Accept header of the request to application/octet-stream. The API will either redirect the client to the location, or stream it directly if possible. API clients should handle both a 200 or 302 response.

octokit.repos.getReleaseAsset({
owner,
repo,
asset_id,
});

Parameters

namerequireddescription
owneryes
repoyes
asset_idyes

asset_id parameter

See also: GitHub Developer Guide documentation.

Get a release by tag name

Get a published release with the specified tag.

octokit.repos.getReleaseByTag({
owner,
repo,
tag,
});

Parameters

namerequireddescription
owneryes
repoyes
tagyes

tag+ parameter

See also: GitHub Developer Guide documentation.

Get status checks protection

Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see GitHub's products in the GitHub Help documentation.

octokit.repos.getStatusChecksProtection({
owner,
repo,
branch,
});

Parameters

namerequireddescription
owneryes
repoyes
branchyes

The name of the branch.

See also: GitHub Developer Guide documentation.

Get teams with access to the protected branch

Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see GitHub's products in the GitHub Help documentation.

Lists the teams who have push access to this branch. The list includes child teams.

octokit.repos.getTeamsWithAccessToProtectedBranch({
owner,
repo,
branch,
});

Parameters

namerequireddescription
owneryes
repoyes
branchyes

The name of the branch.

See also: GitHub Developer Guide documentation.

Get top referral paths

Get the top 10 popular contents over the last 14 days.

octokit.repos.getTopPaths({
owner,
repo,
});

Parameters

namerequireddescription
owneryes
repoyes

See also: GitHub Developer Guide documentation.

Get top referral sources

Get the top 10 referrers over the last 14 days.

octokit.repos.getTopReferrers({
owner,
repo,
});

Parameters

namerequireddescription
owneryes
repoyes

See also: GitHub Developer Guide documentation.

Get users with access to the protected branch

Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see GitHub's products in the GitHub Help documentation.

Lists the people who have push access to this branch.

octokit.repos.getUsersWithAccessToProtectedBranch({
owner,
repo,
branch,
});

Parameters

namerequireddescription
owneryes
repoyes
branchyes

The name of the branch.

See also: GitHub Developer Guide documentation.

Get page views

Get the total number of views and breakdown per day or week for the last 14 days. Timestamps are aligned to UTC midnight of the beginning of the day or week. Week begins on Monday.

octokit.repos.getViews({
owner,
repo,
});

Parameters

namerequireddescription
owneryes
repoyes
perno

Must be one of: day, week.

See also: GitHub Developer Guide documentation.

Get a repository webhook

Returns a webhook configured in a repository. To get only the webhook config properties, see "Get a webhook configuration for a repository."

octokit.repos.getWebhook({
owner,
repo,
hook_id,
});

Parameters

namerequireddescription
owneryes
repoyes
hook_idyes

See also: GitHub Developer Guide documentation.

Get a webhook configuration for a repository

Returns the webhook configuration for a repository. To get more information about the webhook, including the active state and events, use "Get a repository webhook."

Access tokens must have the read:repo_hook or repo scope, and GitHub Apps must have the repository_hooks:read permission.

octokit.repos.getWebhookConfigForRepo({
owner,
repo,
hook_id,
});

Parameters

namerequireddescription
owneryes
repoyes
hook_idyes

See also: GitHub Developer Guide documentation.

List branches

octokit.repos.listBranches({
owner,
repo,
});

Parameters

namerequireddescription
owneryes
repoyes
protectedno

Setting to true returns only protected branches. When set to false, only unprotected branches are returned. Omitting this parameter returns all branches.

per_pageno

Results per page (max 100)

pageno

Page number of the results to fetch.

See also: GitHub Developer Guide documentation.

List branches for HEAD commit

Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see GitHub's products in the GitHub Help documentation.

Returns all branches where the given commit SHA is the HEAD, or latest commit for the branch.

octokit.repos.listBranchesForHeadCommit({
owner,
repo,
commit_sha,
});

Parameters

namerequireddescription
owneryes
repoyes
commit_shayes

commit_sha parameter

See also: GitHub Developer Guide documentation.

List repository collaborators

For organization-owned repositories, the list of collaborators includes outside collaborators, organization members that are direct collaborators, organization members with access through team memberships, organization members with access through default organization permissions, and organization owners.

Team members will include the members of child teams.

octokit.repos.listCollaborators({
owner,
repo,
});

Parameters

namerequireddescription
owneryes
repoyes
affiliationno

Filter collaborators returned by their affiliation. Can be one of:
* outside: All outside collaborators of an organization-owned repository.
* direct: All collaborators with permissions to an organization-owned repository, regardless of organization membership status.
* all: All collaborators the authenticated user can see.

per_pageno

Results per page (max 100)

pageno

Page number of the results to fetch.

See also: GitHub Developer Guide documentation.

List commit comments

Use the :commit_sha to specify the commit that will have its comments listed.

octokit.repos.listCommentsForCommit({
owner,
repo,
commit_sha,
});

Parameters

namerequireddescription
owneryes
repoyes
commit_shayes

commit_sha parameter

per_pageno

Results per page (max 100)

pageno

Page number of the results to fetch.

See also: GitHub Developer Guide documentation.

List commit comments for a repository

Commit Comments use these custom media types. You can read more about the use of media types in the API here.

Comments are ordered by ascending ID.

octokit.repos.listCommitCommentsForRepo({
owner,
repo,
});

Parameters

namerequireddescription
owneryes
repoyes
per_pageno

Results per page (max 100)

pageno

Page number of the results to fetch.

See also: GitHub Developer Guide documentation.

List commits

Signature verification object

The response will include a verification object that describes the result of verifying the commit's signature. The following fields are included in the verification object:

NameTypeDescription
verifiedbooleanIndicates whether GitHub considers the signature in this commit to be verified.
reasonstringThe reason for verified value. Possible values and their meanings are enumerated in table below.
signaturestringThe signature that was extracted from the commit.
payloadstringThe value that was signed.

These are the possible values for reason in the verification object:

ValueDescription
expired_keyThe key that made the signature is expired.
not_signing_keyThe "signing" flag is not among the usage flags in the GPG key that made the signature.
gpgverify_errorThere was an error communicating with the signature verification service.
gpgverify_unavailableThe signature verification service is currently unavailable.
unsignedThe object does not include a signature.
unknown_signature_typeA non-PGP signature was found in the commit.
no_userNo user was associated with the committer email address in the commit.
unverified_emailThe committer email address in the commit was associated with a user, but the email address is not verified on her/his account.
bad_emailThe committer email address in the commit is not included in the identities of the PGP key that made the signature.
unknown_keyThe key that made the signature has not been registered with any user's account.
malformed_signatureThere was an error parsing the signature.
invalidThe signature could not be cryptographically verified using the key whose key-id was found in the signature.
validNone of the above errors applied, so the signature is considered to be verified.
octokit.repos.listCommits({
owner,
repo,
});

Parameters

namerequireddescription
owneryes
repoyes
shano

SHA or branch to start listing commits from. Default: the repository’s default branch (usually master).

pathno

Only commits containing this file path will be returned.

authorno

GitHub login or email address by which to filter by commit author.

sinceno

Only show notifications updated after the given time. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.

untilno

Only commits before this date will be returned. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.

per_pageno

Results per page (max 100)

pageno

Page number of the results to fetch.

See also: GitHub Developer Guide documentation.

List commit statuses for a reference

Users with pull access in a repository can view commit statuses for a given ref. The ref can be a SHA, a branch name, or a tag name. Statuses are returned in reverse chronological order. The first status in the list will be the latest one.

This resource is also available via a legacy route: GET /repos/:owner/:repo/statuses/:ref.

octokit.repos.listCommitStatusesForRef({
owner,
repo,
ref,
});

Parameters

namerequireddescription
owneryes
repoyes
refyes

ref+ parameter

per_pageno

Results per page (max 100)

pageno

Page number of the results to fetch.

See also: GitHub Developer Guide documentation.

List repository contributors

Lists contributors to the specified repository and sorts them by the number of commits per contributor in descending order. This endpoint may return information that is a few hours old because the GitHub REST API v3 caches contributor data to improve performance.

GitHub identifies contributors by author email address. This endpoint groups contribution counts by GitHub user, which includes all associated email addresses. To improve performance, only the first 500 author email addresses in the repository link to GitHub users. The rest will appear as anonymous contributors without associated GitHub user information.

octokit.repos.listContributors({
owner,
repo,
});

Parameters

namerequireddescription
owneryes
repoyes
anonno

Set to 1 or true to include anonymous contributors in results.

per_pageno

Results per page (max 100)

pageno

Page number of the results to fetch.

See also: GitHub Developer Guide documentation.

List deploy keys

octokit.repos.listDeployKeys({
owner,
repo,
});

Parameters

namerequireddescription
owneryes
repoyes
per_pageno

Results per page (max 100)

pageno

Page number of the results to fetch.

See also: GitHub Developer Guide documentation.

List deployments

Simple filtering of deployments is available via query parameters:

octokit.repos.listDeployments({
owner,
repo,
});

Parameters

namerequireddescription
owneryes
repoyes
shano

The SHA recorded at creation time.

refno

The name of the ref. This can be a branch, tag, or SHA.

taskno

The name of the task for the deployment (e.g., deploy or deploy:migrations).

environmentno

The name of the environment that was deployed to (e.g., staging or production).

per_pageno

Results per page (max 100)

pageno

Page number of the results to fetch.

See also: GitHub Developer Guide documentation.

List deployment statuses

Users with pull access can view deployment statuses for a deployment:

octokit.repos.listDeploymentStatuses({
owner,
repo,
deployment_id,
});

Parameters

namerequireddescription
owneryes
repoyes
deployment_idyes

deployment_id parameter

per_pageno

Results per page (max 100)

pageno

Page number of the results to fetch.

See also: GitHub Developer Guide documentation.

List repositories for the authenticated user

Lists repositories that the authenticated user has explicit permission (:read, :write, or :admin) to access.

The authenticated user has explicit permission to access repositories they own, repositories where they are a collaborator, and repositories that they can access through an organization membership.

octokit.repos.listForAuthenticatedUser();

Parameters

namerequireddescription
visibilityno

Can be one of all, public, or private.

affiliationno

Comma-separated list of values. Can include:
* owner: Repositories that are owned by the authenticated user.
* collaborator: Repositories that the user has been added to as a collaborator.
* organization_member: Repositories that the user has access to through being a member of an organization. This includes every repository on every team that the user is on.

typeno

Can be one of all, owner, public, private, member. Default: all

Will cause a 422 error if used in the same request as visibility or affiliation. Will cause a 422 error if used in the same request as visibility or affiliation.

sortno

Can be one of created, updated, pushed, full_name.

directionno

Can be one of asc or desc. Default: asc when using full_name, otherwise desc

per_pageno

Results per page (max 100)

pageno

Page number of the results to fetch.

sinceno

Only show notifications updated after the given time. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.

beforeno

Only show notifications updated before the given time. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.

See also: GitHub Developer Guide documentation.

List forks

octokit.repos.listForks({
owner,
repo,
});

Parameters

namerequireddescription
owneryes
repoyes
sortno

The sort order. Can be either newest, oldest, or stargazers.

per_pageno

Results per page (max 100)

pageno

Page number of the results to fetch.

See also: GitHub Developer Guide documentation.

List organization repositories

Lists repositories for the specified organization.

octokit.repos.listForOrg({
org,
});

Parameters

namerequireddescription
orgyes
typeno

Specifies the types of repositories you want returned. Can be one of all, public, private, forks, sources, member, internal. Default: all. If your organization is associated with an enterprise account using GitHub Enterprise Cloud or GitHub Enterprise Server 2.20+, type can also be internal.

sortno

Can be one of created, updated, pushed, full_name.

directionno

Can be one of asc or desc. Default: when using full_name: asc, otherwise desc

per_pageno

Results per page (max 100)

pageno

Page number of the results to fetch.

See also: GitHub Developer Guide documentation.

List repositories for a user

Lists public repositories for the specified user.

octokit.repos.listForUser({
username,
});

Parameters

namerequireddescription
usernameyes
typeno

Can be one of all, owner, member.

sortno

Can be one of created, updated, pushed, full_name.

directionno

Can be one of asc or desc. Default: asc when using full_name, otherwise desc

per_pageno

Results per page (max 100)

pageno

Page number of the results to fetch.

See also: GitHub Developer Guide documentation.

List repository invitations

When authenticating as a user with admin rights to a repository, this endpoint will list all currently open repository invitations.

octokit.repos.listInvitations({
owner,
repo,
});

Parameters

namerequireddescription
owneryes
repoyes
per_pageno

Results per page (max 100)

pageno

Page number of the results to fetch.

See also: GitHub Developer Guide documentation.

List repository invitations for the authenticated user

When authenticating as a user, this endpoint will list all currently open repository invitations for that user.

octokit.repos.listInvitationsForAuthenticatedUser();

Parameters

namerequireddescription
per_pageno

Results per page (max 100)

pageno

Page number of the results to fetch.

See also: GitHub Developer Guide documentation.

List repository languages

Lists languages for the specified repository. The value shown for each language is the number of bytes of code written in that language.

octokit.repos.listLanguages({
owner,
repo,
});

Parameters

namerequireddescription
owneryes
repoyes

See also: GitHub Developer Guide documentation.

List GitHub Pages builds

octokit.repos.listPagesBuilds({
owner,
repo,
});

Parameters

namerequireddescription
owneryes
repoyes
per_pageno

Results per page (max 100)

pageno

Page number of the results to fetch.

See also: GitHub Developer Guide documentation.

List public repositories

Lists all public repositories in the order that they were created.

Note: Pagination is powered exclusively by the since parameter. Use the Link header to get the URL for the next page of repositories.

octokit.repos.listPublic();

Parameters

namerequireddescription
sinceno

A repository ID. Only return repositories with an ID greater than this ID.

See also: GitHub Developer Guide documentation.

List pull requests associated with a commit

Lists all pull requests containing the provided commit SHA, which can be from any point in the commit history. The results will include open and closed pull requests. Additional preview headers may be required to see certain details for associated pull requests, such as whether a pull request is in a draft state. For more information about previews that might affect this endpoint, see the List pull requests endpoint.

octokit.repos.listPullRequestsAssociatedWithCommit({
owner,
repo,
commit_sha,
});

Parameters

namerequireddescription
owneryes
repoyes
commit_shayes

commit_sha parameter

per_pageno

Results per page (max 100)

pageno

Page number of the results to fetch.

See also: GitHub Developer Guide documentation.

List release assets

octokit.repos.listReleaseAssets({
owner,
repo,
release_id,
});

Parameters

namerequireddescription
owneryes
repoyes
release_idyes

release_id parameter

per_pageno

Results per page (max 100)

pageno

Page number of the results to fetch.

See also: GitHub Developer Guide documentation.

List releases

This returns a list of releases, which does not include regular Git tags that have not been associated with a release. To get a list of Git tags, use the Repository Tags API.

Information about published releases are available to everyone. Only users with push access will receive listings for draft releases.

octokit.repos.listReleases({
owner,
repo,
});

Parameters

namerequireddescription
owneryes
repoyes
per_pageno

Results per page (max 100)

pageno

Page number of the results to fetch.

See also: GitHub Developer Guide documentation.

List repository tags

octokit.repos.listTags({
owner,
repo,
});

Parameters

namerequireddescription
owneryes
repoyes
per_pageno

Results per page (max 100)

pageno

Page number of the results to fetch.

See also: GitHub Developer Guide documentation.

List repository teams

octokit.repos.listTeams({
owner,
repo,
});

Parameters

namerequireddescription
owneryes
repoyes
per_pageno

Results per page (max 100)

pageno

Page number of the results to fetch.

See also: GitHub Developer Guide documentation.

List repository webhooks

octokit.repos.listWebhooks({
owner,
repo,
});

Parameters

namerequireddescription
owneryes
repoyes
per_pageno

Results per page (max 100)

pageno

Page number of the results to fetch.

See also: GitHub Developer Guide documentation.

Merge a branch

octokit.repos.merge({
owner,
repo,
base,
head,
});

Parameters

namerequireddescription
owneryes
repoyes
baseyes

The name of the base branch that the head will be merged into.

headyes

The head to merge. This can be a branch name or a commit SHA1.

commit_messageno

Commit message to use for the merge commit. If omitted, a default message will be used.

See also: GitHub Developer Guide documentation.

Ping a repository webhook

This will trigger a ping event to be sent to the hook.

octokit.repos.pingWebhook({
owner,
repo,
hook_id,
});

Parameters

namerequireddescription
owneryes
repoyes
hook_idyes

See also: GitHub Developer Guide documentation.

Remove app access restrictions

Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see GitHub's products in the GitHub Help documentation.

Removes the ability of an app to push to this branch. Only installed GitHub Apps with write access to the contents permission can be added as authorized actors on a protected branch.

TypeDescription
arrayThe GitHub Apps that have push access to this branch. Use the app's slug. Note: The list of users, apps, and teams in total is limited to 100 items.
octokit.repos.removeAppAccessRestrictions({
owner,
repo,
branch,
apps,
});

Parameters

namerequireddescription
owneryes
repoyes
branchyes

The name of the branch.

appsyes

See also: GitHub Developer Guide documentation.

Remove a repository collaborator

octokit.repos.removeCollaborator({
owner,
repo,
username,
});

Parameters

namerequireddescription
owneryes
repoyes
usernameyes

See also: GitHub Developer Guide documentation.

Remove status check contexts

Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see GitHub's products in the GitHub Help documentation.

octokit.repos.removeStatusCheckContexts({
owner,
repo,
branch,
contexts,
});

Parameters

namerequireddescription
owneryes
repoyes
branchyes

The name of the branch.

contextsyes

See also: GitHub Developer Guide documentation.

Remove status check protection

Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see GitHub's products in the GitHub Help documentation.

octokit.repos.removeStatusCheckProtection({
owner,
repo,
branch,
});

Parameters

namerequireddescription
owneryes
repoyes
branchyes

The name of the branch.

See also: GitHub Developer Guide documentation.

Remove team access restrictions

Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see GitHub's products in the GitHub Help documentation.

Removes the ability of a team to push to this branch. You can also remove push access for child teams.

TypeDescription
arrayTeams that should no longer have push access. Use the team's slug. Note: The list of users, apps, and teams in total is limited to 100 items.
octokit.repos.removeTeamAccessRestrictions({
owner,
repo,
branch,
teams,
});

Parameters

namerequireddescription
owneryes
repoyes
branchyes

The name of the branch.

teamsyes

See also: GitHub Developer Guide documentation.

Remove user access restrictions

Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see GitHub's products in the GitHub Help documentation.

Removes the ability of a user to push to this branch.

TypeDescription
arrayUsernames of the people who should no longer have push access. Note: The list of users, apps, and teams in total is limited to 100 items.
octokit.repos.removeUserAccessRestrictions({
owner,
repo,
branch,
users,
});

Parameters

namerequireddescription
owneryes
repoyes
branchyes

The name of the branch.

usersyes

See also: GitHub Developer Guide documentation.

Rename a branch

Renames a branch in a repository.

Note: Although the API responds immediately, the branch rename process might take some extra time to complete in the background. You won't be able to push to the old branch name while the rename process is in progress. For more information, see "Renaming a branch".

The permissions required to use this endpoint depends on whether you are renaming the default branch.

To rename a non-default branch:

  • Users must have push access.
  • GitHub Apps must have the contents:write repository permission.

To rename the default branch:

  • Users must have admin or owner permissions.
  • GitHub Apps must have the administration:write repository permission.
octokit.repos.renameBranch({
owner,
repo,
branch,
new_name,
});

Parameters

namerequireddescription
owneryes
repoyes
branchyes

The name of the branch.

new_nameyes

The new name of the branch.

See also: GitHub Developer Guide documentation.

Replace all repository topics

octokit.repos.replaceAllTopics({
owner,
repo,
names,
});

Parameters

namerequireddescription
owneryes
repoyes
namesyes

An array of topics to add to the repository. Pass one or more topics to replace the set of existing topics. Send an empty array ([]) to clear all topics from the repository. Note: Topic names cannot contain uppercase letters.

See also: GitHub Developer Guide documentation.

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.

octokit.repos.requestPagesBuild({
owner,
repo,
});

Parameters

namerequireddescription
owneryes
repoyes

See also: GitHub Developer Guide documentation.

Set admin branch protection

Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see GitHub's products in the GitHub Help documentation.

Adding admin enforcement requires admin or owner permissions to the repository and branch protection to be enabled.

octokit.repos.setAdminBranchProtection({
owner,
repo,
branch,
});

Parameters

namerequireddescription
owneryes
repoyes
branchyes

The name of the branch.

See also: GitHub Developer Guide documentation.

Set app access restrictions

Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see GitHub's products in the GitHub Help documentation.

Replaces the list of apps that have push access to this branch. This removes all apps that previously had push access and grants push access to the new list of apps. Only installed GitHub Apps with write access to the contents permission can be added as authorized actors on a protected branch.

TypeDescription
arrayThe GitHub Apps that have push access to this branch. Use the app's slug. Note: The list of users, apps, and teams in total is limited to 100 items.
octokit.repos.setAppAccessRestrictions({
owner,
repo,
branch,
apps,
});

Parameters

namerequireddescription
owneryes
repoyes
branchyes

The name of the branch.

appsyes

See also: GitHub Developer Guide documentation.

Set status check contexts

Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see GitHub's products in the GitHub Help documentation.

octokit.repos.setStatusCheckContexts({
owner,
repo,
branch,
contexts,
});

Parameters

namerequireddescription
owneryes
repoyes
branchyes

The name of the branch.

contextsyes

See also: GitHub Developer Guide documentation.

Set team access restrictions

Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see GitHub's products in the GitHub Help documentation.

Replaces the list of teams that have push access to this branch. This removes all teams that previously had push access and grants push access to the new list of teams. Team restrictions include child teams.

TypeDescription
arrayThe teams that can have push access. Use the team's slug. Note: The list of users, apps, and teams in total is limited to 100 items.
octokit.repos.setTeamAccessRestrictions({
owner,
repo,
branch,
teams,
});

Parameters

namerequireddescription
owneryes
repoyes
branchyes

The name of the branch.

teamsyes

See also: GitHub Developer Guide documentation.

Set user access restrictions

Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see GitHub's products in the GitHub Help documentation.

Replaces the list of people that have push access to this branch. This removes all people that previously had push access and grants push access to the new list of people.

TypeDescription
arrayUsernames for people who can have push access. Note: The list of users, apps, and teams in total is limited to 100 items.
octokit.repos.setUserAccessRestrictions({
owner,
repo,
branch,
users,
});

Parameters

namerequireddescription
owneryes
repoyes
branchyes

The name of the branch.

usersyes

See also: GitHub Developer Guide documentation.

Test the push repository webhook

This will trigger the hook with the latest push to the current repository if the hook is subscribed to push events. If the hook is not subscribed to push events, the server will respond with 204 but no test POST will be generated.

Note: Previously /repos/:owner/:repo/hooks/:hook_id/test

octokit.repos.testPushWebhook({
owner,
repo,
hook_id,
});

Parameters

namerequireddescription
owneryes
repoyes
hook_idyes

See also: GitHub Developer Guide documentation.

Transfer a repository

A transfer request will need to be accepted by the new owner when transferring a personal repository to another user. The response will contain the original owner, and the transfer will continue asynchronously. For more details on the requirements to transfer personal and organization-owned repositories, see about repository transfers.

octokit.repos.transfer({
owner,
repo,
new_owner,
});

Parameters

namerequireddescription
owneryes
repoyes
new_owneryes

The username or organization name the repository will be transferred to.

team_idsno

ID of the team or teams to add to the repository. Teams can only be added to organization-owned repositories.

See also: GitHub Developer Guide documentation.

Update a repository

Note: To edit a repository's topics, use the Replace all repository topics endpoint.

octokit.repos.update({
owner,
repo,
});

Parameters

namerequireddescription
owneryes
repoyes
nameno

The name of the repository.

descriptionno

A short description of the repository.

homepageno

A URL with more information about the repository.

privateno

Either true to make the repository private or false to make it public. Default: false.
Note: You will get a 422 error if the organization restricts changing repository visibility to organization owners and a non-owner tries to change the value of private. Note: You will get a 422 error if the organization restricts changing repository visibility to organization owners and a non-owner tries to change the value of private.

visibilityno

Can be public or private. If your organization is associated with an enterprise account using GitHub Enterprise Cloud or GitHub Enterprise Server 2.20+, visibility can also be internal. The visibility parameter overrides the private parameter when you use both along with the nebula-preview preview header.

has_issuesno

Either true to enable issues for this repository or false to disable them.

has_projectsno

Either true to enable projects for this repository or false to disable them. Note: If you're creating a repository in an organization that has disabled repository projects, the default is false, and if you pass true, the API returns an error.

has_wikino

Either true to enable the wiki for this repository or false to disable it.

is_templateno

Either true to make this repo available as a template repository or false to prevent it.

default_branchno

Updates the default branch for this repository.

allow_squash_mergeno

Either true to allow squash-merging pull requests, or false to prevent squash-merging.

allow_merge_commitno

Either true to allow merging pull requests with a merge commit, or false to prevent merging pull requests with merge commits.

allow_rebase_mergeno

Either true to allow rebase-merging pull requests, or false to prevent rebase-merging.

delete_branch_on_mergeno

Either true to allow automatically deleting head branches when pull requests are merged, or false to prevent automatic deletion.

archivedno

true to archive this repository. Note: You cannot unarchive repositories through the API.

See also: GitHub Developer Guide documentation.

Update branch protection

Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see GitHub's products in the GitHub Help documentation.

Protecting a branch requires admin or owner permissions to the repository.

Note: Passing new arrays of users and teams replaces their previous values.

Note: The list of users, apps, and teams in total is limited to 100 items.

octokit.repos.updateBranchProtection({
owner,
repo,
branch,
required_status_checks,
required_status_checks.strict,
required_status_checks.contexts,
enforce_admins,
required_pull_request_reviews,
restrictions,
restrictions.users,
restrictions.teams
})

Parameters

namerequireddescription
owneryes
repoyes
branchyes

The name of the branch.

required_status_checksyes

Require status checks to pass before merging. Set to null to disable.

required_status_checks.strictyes

Require branches to be up to date before merging.

required_status_checks.contextsyes

The list of status checks to require in order to merge into this branch

enforce_adminsyes

Enforce all configured restrictions for administrators. Set to true to enforce required status checks for repository administrators. Set to null to disable.

required_pull_request_reviewsyes

Require at least one approving review on a pull request, before merging. Set to null to disable.

required_pull_request_reviews.dismissal_restrictionsno

Specify which users and teams can dismiss pull request reviews. Pass an empty dismissal_restrictions object to disable. User and team dismissal_restrictions are only available for organization-owned repositories. Omit this parameter for personal repositories.

required_pull_request_reviews.dismissal_restrictions.usersno

The list of user logins with dismissal access

required_pull_request_reviews.dismissal_restrictions.teamsno

The list of team slugs with dismissal access

required_pull_request_reviews.dismiss_stale_reviewsno

Set to true if you want to automatically dismiss approving reviews when someone pushes a new commit.

required_pull_request_reviews.require_code_owner_reviewsno

Blocks merging pull requests until code owners review them.

required_pull_request_reviews.required_approving_review_countno

Specify the number of reviewers required to approve pull requests. Use a number between 1 and 6.

restrictionsyes

Restrict who can push to the protected branch. User, app, and team restrictions are only available for organization-owned repositories. Set to null to disable.

restrictions.usersyes

The list of user logins with push access

restrictions.teamsyes

The list of team slugs with push access

restrictions.appsno

The list of app slugs with push access

required_linear_historyno

Enforces a linear commit Git history, which prevents anyone from pushing merge commits to a branch. Set to true to enforce a linear commit history. Set to false to disable a linear commit Git history. Your repository must allow squash merging or rebase merging before you can enable a linear commit history. Default: false. For more information, see "Requiring a linear commit history" in the GitHub Help documentation.

allow_force_pushesno

Permits force pushes to the protected branch by anyone with write access to the repository. Set to true to allow force pushes. Set to false or null to block force pushes. Default: false. For more information, see "Enabling force pushes to a protected branch" in the GitHub Help documentation."

allow_deletionsno

Allows deletion of the protected branch by anyone with write access to the repository. Set to false to prevent deletion of the protected branch. Default: false. For more information, see "Enabling force pushes to a protected branch" in the GitHub Help documentation.

See also: GitHub Developer Guide documentation.

Update a commit comment

octokit.repos.updateCommitComment({
owner,
repo,
comment_id,
body,
});

Parameters

namerequireddescription
owneryes
repoyes
comment_idyes

comment_id parameter

bodyyes

The contents of the comment

See also: GitHub Developer Guide documentation.

Update information about a GitHub Pages site

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

octokit.repos.updateInformationAboutPagesSite({
owner,
repo,
source,
});

Parameters

namerequireddescription
owneryes
repoyes
cnameno

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

publicno

Configures access controls for the GitHub Pages site. If public is set to true, the site is accessible to anyone on the internet. If set to false, the site will only be accessible to users who have at least read access to the repository that published the site. This includes anyone in your Enterprise if the repository is set to internal visibility. This feature is only available to repositories in an organization on an Enterprise plan.

sourceyes

See also: GitHub Developer Guide documentation.

Update a repository invitation

octokit.repos.updateInvitation({
owner,
repo,
invitation_id,
});

Parameters

namerequireddescription
owneryes
repoyes
invitation_idyes

invitation_id parameter

permissionsno

The permissions that the associated user will have on the repository. Valid values are read, write, maintain, triage, and admin.

See also: GitHub Developer Guide documentation.

Update pull request review protection

Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see GitHub's products in the GitHub Help documentation.

Updating pull request review enforcement requires admin or owner permissions to the repository and branch protection to be enabled.

Note: Passing new arrays of users and teams replaces their previous values.

octokit.repos.updatePullRequestReviewProtection({
owner,
repo,
branch,
});

Parameters

namerequireddescription
owneryes
repoyes
branchyes

The name of the branch.

dismissal_restrictionsno

Specify which users and teams can dismiss pull request reviews. Pass an empty dismissal_restrictions object to disable. User and team dismissal_restrictions are only available for organization-owned repositories. Omit this parameter for personal repositories.

dismissal_restrictions.usersno

The list of user logins with dismissal access

dismissal_restrictions.teamsno

The list of team slugs with dismissal access

dismiss_stale_reviewsno

Set to true if you want to automatically dismiss approving reviews when someone pushes a new commit.

require_code_owner_reviewsno

Blocks merging pull requests until code owners have reviewed.

required_approving_review_countno

Specifies the number of reviewers required to approve pull requests. Use a number between 1 and 6.

See also: GitHub Developer Guide documentation.

Update a release

Users with push access to the repository can edit a release.

octokit.repos.updateRelease({
owner,
repo,
release_id,
});

Parameters

namerequireddescription
owneryes
repoyes
release_idyes

release_id parameter

tag_nameno

The name of the tag.

target_commitishno

Specifies the commitish value that determines where the Git tag is created from. Can be any branch or commit SHA. Unused if the Git tag already exists. Default: the repository's default branch (usually master).

nameno

The name of the release.

bodyno

Text describing the contents of the tag.

draftno

true makes the release a draft, and false publishes the release.

prereleaseno

true to identify the release as a prerelease, false to identify the release as a full release.

See also: GitHub Developer Guide documentation.

Update a release asset

Users with push access to the repository can edit a release asset.

octokit.repos.updateReleaseAsset({
owner,
repo,
asset_id,
});

Parameters

namerequireddescription
owneryes
repoyes
asset_idyes

asset_id parameter

nameno

The file name of the asset.

labelno

An alternate short description of the asset. Used in place of the filename.

stateno

See also: GitHub Developer Guide documentation.

Update status check protection

Deprecated: This method has been renamed to repos.updateStatusCheckProtection

Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see GitHub's products in the GitHub Help documentation.

Updating required status checks requires admin or owner permissions to the repository and branch protection to be enabled.

octokit.repos.updateStatusCheckPotection({
owner,
repo,
branch,
});

Parameters

namerequireddescription
owneryes
repoyes
branchyes

The name of the branch.

strictno

Require branches to be up to date before merging.

contextsno

The list of status checks to require in order to merge into this branch

See also: GitHub Developer Guide documentation.

Update status check protection

Protected branches are available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see GitHub's products in the GitHub Help documentation.

Updating required status checks requires admin or owner permissions to the repository and branch protection to be enabled.

octokit.repos.updateStatusCheckProtection({
owner,
repo,
branch,
});

Parameters

namerequireddescription
owneryes
repoyes
branchyes

The name of the branch.

strictno

Require branches to be up to date before merging.

contextsno

The list of status checks to require in order to merge into this branch

See also: GitHub Developer Guide documentation.

Update a repository webhook

Updates a webhook configured in a repository. If you previously had a secret set, you must provide the same secret or set a new secret or the secret will be removed. If you are only updating individual webhook config properties, use "Update a webhook configuration for a repository."

octokit.repos.updateWebhook({
owner,
repo,
hook_id,
config.url
})

Parameters

namerequireddescription
owneryes
repoyes
hook_idyes
configno

Key/value pairs to provide settings for this webhook. These are defined below.

config.urlyes

The URL to which the payloads will be delivered.

config.content_typeno

The media type used to serialize the payloads. Supported values include json and form. The default is form.

config.secretno

If provided, the secret will be used as the key to generate the HMAC hex digest value for delivery signature headers.

config.insecure_sslno

Determines whether the SSL certificate of the host for url will be verified when delivering payloads. Supported values include 0 (verification is performed) and 1 (verification is not performed). The default is 0. We strongly recommend not setting this to 1 as you are subject to man-in-the-middle and other attacks.

config.addressno
config.roomno
eventsno

Determines what events the hook is triggered for. This replaces the entire array of events.

add_eventsno

Determines a list of events to be added to the list of events that the Hook triggers for.

remove_eventsno

Determines a list of events to be removed from the list of events that the Hook triggers for.

activeno

Determines if notifications are sent when the webhook is triggered. Set to true to send notifications.

See also: GitHub Developer Guide documentation.

Update a webhook configuration for a repository

Updates the webhook configuration for a repository. To update more information about the webhook, including the active state and events, use "Update a repository webhook."

Access tokens must have the write:repo_hook or repo scope, and GitHub Apps must have the repository_hooks:write permission.

octokit.repos.updateWebhookConfigForRepo({
owner,
repo,
hook_id,
});

Parameters

namerequireddescription
owneryes
repoyes
hook_idyes
urlno

The URL to which the payloads will be delivered.

content_typeno

The media type used to serialize the payloads. Supported values include json and form. The default is form.

secretno

If provided, the secret will be used as the key to generate the HMAC hex digest value for delivery signature headers.

insecure_sslno

Determines whether the SSL certificate of the host for url will be verified when delivering payloads. Supported values include 0 (verification is performed) and 1 (verification is not performed). The default is 0. We strongly recommend not setting this to 1 as you are subject to man-in-the-middle and other attacks.

See also: GitHub Developer Guide documentation.

Upload a release asset

This endpoint makes use of a Hypermedia relation to determine which URL to access. The endpoint you call to upload release assets is specific to your release. Use the upload_url returned in the response of the Create a release endpoint to upload a release asset.

You need to use an HTTP client which supports SNI to make calls to this endpoint.

Most libraries will set the required Content-Length header automatically. Use the required Content-Type header to provide the media type of the asset. For a list of media types, see Media Types. For example:

application/zip

GitHub expects the asset data in its raw binary form, rather than JSON. You will send the raw binary content of the asset as the request body. Everything else about the endpoint is the same as the rest of the API. For example, you'll still need to pass your authentication to be able to upload an asset.

When an upstream failure occurs, you will receive a 502 Bad Gateway status. This may leave an empty asset with a state of starter. It can be safely deleted.

Notes:

  • GitHub renames asset filenames that have special characters, non-alphanumeric characters, and leading or trailing periods. The "List assets for a release" endpoint lists the renamed filenames. For more information and help, contact GitHub Support.
  • If you upload an asset with the same filename as another uploaded asset, you'll receive an error and must delete the old file before you can re-upload the new asset.
octokit.repos.uploadReleaseAsset({
owner,
repo,
release_id,
data,
});

Parameters

namerequireddescription
owneryes
repoyes
release_idyes

release_id parameter

nameno
labelno
datayes

The raw file data

originno

The URL origin (protocol + host name + port) is included in upload_url returned in the response of the "Create a release" endpoint

See also: GitHub Developer Guide documentation.