← All tags

Repos API Reference

Interact with GitHub Repos.

203 endpoints tagged repos, each listing its parameters and possible responses. Search or scroll the index below to jump to a specific endpoint.

No endpoints match your search.

List organization repositories

GET /orgs/{org}/repos

Lists repositories for the specified organization.

Parameters

NameInRequiredDescription
orgpathyesThe organization name. The name is not case sensitive.
typequerynoSpecifies the types of repositories you want returned.
sortquerynoThe property to sort the results by.
directionquerynoThe order to sort by. Default: asc when using full_name, otherwise desc.
per_pagequerynoThe number of results per page (max 100). For more information, see "Using pagination in the REST API."
pagequerynoThe page number of the results to fetch. For more information, see "Using pagination in the REST API."

Responses

StatusDescriptionHas JSON body
200Responseyes

Create an organization repository

POST /orgs/{org}/repos

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

Parameters

NameInRequiredDescription
orgpathyesThe organization name. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
201Responseyes
403Forbiddenyes
422Validation failed, or the endpoint has been spammed.yes

Get all organization repository rulesets

GET /orgs/{org}/rulesets

Get all the repository rulesets for an organization.

Parameters

NameInRequiredDescription
orgpathyesThe organization name. The name is not case sensitive.
per_pagequerynoThe number of results per page (max 100). For more information, see "Using pagination in the REST API."
pagequerynoThe page number of the results to fetch. For more information, see "Using pagination in the REST API."
targetsquerynoA comma-separated list of rule targets to filter by.

Responses

StatusDescriptionHas JSON body
200Responseyes
404Resource not foundyes
500Internal Erroryes

Create an organization repository ruleset

POST /orgs/{org}/rulesets

Create a repository ruleset for an organization.

Parameters

NameInRequiredDescription
orgpathyesThe organization name. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
201Responseyes
404Resource not foundyes
422Validation failed, or the endpoint has been spammed.yes
500Internal Erroryes

List organization rule suites

GET /orgs/{org}/rulesets/rule-suites

Lists suites of rule evaluations at the organization level.

Parameters

NameInRequiredDescription
orgpathyesThe organization name. The name is not case sensitive.
refquerynoThe name of the ref. Cannot contain wildcard characters. Optionally prefix with refs/heads/ to limit to branches or refs/tags/ to limit to tags. Omit the prefix to search across all refs. When specified, only rule evaluations triggered for this ref will be returned.
repository_namequerynoThe name of the repository to filter on.
time_periodquerynoThe time period to filter by.
actor_namequerynoThe handle for the GitHub user account to filter on. When specified, only rule evaluations triggered by this actor will be returned.
rule_suite_resultquerynoThe rule suite results to filter on. When specified, only suites with this result will be returned.
evaluate_statusquerynoThe evaluate status to filter on. When specified, only rule suites resulting from rulesets with the specified evaluate status will be returned.
per_pagequerynoThe number of results per page (max 100). For more information, see "Using pagination in the REST API."
pagequerynoThe page number of the results to fetch. For more information, see "Using pagination in the REST API."

Responses

StatusDescriptionHas JSON body
200Responseyes
404Resource not foundyes
500Internal Erroryes

Get an organization rule suite

GET /orgs/{org}/rulesets/rule-suites/{rule_suite_id}

Gets information about a suite of rule evaluations from within an organization.

Parameters

NameInRequiredDescription
orgpathyesThe organization name. The name is not case sensitive.
rule_suite_idpathyesThe unique identifier of the rule suite result.

Responses

StatusDescriptionHas JSON body
200Responseyes
404Resource not foundyes
500Internal Erroryes

Get an organization repository ruleset

GET /orgs/{org}/rulesets/{ruleset_id}

Get a repository ruleset for an organization.

Parameters

NameInRequiredDescription
orgpathyesThe organization name. The name is not case sensitive.
ruleset_idpathyesThe ID of the ruleset.

Responses

StatusDescriptionHas JSON body
200Responseyes
404Resource not foundyes
500Internal Erroryes

Update an organization repository ruleset

PUT /orgs/{org}/rulesets/{ruleset_id}

Update a ruleset for an organization.

Parameters

NameInRequiredDescription
orgpathyesThe organization name. The name is not case sensitive.
ruleset_idpathyesThe ID of the ruleset.

Responses

StatusDescriptionHas JSON body
200Responseyes
404Resource not foundyes
422Validation failed, or the endpoint has been spammed.yes
500Internal Erroryes

Delete an organization repository ruleset

DELETE /orgs/{org}/rulesets/{ruleset_id}

Delete a ruleset for an organization.

Parameters

NameInRequiredDescription
orgpathyesThe organization name. The name is not case sensitive.
ruleset_idpathyesThe ID of the ruleset.

Responses

StatusDescriptionHas JSON body
204Responseno
404Resource not foundyes
500Internal Erroryes

Get a repository

GET /repos/{owner}/{repo}

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.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
200Responseyes
403Forbiddenyes
404Resource not foundyes
301Moved permanentlyyes

Update a repository

PATCH /repos/{owner}/{repo}

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

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
200Responseyes
307Temporary Redirectyes
403Forbiddenyes
422Validation failed, or the endpoint has been spammed.yes
404Resource not foundyes

Delete a repository

DELETE /repos/{owner}/{repo}

Deleting a repository requires admin access.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
204Responseno
403If an organization owner has configured the organization to prevent members from deleting organization-owned repositories, a member will get this response:yes
307Temporary Redirectyes
404Resource not foundyes
409Conflictyes

List repository activities

GET /repos/{owner}/{repo}/activity

Lists a detailed history of changes to a repository, such as pushes, merges, force pushes, and branch changes, and associates these changes with commits and users.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
directionquerynoThe direction to sort the results by.
per_pagequerynoThe number of results per page (max 100). For more information, see "Using pagination in the REST API."
beforequerynoA cursor, as given in the Link header. If specified, the query only searches for results before this cursor. For more information, see "Using pagination in the REST API."
afterquerynoA cursor, as given in the Link header. If specified, the query only searches for results after this cursor. For more information, see "Using pagination in the REST API."
refquerynoThe Git reference for the activities you want to list.
actorquerynoThe GitHub username to use to filter by the actor who performed the activity.
time_periodquerynoThe time period to filter by.
activity_typequerynoThe activity type to filter by.

Responses

StatusDescriptionHas JSON body
200Responseyes
422Validation failed, or the endpoint has been spammed.yes

Create an attestation

POST /repos/{owner}/{repo}/attestations

Store an artifact attestation and associate it with a repository.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
201responseyes
403Forbiddenyes
422Validation failed, or the endpoint has been spammed.yes

List attestations

GET /repos/{owner}/{repo}/attestations/{subject_digest}

List a collection of artifact attestations with a given subject digest that are associated with a repository.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
per_pagequerynoThe number of results per page (max 100). For more information, see "Using pagination in the REST API."
beforequerynoA cursor, as given in the Link header. If specified, the query only searches for results before this cursor. For more information, see "Using pagination in the REST API."
afterquerynoA cursor, as given in the Link header. If specified, the query only searches for results after this cursor. For more information, see "Using pagination in the REST API."
subject_digestpathyesThe parameter should be set to the attestation's subject's SHA256 digest, in the form sha256:HEX_DIGEST.
predicate_typequerynoOptional filter for fetching attestations with a given predicate type.

Responses

StatusDescriptionHas JSON body
200Responseyes

Create an autolink reference for a repository

POST /repos/{owner}/{repo}/autolinks

Users with admin access to the repository can create an autolink.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
201responseyes
422Validation failed, or the endpoint has been spammed.yes

Check if Dependabot security updates are enabled for a repository

GET /repos/{owner}/{repo}/automated-security-fixes

Shows whether Dependabot security updates are enabled, disabled or paused for a repository. The authenticated user must have admin read access to the repository. For more information, see "Configuring Dependabot security updates".

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
200Response if Dependabot is enabledyes
404Not Found if Dependabot is not enabled for the repositoryno

Enable Dependabot security updates

PUT /repos/{owner}/{repo}/automated-security-fixes

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

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
204Responseno

Disable Dependabot security updates

DELETE /repos/{owner}/{repo}/automated-security-fixes

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

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
204Responseno

List branches

GET /repos/{owner}/{repo}/branches

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
protectedquerynoSetting to true returns only branches protected by branch protections or rulesets. When set to false, only unprotected branches are returned. Omitting this parameter returns all branches.
per_pagequerynoThe number of results per page (max 100). For more information, see "Using pagination in the REST API."
pagequerynoThe page number of the results to fetch. For more information, see "Using pagination in the REST API."

Responses

StatusDescriptionHas JSON body
200Responseyes
404Resource not foundyes

Get a branch

GET /repos/{owner}/{repo}/branches/{branch}

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
branchpathyesThe name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.

Responses

StatusDescriptionHas JSON body
200Responseyes
301Moved permanentlyyes
404Resource not foundyes

Get branch protection

GET /repos/{owner}/{repo}/branches/{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.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
branchpathyesThe name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.

Responses

StatusDescriptionHas JSON body
200Responseyes
404Resource not foundyes

Update branch protection

PUT /repos/{owner}/{repo}/branches/{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.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
branchpathyesThe name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.

Responses

StatusDescriptionHas JSON body
200Responseyes
403Forbiddenyes
422Validation failed, or the endpoint has been spammed.yes
404Resource not foundyes

Delete branch protection

DELETE /repos/{owner}/{repo}/branches/{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.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
branchpathyesThe name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.

Responses

StatusDescriptionHas JSON body
204Responseno
403Forbiddenyes

Get admin branch protection

GET /repos/{owner}/{repo}/branches/{branch}/protection/enforce_admins

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.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
branchpathyesThe name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.

Responses

StatusDescriptionHas JSON body
200Responseyes

Set admin branch protection

POST /repos/{owner}/{repo}/branches/{branch}/protection/enforce_admins

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.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
branchpathyesThe name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.

Responses

StatusDescriptionHas JSON body
200Responseyes

Delete admin branch protection

DELETE /repos/{owner}/{repo}/branches/{branch}/protection/enforce_admins

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.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
branchpathyesThe name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.

Responses

StatusDescriptionHas JSON body
204Responseno
404Resource not foundyes

Get pull request review protection

GET /repos/{owner}/{repo}/branches/{branch}/protection/required_pull_request_reviews

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.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
branchpathyesThe name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.

Responses

StatusDescriptionHas JSON body
200Responseyes

Update pull request review protection

PATCH /repos/{owner}/{repo}/branches/{branch}/protection/required_pull_request_reviews

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.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
branchpathyesThe name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.

Responses

StatusDescriptionHas JSON body
200Responseyes
422Validation failed, or the endpoint has been spammed.yes

Delete pull request review protection

DELETE /repos/{owner}/{repo}/branches/{branch}/protection/required_pull_request_reviews

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.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
branchpathyesThe name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.

Responses

StatusDescriptionHas JSON body
204Responseno
404Resource not foundyes

Get commit signature protection

GET /repos/{owner}/{repo}/branches/{branch}/protection/required_signatures

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.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
branchpathyesThe name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.

Responses

StatusDescriptionHas JSON body
200Responseyes
404Resource not foundyes

Create commit signature protection

POST /repos/{owner}/{repo}/branches/{branch}/protection/required_signatures

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.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
branchpathyesThe name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.

Responses

StatusDescriptionHas JSON body
200Responseyes
404Resource not foundyes

Delete commit signature protection

DELETE /repos/{owner}/{repo}/branches/{branch}/protection/required_signatures

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.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
branchpathyesThe name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.

Responses

StatusDescriptionHas JSON body
204Responseno
404Resource not foundyes

Get status checks protection

GET /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks

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.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
branchpathyesThe name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.

Responses

StatusDescriptionHas JSON body
200Responseyes
404Resource not foundyes

Update status check protection

PATCH /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks

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.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
branchpathyesThe name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.

Responses

StatusDescriptionHas JSON body
200Responseyes
404Resource not foundyes
422Validation failed, or the endpoint has been spammed.yes

Remove status check protection

DELETE /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks

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.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
branchpathyesThe name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.

Responses

StatusDescriptionHas JSON body
204Responseno

Get all status check contexts

GET /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/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.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
branchpathyesThe name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.

Responses

StatusDescriptionHas JSON body
200Responseyes
404Resource not foundyes

Add status check contexts

POST /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/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.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
branchpathyesThe name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.

Responses

StatusDescriptionHas JSON body
200Responseyes
422Validation failed, or the endpoint has been spammed.yes
403Forbiddenyes
404Resource not foundyes

Set status check contexts

PUT /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/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.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
branchpathyesThe name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.

Responses

StatusDescriptionHas JSON body
200Responseyes
422Validation failed, or the endpoint has been spammed.yes
404Resource not foundyes

Remove status check contexts

DELETE /repos/{owner}/{repo}/branches/{branch}/protection/required_status_checks/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.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
branchpathyesThe name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.

Responses

StatusDescriptionHas JSON body
200Responseyes
404Resource not foundyes
422Validation failed, or the endpoint has been spammed.yes

Get access restrictions

GET /repos/{owner}/{repo}/branches/{branch}/protection/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.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
branchpathyesThe name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.

Responses

StatusDescriptionHas JSON body
200Responseyes
404Resource not foundyes

Delete access restrictions

DELETE /repos/{owner}/{repo}/branches/{branch}/protection/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.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
branchpathyesThe name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.

Responses

StatusDescriptionHas JSON body
204Responseno

Get apps with access to the protected branch

GET /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/apps

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.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
branchpathyesThe name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.

Responses

StatusDescriptionHas JSON body
200Responseyes
404Resource not foundyes

Add app access restrictions

POST /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/apps

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.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
branchpathyesThe name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.

Responses

StatusDescriptionHas JSON body
200Responseyes
422Validation failed, or the endpoint has been spammed.yes

Set app access restrictions

PUT /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/apps

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.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
branchpathyesThe name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.

Responses

StatusDescriptionHas JSON body
200Responseyes
422Validation failed, or the endpoint has been spammed.yes

Remove app access restrictions

DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/apps

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.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
branchpathyesThe name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.

Responses

StatusDescriptionHas JSON body
200Responseyes
422Validation failed, or the endpoint has been spammed.yes

Get teams with access to the protected branch

GET /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams

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.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
branchpathyesThe name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.

Responses

StatusDescriptionHas JSON body
200Responseyes
404Resource not foundyes

Add team access restrictions

POST /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams

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.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
branchpathyesThe name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.

Responses

StatusDescriptionHas JSON body
200Responseyes
422Validation failed, or the endpoint has been spammed.yes

Set team access restrictions

PUT /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams

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.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
branchpathyesThe name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.

Responses

StatusDescriptionHas JSON body
200Responseyes
422Validation failed, or the endpoint has been spammed.yes

Remove team access restrictions

DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/teams

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.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
branchpathyesThe name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.

Responses

StatusDescriptionHas JSON body
200Responseyes
422Validation failed, or the endpoint has been spammed.yes

Get users with access to the protected branch

GET /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users

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.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
branchpathyesThe name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.

Responses

StatusDescriptionHas JSON body
200Responseyes
404Resource not foundyes

Add user access restrictions

POST /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users

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.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
branchpathyesThe name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.

Responses

StatusDescriptionHas JSON body
200Responseyes
422Validation failed, or the endpoint has been spammed.yes

Set user access restrictions

PUT /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users

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.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
branchpathyesThe name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.

Responses

StatusDescriptionHas JSON body
200Responseyes
422Validation failed, or the endpoint has been spammed.yes

Remove user access restrictions

DELETE /repos/{owner}/{repo}/branches/{branch}/protection/restrictions/users

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.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
branchpathyesThe name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.

Responses

StatusDescriptionHas JSON body
200Responseyes
422Validation failed, or the endpoint has been spammed.yes

Rename a branch

POST /repos/{owner}/{repo}/branches/{branch}/rename

Renames a branch in a repository.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
branchpathyesThe name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.

Responses

StatusDescriptionHas JSON body
201Responseyes
403Forbiddenyes
404Resource not foundyes
422Validation failed, or the endpoint has been spammed.yes

List CODEOWNERS errors

GET /repos/{owner}/{repo}/codeowners/errors

List any syntax errors that are detected in the CODEOWNERS

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
refquerynoA branch, tag or commit name used to determine which version of the CODEOWNERS file to use. Default: the repository's default branch (e.g. main)

Responses

StatusDescriptionHas JSON body
200Responseyes
404Resource not foundno

List repository collaborators

GET /repos/{owner}/{repo}/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.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
affiliationquerynoFilter collaborators returned by their affiliation. outside means all outside collaborators of an organization-owned repository. direct means all collaborators with permissions to an organization-owned repository, regardless of organization membership status. all means all collaborators the authenticated user can see.
permissionquerynoFilter collaborators by the permissions they have on the repository. If not specified, all collaborators will be returned.
per_pagequerynoThe number of results per page (max 100). For more information, see "Using pagination in the REST API."
pagequerynoThe page number of the results to fetch. For more information, see "Using pagination in the REST API."

Responses

StatusDescriptionHas JSON body
200Responseyes
404Resource not foundyes

Check if a user is a repository collaborator

GET /repos/{owner}/{repo}/collaborators/{username}

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.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
usernamepathyesThe handle for the GitHub user account.

Responses

StatusDescriptionHas JSON body
204Response if user is a collaboratorno
404Not Found if user is not a collaboratorno

Add a repository collaborator

PUT /repos/{owner}/{repo}/collaborators/{username}

Add a user to a repository with a specified level of access. If the repository is owned by an organization, this API does not add the user to the organization - a user that has repository access without being an organization member is called an "outside collaborator" (if they are not an Enterprise Managed User) or a "repository collaborator" if they are an Enterprise Managed User. These users are exempt from some organization policies - see "Adding outside collaborators to repositories" to learn more about these collaborator types.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
usernamepathyesThe handle for the GitHub user account.

Responses

StatusDescriptionHas JSON body
201Response when a new invitation is createdyes
204Response when: - an existing collaborator is added as a collaborator - an organization member is added as an individual collaborator - an existing team member (whose team is also a repository collaborator) is added as an individual collaboratorno
422Response when: - validation failed, or the endpoint has been spammed - an Enterprise Managed User (EMU) account was invited to a repository in an enterprise with personal user accountsyes
403Forbiddenyes

Remove a repository collaborator

DELETE /repos/{owner}/{repo}/collaborators/{username}

Removes a collaborator from a repository.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
usernamepathyesThe handle for the GitHub user account.

Responses

StatusDescriptionHas JSON body
204No Content when collaborator was removed from the repository.no
422Validation failed, or the endpoint has been spammed.yes
403Forbiddenyes

Get repository permissions for a user

GET /repos/{owner}/{repo}/collaborators/{username}/permission

Checks the repository permission and role of a collaborator.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
usernamepathyesThe handle for the GitHub user account.

Responses

StatusDescriptionHas JSON body
200if user has admin permissionsyes
404Resource not foundyes

List commit comments for a repository

GET /repos/{owner}/{repo}/comments

Lists the commit comments for a specified repository. Comments are ordered by ascending ID.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
per_pagequerynoThe number of results per page (max 100). For more information, see "Using pagination in the REST API."
pagequerynoThe page number of the results to fetch. For more information, see "Using pagination in the REST API."

Responses

StatusDescriptionHas JSON body
200Responseyes

Get a commit comment

GET /repos/{owner}/{repo}/comments/{comment_id}

Gets a specified commit comment.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
comment_idpathyesThe unique identifier of the comment.

Responses

StatusDescriptionHas JSON body
200Responseyes
404Resource not foundyes

Update a commit comment

PATCH /repos/{owner}/{repo}/comments/{comment_id}

Updates the contents of a specified commit comment.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
comment_idpathyesThe unique identifier of the comment.

Responses

StatusDescriptionHas JSON body
200Responseyes
404Resource not foundyes

Delete a commit comment

DELETE /repos/{owner}/{repo}/comments/{comment_id}

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
comment_idpathyesThe unique identifier of the comment.

Responses

StatusDescriptionHas JSON body
204Responseno
404Resource not foundyes

List commits

GET /repos/{owner}/{repo}/commits

Signature verification object

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
shaquerynoSHA or branch to start listing commits from. Default: the repository’s default branch (usually main).
pathquerynoOnly commits containing this file path will be returned.
authorquerynoGitHub username or email address to use to filter by commit author.
committerquerynoGitHub username or email address to use to filter by commit committer.
sincequerynoOnly show results that were last updated after the given time. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ. Due to limitations of Git, timestamps must be between 1970-01-01 and 2099-12-31 (inclusive) or unexpected results may be returned.
untilquerynoOnly commits before this date will be returned. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ. Due to limitations of Git, timestamps must be between 1970-01-01 and 2099-12-31 (inclusive) or unexpected results may be returned.
per_pagequerynoThe number of results per page (max 100). For more information, see "Using pagination in the REST API."
pagequerynoThe page number of the results to fetch. For more information, see "Using pagination in the REST API."

Responses

StatusDescriptionHas JSON body
200Responseyes
500Internal Erroryes
400Bad Requestyes
404Resource not foundyes
409Conflictyes

List branches for HEAD commit

GET /repos/{owner}/{repo}/commits/{commit_sha}/branches-where-head

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.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
commit_shapathyesThe SHA of the commit.

Responses

StatusDescriptionHas JSON body
200Responseyes
422Validation failed, or the endpoint has been spammed.yes
409Conflictyes

List commit comments

GET /repos/{owner}/{repo}/commits/{commit_sha}/comments

Lists the comments for a specified commit.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
commit_shapathyesThe SHA of the commit.
per_pagequerynoThe number of results per page (max 100). For more information, see "Using pagination in the REST API."
pagequerynoThe page number of the results to fetch. For more information, see "Using pagination in the REST API."

Responses

StatusDescriptionHas JSON body
200Responseyes

Create a commit comment

POST /repos/{owner}/{repo}/commits/{commit_sha}/comments

Create a comment for a commit using its :commit_sha.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
commit_shapathyesThe SHA of the commit.

Responses

StatusDescriptionHas JSON body
201Responseyes
403Forbiddenyes
422Validation failed, or the endpoint has been spammed.yes

List pull requests associated with a commit

GET /repos/{owner}/{repo}/commits/{commit_sha}/pulls

Lists the merged pull request that introduced the commit to the repository. If the commit is not present in the default branch, it will return merged and open pull requests associated with the commit.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
commit_shapathyesThe SHA of the commit.
per_pagequerynoThe number of results per page (max 100). For more information, see "Using pagination in the REST API."
pagequerynoThe page number of the results to fetch. For more information, see "Using pagination in the REST API."

Responses

StatusDescriptionHas JSON body
200Responseyes
409Conflictyes

Get a commit

GET /repos/{owner}/{repo}/commits/{ref}

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

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
pagequerynoThe page number of the results to fetch. For more information, see "Using pagination in the REST API."
per_pagequerynoThe number of results per page (max 100). For more information, see "Using pagination in the REST API."
refpathyesThe commit reference. Can be a commit SHA, branch name (heads/BRANCH_NAME), or tag name (tags/TAG_NAME). For more information, see "Git References" in the Git documentation.

Responses

StatusDescriptionHas JSON body
200Responseyes
422Validation failed, or the endpoint has been spammed.yes
404Resource not foundyes
500Internal Erroryes
503Service unavailableyes
409Conflictyes

Get the combined status for a specific reference

GET /repos/{owner}/{repo}/commits/{ref}/status

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.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
refpathyesThe commit reference. Can be a commit SHA, branch name (heads/BRANCH_NAME), or tag name (tags/TAG_NAME). For more information, see "Git References" in the Git documentation.
per_pagequerynoThe number of results per page (max 100). For more information, see "Using pagination in the REST API."
pagequerynoThe page number of the results to fetch. For more information, see "Using pagination in the REST API."

Responses

StatusDescriptionHas JSON body
200Responseyes
404Resource not foundyes

List commit statuses for a reference

GET /repos/{owner}/{repo}/commits/{ref}/statuses

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.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
refpathyesThe commit reference. Can be a commit SHA, branch name (heads/BRANCH_NAME), or tag name (tags/TAG_NAME). For more information, see "Git References" in the Git documentation.
per_pagequerynoThe number of results per page (max 100). For more information, see "Using pagination in the REST API."
pagequerynoThe page number of the results to fetch. For more information, see "Using pagination in the REST API."

Responses

StatusDescriptionHas JSON body
200Responseyes
301Moved permanentlyyes

Get community profile metrics

GET /repos/{owner}/{repo}/community/profile

Returns all community profile metrics for a repository. The repository cannot be a fork.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
200Responseyes

Compare two commits

GET /repos/{owner}/{repo}/compare/{basehead}

Compares two commits against one another. You can compare refs (branches or tags) and commit SHAs in the same repository, or you can compare refs and commit SHAs that exist in different repositories within the same repository network, including fork branches. For more information about how to view a repository's network, see "Understanding connections between repositories."

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
pagequerynoThe page number of the results to fetch. For more information, see "Using pagination in the REST API."
per_pagequerynoThe number of results per page (max 100). For more information, see "Using pagination in the REST API."
baseheadpathyesThe base branch and head branch to compare. This parameter expects the format BASE...HEAD. Both must be branch names in repo. To compare with a branch that exists in a different repository in the same network as repo, the basehead parameter expects the format USERNAME:BASE...USERNAME:HEAD.

Responses

StatusDescriptionHas JSON body
200Responseyes
404Resource not foundyes
500Internal Erroryes
503Service unavailableyes

Get repository content

GET /repos/{owner}/{repo}/contents/{path}

Gets the contents of a file or directory in a repository. Specify the file path or directory with the path parameter. If you omit the path parameter, you will receive the contents of the repository's root directory.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
pathpathyespath parameter
refquerynoThe name of the commit/branch/tag. Default: the repository’s default branch.

Responses

StatusDescriptionHas JSON body
200Responseyes
404Resource not foundyes
403Forbiddenyes
302Foundno
304Not modifiedno

Create or update file contents

PUT /repos/{owner}/{repo}/contents/{path}

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

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
pathpathyespath parameter

Responses

StatusDescriptionHas JSON body
200Responseyes
201Responseyes
404Resource not foundyes
422Validation failed, or the endpoint has been spammed.yes
409Conflictyes

Delete a file

DELETE /repos/{owner}/{repo}/contents/{path}

Deletes a file in a repository.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
pathpathyespath parameter

Responses

StatusDescriptionHas JSON body
200Responseyes
422Validation failed, or the endpoint has been spammed.yes
404Resource not foundyes
409Conflictyes
503Service unavailableyes

List repository contributors

GET /repos/{owner}/{repo}/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 caches contributor data to improve performance.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
anonquerynoSet to 1 or true to include anonymous contributors in results.
per_pagequerynoThe number of results per page (max 100). For more information, see "Using pagination in the REST API."
pagequerynoThe page number of the results to fetch. For more information, see "Using pagination in the REST API."

Responses

StatusDescriptionHas JSON body
200If repository contains contentyes
204Response if repository is emptyno
403Forbiddenyes
404Resource not foundyes

List deployments

GET /repos/{owner}/{repo}/deployments

Simple filtering of deployments is available via query parameters:

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
shaquerynoThe SHA recorded at creation time.
refquerynoThe name of the ref. This can be a branch, tag, or SHA.
taskquerynoThe name of the task for the deployment (e.g., deploy or deploy:migrations).
environmentquerynoThe name of the environment that was deployed to (e.g., staging or production).
per_pagequerynoThe number of results per page (max 100). For more information, see "Using pagination in the REST API."
pagequerynoThe page number of the results to fetch. For more information, see "Using pagination in the REST API."

Responses

StatusDescriptionHas JSON body
200Responseyes

Create a deployment

POST /repos/{owner}/{repo}/deployments

Deployments offer a few configurable parameters with certain defaults.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
201Responseyes
202Merged branch responseyes
409Conflict when there is a merge conflict or the commit's status checks failedno
422Validation failed, or the endpoint has been spammed.yes

Get a deployment

GET /repos/{owner}/{repo}/deployments/{deployment_id}

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
deployment_idpathyesdeployment_id parameter

Responses

StatusDescriptionHas JSON body
200Responseyes
404Resource not foundyes

Delete a deployment

DELETE /repos/{owner}/{repo}/deployments/{deployment_id}

If the repository only has one deployment, you can delete the deployment regardless of its status. If the repository has more than one deployment, you can only delete inactive deployments. This ensures that repositories with multiple deployments will always have an active deployment.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
deployment_idpathyesdeployment_id parameter

Responses

StatusDescriptionHas JSON body
204Responseno
404Resource not foundyes
422Validation failed, or the endpoint has been spammed.yes

List deployment statuses

GET /repos/{owner}/{repo}/deployments/{deployment_id}/statuses

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

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
deployment_idpathyesdeployment_id parameter
per_pagequerynoThe number of results per page (max 100). For more information, see "Using pagination in the REST API."
pagequerynoThe page number of the results to fetch. For more information, see "Using pagination in the REST API."

Responses

StatusDescriptionHas JSON body
200Responseyes
404Resource not foundyes

Create a deployment status

POST /repos/{owner}/{repo}/deployments/{deployment_id}/statuses

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

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
deployment_idpathyesdeployment_id parameter

Responses

StatusDescriptionHas JSON body
201Responseyes
422Validation failed, or the endpoint has been spammed.yes

Get a deployment status

GET /repos/{owner}/{repo}/deployments/{deployment_id}/statuses/{status_id}

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

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
deployment_idpathyesdeployment_id parameter
status_idpathyes

Responses

StatusDescriptionHas JSON body
200Responseyes
404Resource not foundyes

Create a repository dispatch event

POST /repos/{owner}/{repo}/dispatches

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

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
204Responseno
404Resource not foundyes
422Validation failed, or the endpoint has been spammed.yes

List environments

GET /repos/{owner}/{repo}/environments

Lists the environments for a repository.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
per_pagequerynoThe number of results per page (max 100). For more information, see "Using pagination in the REST API."
pagequerynoThe page number of the results to fetch. For more information, see "Using pagination in the REST API."

Responses

StatusDescriptionHas JSON body
200Responseyes

Get an environment

GET /repos/{owner}/{repo}/environments/{environment_name}

Anyone with read access to the repository can use this endpoint.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
environment_namepathyesThe name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with %2F.

Responses

StatusDescriptionHas JSON body
200Responseyes

Create or update an environment

PUT /repos/{owner}/{repo}/environments/{environment_name}

Create or update an environment with protection rules, such as required reviewers. For more information about environment protection rules, see "Environments."

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
environment_namepathyesThe name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with %2F.

Responses

StatusDescriptionHas JSON body
200Responseyes
422Validation error when the environment name is invalid or when protected_branches and custom_branch_policies in deployment_branch_policy are set to the same valueyes

Delete an environment

DELETE /repos/{owner}/{repo}/environments/{environment_name}

OAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
environment_namepathyesThe name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with %2F.

Responses

StatusDescriptionHas JSON body
204Default responseno

List deployment branch policies

GET /repos/{owner}/{repo}/environments/{environment_name}/deployment-branch-policies

Lists the deployment branch policies for an environment.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
environment_namepathyesThe name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with %2F.
per_pagequerynoThe number of results per page (max 100). For more information, see "Using pagination in the REST API."
pagequerynoThe page number of the results to fetch. For more information, see "Using pagination in the REST API."

Responses

StatusDescriptionHas JSON body
200Responseyes

Create a deployment branch policy

POST /repos/{owner}/{repo}/environments/{environment_name}/deployment-branch-policies

Creates a deployment branch or tag policy for an environment.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
environment_namepathyesThe name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with %2F.

Responses

StatusDescriptionHas JSON body
200Responseyes
404Not Found or deployment_branch_policy.custom_branch_policies property for the environment is set to falseno
303Response if the same branch name pattern already existsno

Get a deployment branch policy

GET /repos/{owner}/{repo}/environments/{environment_name}/deployment-branch-policies/{branch_policy_id}

Gets a deployment branch or tag policy for an environment.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
environment_namepathyesThe name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with %2F.
branch_policy_idpathyesThe unique identifier of the branch policy.

Responses

StatusDescriptionHas JSON body
200Responseyes

Update a deployment branch policy

PUT /repos/{owner}/{repo}/environments/{environment_name}/deployment-branch-policies/{branch_policy_id}

Updates a deployment branch or tag policy for an environment.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
environment_namepathyesThe name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with %2F.
branch_policy_idpathyesThe unique identifier of the branch policy.

Responses

StatusDescriptionHas JSON body
200Responseyes

Delete a deployment branch policy

DELETE /repos/{owner}/{repo}/environments/{environment_name}/deployment-branch-policies/{branch_policy_id}

Deletes a deployment branch or tag policy for an environment.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
environment_namepathyesThe name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with %2F.
branch_policy_idpathyesThe unique identifier of the branch policy.

Responses

StatusDescriptionHas JSON body
204Responseno

Get all deployment protection rules for an environment

GET /repos/{owner}/{repo}/environments/{environment_name}/deployment_protection_rules

Gets all custom deployment protection rules that are enabled for an environment. Anyone with read access to the repository can use this endpoint. For more information about environments, see "Using environments for deployment."

Parameters

NameInRequiredDescription
environment_namepathyesThe name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with %2F.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
ownerpathyesThe account owner of the repository. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
200List of deployment protection rulesyes

Create a custom deployment protection rule on an environment

POST /repos/{owner}/{repo}/environments/{environment_name}/deployment_protection_rules

Enable a custom deployment protection rule for an environment.

Parameters

NameInRequiredDescription
environment_namepathyesThe name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with %2F.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
ownerpathyesThe account owner of the repository. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
201The enabled custom deployment protection ruleyes

List custom deployment rule integrations available for an environment

GET /repos/{owner}/{repo}/environments/{environment_name}/deployment_protection_rules/apps

Gets all custom deployment protection rule integrations that are available for an environment.

Parameters

NameInRequiredDescription
environment_namepathyesThe name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with %2F.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
ownerpathyesThe account owner of the repository. The name is not case sensitive.
pagequerynoThe page number of the results to fetch. For more information, see "Using pagination in the REST API."
per_pagequerynoThe number of results per page (max 100). For more information, see "Using pagination in the REST API."

Responses

StatusDescriptionHas JSON body
200A list of custom deployment rule integrations available for this environment.yes

Get a custom deployment protection rule

GET /repos/{owner}/{repo}/environments/{environment_name}/deployment_protection_rules/{protection_rule_id}

Gets an enabled custom deployment protection rule for an environment. Anyone with read access to the repository can use this endpoint. For more information about environments, see "Using environments for deployment."

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
environment_namepathyesThe name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with %2F.
protection_rule_idpathyesThe unique identifier of the protection rule.

Responses

StatusDescriptionHas JSON body
200Responseyes

Disable a custom protection rule for an environment

DELETE /repos/{owner}/{repo}/environments/{environment_name}/deployment_protection_rules/{protection_rule_id}

Disables a custom deployment protection rule for an environment.

Parameters

NameInRequiredDescription
environment_namepathyesThe name of the environment. The name must be URL encoded. For example, any slashes in the name must be replaced with %2F.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
ownerpathyesThe account owner of the repository. The name is not case sensitive.
protection_rule_idpathyesThe unique identifier of the protection rule.

Responses

StatusDescriptionHas JSON body
204Responseno

List forks

GET /repos/{owner}/{repo}/forks

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
sortquerynoThe sort order. stargazers will sort by star count.
per_pagequerynoThe number of results per page (max 100). For more information, see "Using pagination in the REST API."
pagequerynoThe page number of the results to fetch. For more information, see "Using pagination in the REST API."

Responses

StatusDescriptionHas JSON body
200Responseyes
400Bad Requestyes

Create a fork

POST /repos/{owner}/{repo}/forks

Create a fork for the authenticated user.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
202Responseyes
400Bad Requestyes
422Validation failed, or the endpoint has been spammed.yes
403Forbiddenyes
404Resource not foundyes

Get the hash algorithm for a repository

GET /repos/{owner}/{repo}/hash-algorithm

Returns the hash algorithm used to store repository objects.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
200Responseyes
403Forbiddenyes
404Resource not foundyes

List repository webhooks

GET /repos/{owner}/{repo}/hooks

Lists webhooks for a repository. last response may return null if there have not been any deliveries within 30 days.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
per_pagequerynoThe number of results per page (max 100). For more information, see "Using pagination in the REST API."
pagequerynoThe page number of the results to fetch. For more information, see "Using pagination in the REST API."

Responses

StatusDescriptionHas JSON body
200Responseyes
404Resource not foundyes

Create a repository webhook

POST /repos/{owner}/{repo}/hooks

Repositories can have multiple webhooks installed. Each webhook should have a unique config. Multiple webhooks can

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
201Responseyes
404Resource not foundyes
422Validation failed, or the endpoint has been spammed.yes
403Forbiddenyes

Get a repository webhook

GET /repos/{owner}/{repo}/hooks/{hook_id}

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

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
hook_idpathyesThe unique identifier of the hook. You can find this value in the X-GitHub-Hook-ID header of a webhook delivery.

Responses

StatusDescriptionHas JSON body
200Responseyes
404Resource not foundyes

Update a repository webhook

PATCH /repos/{owner}/{repo}/hooks/{hook_id}

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

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
hook_idpathyesThe unique identifier of the hook. You can find this value in the X-GitHub-Hook-ID header of a webhook delivery.

Responses

StatusDescriptionHas JSON body
200Responseyes
422Validation failed, or the endpoint has been spammed.yes
404Resource not foundyes

Delete a repository webhook

DELETE /repos/{owner}/{repo}/hooks/{hook_id}

Delete a webhook for an organization.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
hook_idpathyesThe unique identifier of the hook. You can find this value in the X-GitHub-Hook-ID header of a webhook delivery.

Responses

StatusDescriptionHas JSON body
204Responseno
404Resource not foundyes

Get a webhook configuration for a repository

GET /repos/{owner}/{repo}/hooks/{hook_id}/config

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

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
hook_idpathyesThe unique identifier of the hook. You can find this value in the X-GitHub-Hook-ID header of a webhook delivery.

Responses

StatusDescriptionHas JSON body
200Responseyes

Update a webhook configuration for a repository

PATCH /repos/{owner}/{repo}/hooks/{hook_id}/config

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

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
hook_idpathyesThe unique identifier of the hook. You can find this value in the X-GitHub-Hook-ID header of a webhook delivery.

Responses

StatusDescriptionHas JSON body
200Responseyes

List deliveries for a repository webhook

GET /repos/{owner}/{repo}/hooks/{hook_id}/deliveries

Returns a list of webhook deliveries for a webhook configured in a repository.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
hook_idpathyesThe unique identifier of the hook. You can find this value in the X-GitHub-Hook-ID header of a webhook delivery.
per_pagequerynoThe number of results per page (max 100). For more information, see "Using pagination in the REST API."
cursorquerynoUsed for pagination: the starting delivery from which the page of deliveries is fetched. Refer to the link header for the next and previous page cursors.
statusquerynoReturns webhook deliveries filtered by delivery outcome classification based on status_code range. A status of success returns deliveries with a status_code in the 200-399 range (inclusive). A status of failure returns deliveries with a status_code in the 400-599 range (inclusive).

Responses

StatusDescriptionHas JSON body
200Responseyes
400Bad Requestyes
422Validation failed, or the endpoint has been spammed.yes

Get a delivery for a repository webhook

GET /repos/{owner}/{repo}/hooks/{hook_id}/deliveries/{delivery_id}

Returns a delivery for a webhook configured in a repository.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
hook_idpathyesThe unique identifier of the hook. You can find this value in the X-GitHub-Hook-ID header of a webhook delivery.
delivery_idpathyes

Responses

StatusDescriptionHas JSON body
200Responseyes
400Bad Requestyes
422Validation failed, or the endpoint has been spammed.yes

Redeliver a delivery for a repository webhook

POST /repos/{owner}/{repo}/hooks/{hook_id}/deliveries/{delivery_id}/attempts

Redeliver a webhook delivery for a webhook configured in a repository.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
hook_idpathyesThe unique identifier of the hook. You can find this value in the X-GitHub-Hook-ID header of a webhook delivery.
delivery_idpathyes

Responses

StatusDescriptionHas JSON body
202Acceptedyes
400Bad Requestyes
422Validation failed, or the endpoint has been spammed.yes

Ping a repository webhook

POST /repos/{owner}/{repo}/hooks/{hook_id}/pings

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

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
hook_idpathyesThe unique identifier of the hook. You can find this value in the X-GitHub-Hook-ID header of a webhook delivery.

Responses

StatusDescriptionHas JSON body
204Responseno
404Resource not foundyes

Test the push repository webhook

POST /repos/{owner}/{repo}/hooks/{hook_id}/tests

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.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
hook_idpathyesThe unique identifier of the hook. You can find this value in the X-GitHub-Hook-ID header of a webhook delivery.

Responses

StatusDescriptionHas JSON body
204Responseno
404Resource not foundyes

Check if immutable releases are enabled for a repository

GET /repos/{owner}/{repo}/immutable-releases

Shows whether immutable releases are enabled or disabled. Also identifies whether immutability is being

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
200Response if immutable releases are enabledyes
404Not Found if immutable releases are not enabled for the repositoryno

Enable immutable releases

PUT /repos/{owner}/{repo}/immutable-releases

Enables immutable releases for a repository. The authenticated user must have admin access to the repository.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
204A header with no content is returned.no
409Conflictyes

Disable immutable releases

DELETE /repos/{owner}/{repo}/immutable-releases

Disables immutable releases for a repository. The authenticated user must have admin access to the repository.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
204A header with no content is returned.no
409Conflictyes

List repository invitations

GET /repos/{owner}/{repo}/invitations

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

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
per_pagequerynoThe number of results per page (max 100). For more information, see "Using pagination in the REST API."
pagequerynoThe page number of the results to fetch. For more information, see "Using pagination in the REST API."

Responses

StatusDescriptionHas JSON body
200Responseyes

Update a repository invitation

PATCH /repos/{owner}/{repo}/invitations/{invitation_id}

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
invitation_idpathyesThe unique identifier of the invitation.

Responses

StatusDescriptionHas JSON body
200Responseyes

Delete a repository invitation

DELETE /repos/{owner}/{repo}/invitations/{invitation_id}

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
invitation_idpathyesThe unique identifier of the invitation.

Responses

StatusDescriptionHas JSON body
204Responseno

List issue types for a repository

GET /repos/{owner}/{repo}/issue-types

Lists issue types available for a repository (inherited from its organization owner, with any per-repository overrides applied).

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
200Responseyes
404Resource not foundyes

List deploy keys

GET /repos/{owner}/{repo}/keys

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
per_pagequerynoThe number of results per page (max 100). For more information, see "Using pagination in the REST API."
pagequerynoThe page number of the results to fetch. For more information, see "Using pagination in the REST API."

Responses

StatusDescriptionHas JSON body
200Responseyes

Create a deploy key

POST /repos/{owner}/{repo}/keys

You can create a read-only deploy key.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
201Responseyes
422Validation failed, or the endpoint has been spammed.yes

Get a deploy key

GET /repos/{owner}/{repo}/keys/{key_id}

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
key_idpathyesThe unique identifier of the key.

Responses

StatusDescriptionHas JSON body
200Responseyes
404Resource not foundyes

Delete a deploy key

DELETE /repos/{owner}/{repo}/keys/{key_id}

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

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
key_idpathyesThe unique identifier of the key.

Responses

StatusDescriptionHas JSON body
204Responseno

List repository languages

GET /repos/{owner}/{repo}/languages

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

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
200Responseyes

Sync a fork branch with the upstream repository

POST /repos/{owner}/{repo}/merge-upstream

Sync a branch of a forked repository to keep it up-to-date with the upstream repository.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
200The branch has been successfully synced with the upstream repositoryyes
409The branch could not be synced because of a merge conflictno
422The branch could not be synced for some other reasonno

Merge a branch

POST /repos/{owner}/{repo}/merges

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
201Successful Response (The resulting merge commit)yes
204Response when already mergedno
404Not Found when the base or head does not existno
409Conflict when there is a merge conflictno
403Forbiddenyes
422Validation failed, or the endpoint has been spammed.yes

Get a GitHub Pages site

GET /repos/{owner}/{repo}/pages

Gets information about a GitHub Pages site.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
200Responseyes
404Resource not foundyes

Create a GitHub Pages site

POST /repos/{owner}/{repo}/pages

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

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
201Responseyes
422Validation failed, or the endpoint has been spammed.yes
409Conflictyes

Update information about a GitHub Pages site

PUT /repos/{owner}/{repo}/pages

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

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
204Responseno
422Validation failed, or the endpoint has been spammed.yes
400Bad Requestyes
409Conflictyes

Delete a GitHub Pages site

DELETE /repos/{owner}/{repo}/pages

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

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
204Responseno
422Validation failed, or the endpoint has been spammed.yes
404Resource not foundyes
409Conflictyes

List GitHub Pages builds

GET /repos/{owner}/{repo}/pages/builds

Lists builts of a GitHub Pages site.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
per_pagequerynoThe number of results per page (max 100). For more information, see "Using pagination in the REST API."
pagequerynoThe page number of the results to fetch. For more information, see "Using pagination in the REST API."

Responses

StatusDescriptionHas JSON body
200Responseyes

Request a GitHub Pages build

POST /repos/{owner}/{repo}/pages/builds

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.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
201Responseyes

Get latest Pages build

GET /repos/{owner}/{repo}/pages/builds/latest

Gets information about the single most recent build of a GitHub Pages site.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
200Responseyes

Get GitHub Pages build

GET /repos/{owner}/{repo}/pages/builds/{build_id}

Gets information about a GitHub Pages build.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
build_idpathyes

Responses

StatusDescriptionHas JSON body
200Responseyes

Create a GitHub Pages deployment

POST /repos/{owner}/{repo}/pages/deployments

Create a GitHub Pages deployment for a repository.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
200Responseyes
400Bad Requestyes
422Validation failed, or the endpoint has been spammed.yes
404Resource not foundyes

Get the status of a GitHub Pages deployment

GET /repos/{owner}/{repo}/pages/deployments/{pages_deployment_id}

Gets the current status of a GitHub Pages deployment.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
pages_deployment_idpathyesThe ID of the Pages deployment. You can also give the commit SHA of the deployment.

Responses

StatusDescriptionHas JSON body
200Responseyes
404Resource not foundyes

Cancel a GitHub Pages deployment

POST /repos/{owner}/{repo}/pages/deployments/{pages_deployment_id}/cancel

Cancels a GitHub Pages deployment.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
pages_deployment_idpathyesThe ID of the Pages deployment. You can also give the commit SHA of the deployment.

Responses

StatusDescriptionHas JSON body
204A header with no content is returned.no
404Resource not foundyes

Get a DNS health check for GitHub Pages

GET /repos/{owner}/{repo}/pages/health

Gets a health check of the DNS settings for the CNAME record configured for a repository's GitHub Pages.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
200Responseyes
202Empty responseyes
400Custom domains are not available for GitHub Pagesno
422There isn't a CNAME for this pageno
404Resource not foundyes

Check if private vulnerability reporting is enabled for a repository

GET /repos/{owner}/{repo}/private-vulnerability-reporting

Returns a boolean indicating whether or not private vulnerability reporting is enabled for the repository. For more information, see "Evaluating the security settings of a repository".

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
200Private vulnerability reporting statusyes
422Bad Requestyes

Enable private vulnerability reporting for a repository

PUT /repos/{owner}/{repo}/private-vulnerability-reporting

Enables private vulnerability reporting for a repository. The authenticated user must have admin access to the repository. For more information, see "Privately reporting a security vulnerability."

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
204A header with no content is returned.no
422Bad Requestyes

Disable private vulnerability reporting for a repository

DELETE /repos/{owner}/{repo}/private-vulnerability-reporting

Disables private vulnerability reporting for a repository. The authenticated user must have admin access to the repository. For more information, see "Privately reporting a security vulnerability".

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
204A header with no content is returned.no
422Bad Requestyes

Get all custom property values for a repository

GET /repos/{owner}/{repo}/properties/values

Gets all custom property values that are set for a repository.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
200Responseyes
403Forbiddenyes
404Resource not foundyes

Create or update custom property values for a repository

PATCH /repos/{owner}/{repo}/properties/values

Create new or update existing custom property values for a repository.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
204No Content when custom property values are successfully created or updatedno
403Forbiddenyes
404Resource not foundyes
422Validation failed, or the endpoint has been spammed.yes

Get a repository README

GET /repos/{owner}/{repo}/readme

Gets the preferred README for a repository.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
refquerynoThe name of the commit/branch/tag. Default: the repository’s default branch.

Responses

StatusDescriptionHas JSON body
200Responseyes
304Not modifiedno
404Resource not foundyes
422Validation failed, or the endpoint has been spammed.yes

Get a repository README for a directory

GET /repos/{owner}/{repo}/readme/{dir}

Gets the README from a repository directory.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
dirpathyesThe alternate path to look for a README file
refquerynoThe name of the commit/branch/tag. Default: the repository’s default branch.

Responses

StatusDescriptionHas JSON body
200Responseyes
404Resource not foundyes
422Validation failed, or the endpoint has been spammed.yes

List releases

GET /repos/{owner}/{repo}/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.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
per_pagequerynoThe number of results per page (max 100). For more information, see "Using pagination in the REST API."
pagequerynoThe page number of the results to fetch. For more information, see "Using pagination in the REST API."

Responses

StatusDescriptionHas JSON body
200Responseyes
404Resource not foundyes

Create a release

POST /repos/{owner}/{repo}/releases

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

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
201Responseyes
404Not Found if the discussion category name is invalidyes
422Validation failed, or the endpoint has been spammed.yes

Get a release asset

GET /repos/{owner}/{repo}/releases/assets/{asset_id}

To download the asset's binary content:

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
asset_idpathyesThe unique identifier of the asset.

Responses

StatusDescriptionHas JSON body
200Responseyes
404Resource not foundyes
302Foundno

Update a release asset

PATCH /repos/{owner}/{repo}/releases/assets/{asset_id}

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

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
asset_idpathyesThe unique identifier of the asset.

Responses

StatusDescriptionHas JSON body
200Responseyes

Delete a release asset

DELETE /repos/{owner}/{repo}/releases/assets/{asset_id}

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
asset_idpathyesThe unique identifier of the asset.

Responses

StatusDescriptionHas JSON body
204Responseno
404Resource not foundyes

Generate release notes content for a release

POST /repos/{owner}/{repo}/releases/generate-notes

Generate a name and body describing a release. The body content will be markdown formatted and contain information like the changes since last release and users who contributed. The generated release notes are not saved anywhere. They are intended to be generated and used when creating a new release.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
200Name and body of generated release notesyes
404Resource not foundyes

Get the latest release

GET /repos/{owner}/{repo}/releases/latest

View the latest published full release for the repository.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
200Responseyes
404Resource not foundyes

Get a release by tag name

GET /repos/{owner}/{repo}/releases/tags/{tag}

Get a published release with the specified tag.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
tagpathyestag parameter

Responses

StatusDescriptionHas JSON body
200Responseyes
404Resource not foundyes

Get a release

GET /repos/{owner}/{repo}/releases/{release_id}

Gets a public release with the specified release ID.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
release_idpathyesThe unique identifier of the release.

Responses

StatusDescriptionHas JSON body
200Note: This returns an upload_url key corresponding to the endpoint for uploading release assets. This key is a hypermedia resource. For more information, see "Getting started with the REST API."yes
401Unauthorizedno

Update a release

PATCH /repos/{owner}/{repo}/releases/{release_id}

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

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
release_idpathyesThe unique identifier of the release.

Responses

StatusDescriptionHas JSON body
200Responseyes
404Not Found if the discussion category name is invalidyes

Delete a release

DELETE /repos/{owner}/{repo}/releases/{release_id}

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

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
release_idpathyesThe unique identifier of the release.

Responses

StatusDescriptionHas JSON body
204Responseno
404Resource not foundyes

List release assets

GET /repos/{owner}/{repo}/releases/{release_id}/assets

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
release_idpathyesThe unique identifier of the release.
per_pagequerynoThe number of results per page (max 100). For more information, see "Using pagination in the REST API."
pagequerynoThe page number of the results to fetch. For more information, see "Using pagination in the REST API."

Responses

StatusDescriptionHas JSON body
200Responseyes

Upload a release asset

POST /repos/{owner}/{repo}/releases/{release_id}/assets

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

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
release_idpathyesThe unique identifier of the release.
namequeryyes
labelqueryno

Responses

StatusDescriptionHas JSON body
201Response for successful uploadyes
422Response if you upload an asset with the same filename as another uploaded assetno

Get rules for a branch

GET /repos/{owner}/{repo}/rules/branches/{branch}

Returns all active rules that apply to the specified branch. The branch does not need to exist; rules that would apply

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
branchpathyesThe name of the branch. Cannot contain wildcard characters. To use wildcard characters in branch names, use the GraphQL API.
per_pagequerynoThe number of results per page (max 100). For more information, see "Using pagination in the REST API."
pagequerynoThe page number of the results to fetch. For more information, see "Using pagination in the REST API."

Responses

StatusDescriptionHas JSON body
200Responseyes

Get all repository rulesets

GET /repos/{owner}/{repo}/rulesets

Get all the rulesets for a repository.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
per_pagequerynoThe number of results per page (max 100). For more information, see "Using pagination in the REST API."
pagequerynoThe page number of the results to fetch. For more information, see "Using pagination in the REST API."
includes_parentsquerynoInclude rulesets configured at higher levels that apply to this repository
targetsquerynoA comma-separated list of rule targets to filter by.

Responses

StatusDescriptionHas JSON body
200Responseyes
404Resource not foundyes
500Internal Erroryes

Create a repository ruleset

POST /repos/{owner}/{repo}/rulesets

Create a ruleset for a repository.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
201Responseyes
404Resource not foundyes
422Validation failed, or the endpoint has been spammed.yes
500Internal Erroryes

List repository rule suites

GET /repos/{owner}/{repo}/rulesets/rule-suites

Lists suites of rule evaluations at the repository level.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
refquerynoThe name of the ref. Cannot contain wildcard characters. Optionally prefix with refs/heads/ to limit to branches or refs/tags/ to limit to tags. Omit the prefix to search across all refs. When specified, only rule evaluations triggered for this ref will be returned.
time_periodquerynoThe time period to filter by.
actor_namequerynoThe handle for the GitHub user account to filter on. When specified, only rule evaluations triggered by this actor will be returned.
rule_suite_resultquerynoThe rule suite results to filter on. When specified, only suites with this result will be returned.
evaluate_statusquerynoThe evaluate status to filter on. When specified, only rule suites resulting from rulesets with the specified evaluate status will be returned.
per_pagequerynoThe number of results per page (max 100). For more information, see "Using pagination in the REST API."
pagequerynoThe page number of the results to fetch. For more information, see "Using pagination in the REST API."

Responses

StatusDescriptionHas JSON body
200Responseyes
404Resource not foundyes
500Internal Erroryes

Get a repository rule suite

GET /repos/{owner}/{repo}/rulesets/rule-suites/{rule_suite_id}

Gets information about a suite of rule evaluations from within a repository.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
rule_suite_idpathyesThe unique identifier of the rule suite result.

Responses

StatusDescriptionHas JSON body
200Responseyes
404Resource not foundyes
500Internal Erroryes

Get a repository ruleset

GET /repos/{owner}/{repo}/rulesets/{ruleset_id}

Get a ruleset for a repository.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
ruleset_idpathyesThe ID of the ruleset.
includes_parentsquerynoInclude rulesets configured at higher levels that apply to this repository

Responses

StatusDescriptionHas JSON body
200Responseyes
404Resource not foundyes
500Internal Erroryes

Update a repository ruleset

PUT /repos/{owner}/{repo}/rulesets/{ruleset_id}

Update a ruleset for a repository.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
ruleset_idpathyesThe ID of the ruleset.

Responses

StatusDescriptionHas JSON body
200Responseyes
404Resource not foundyes
422Validation failed, or the endpoint has been spammed.yes
500Internal Erroryes

Delete a repository ruleset

DELETE /repos/{owner}/{repo}/rulesets/{ruleset_id}

Delete a ruleset for a repository.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
ruleset_idpathyesThe ID of the ruleset.

Responses

StatusDescriptionHas JSON body
204Responseno
404Resource not foundyes
500Internal Erroryes

Get repository ruleset history

GET /repos/{owner}/{repo}/rulesets/{ruleset_id}/history

Get the history of a repository ruleset.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
per_pagequerynoThe number of results per page (max 100). For more information, see "Using pagination in the REST API."
pagequerynoThe page number of the results to fetch. For more information, see "Using pagination in the REST API."
ruleset_idpathyesThe ID of the ruleset.

Responses

StatusDescriptionHas JSON body
200Responseyes
404Resource not foundyes
500Internal Erroryes

Get repository ruleset version

GET /repos/{owner}/{repo}/rulesets/{ruleset_id}/history/{version_id}

Get a version of a repository ruleset.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
ruleset_idpathyesThe ID of the ruleset.
version_idpathyesThe ID of the version

Responses

StatusDescriptionHas JSON body
200Responseyes
404Resource not foundyes
500Internal Erroryes

Get the weekly commit activity

GET /repos/{owner}/{repo}/stats/code_frequency

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

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
200Returns a weekly aggregate of the number of additions and deletions pushed to a repository.yes
202Acceptedyes
204A header with no content is returned.no
422Repository contains more than 10,000 commitsno

Get the last year of commit activity

GET /repos/{owner}/{repo}/stats/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.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
200Responseyes
202Acceptedyes
204A header with no content is returned.no

Get all contributor commit activity

GET /repos/{owner}/{repo}/stats/contributors

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

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
200Responseyes
202Acceptedyes
204A header with no content is returned.no

Get the weekly commit count

GET /repos/{owner}/{repo}/stats/participation

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.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
200The array order is oldest week (index 0) to most recent week.yes
404Resource not foundyes

Get the hourly commit count for each day

GET /repos/{owner}/{repo}/stats/punch_card

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

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
200For 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.yes
204A header with no content is returned.no

Create a commit status

POST /repos/{owner}/{repo}/statuses/{sha}

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

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
shapathyes

Responses

StatusDescriptionHas JSON body
201Responseyes

List repository tags

GET /repos/{owner}/{repo}/tags

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
per_pagequerynoThe number of results per page (max 100). For more information, see "Using pagination in the REST API."
pagequerynoThe page number of the results to fetch. For more information, see "Using pagination in the REST API."

Responses

StatusDescriptionHas JSON body
200Responseyes

Download a repository archive (tar)

GET /repos/{owner}/{repo}/tarball/{ref}

Gets a redirect URL to download a tar archive for a repository. If you omit :ref, the repository’s default branch (usually

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
refpathyes

Responses

StatusDescriptionHas JSON body
302Responseno

List repository teams

GET /repos/{owner}/{repo}/teams

Lists the teams that have access to the specified repository and that are also visible to the authenticated user.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
per_pagequerynoThe number of results per page (max 100). For more information, see "Using pagination in the REST API."
pagequerynoThe page number of the results to fetch. For more information, see "Using pagination in the REST API."

Responses

StatusDescriptionHas JSON body
200Responseyes
404Resource not foundyes

Get all repository topics

GET /repos/{owner}/{repo}/topics

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
pagequerynoThe page number of the results to fetch. For more information, see "Using pagination in the REST API."
per_pagequerynoThe number of results per page (max 100). For more information, see "Using pagination in the REST API."

Responses

StatusDescriptionHas JSON body
200Responseyes
404Resource not foundyes

Replace all repository topics

PUT /repos/{owner}/{repo}/topics

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
200Responseyes
404Resource not foundyes
422Validation failed, or the endpoint has been spammed.yes

Get repository clones

GET /repos/{owner}/{repo}/traffic/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.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
perquerynoThe time frame to display results for.

Responses

StatusDescriptionHas JSON body
200Responseyes
403Forbiddenyes

Get page views

GET /repos/{owner}/{repo}/traffic/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.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
perquerynoThe time frame to display results for.

Responses

StatusDescriptionHas JSON body
200Responseyes
403Forbiddenyes

Transfer a repository

POST /repos/{owner}/{repo}/transfer

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.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
202Responseyes

Check if vulnerability alerts are enabled for a repository

GET /repos/{owner}/{repo}/vulnerability-alerts

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

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
204Response if repository is enabled with vulnerability alertsno
404Not Found if repository is not enabled with vulnerability alertsno

Enable vulnerability alerts

PUT /repos/{owner}/{repo}/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".

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
204Responseno

Disable vulnerability alerts

DELETE /repos/{owner}/{repo}/vulnerability-alerts

Disables dependency alerts and the dependency graph for a repository.

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
204Responseno

Download a repository archive (zip)

GET /repos/{owner}/{repo}/zipball/{ref}

Gets a redirect URL to download a zip archive for a repository. If you omit :ref, the repository’s default branch (usually

Parameters

NameInRequiredDescription
ownerpathyesThe account owner of the repository. The name is not case sensitive.
repopathyesThe name of the repository without the .git extension. The name is not case sensitive.
refpathyes

Responses

StatusDescriptionHas JSON body
302Responseno

Create a repository using a template

POST /repos/{template_owner}/{template_repo}/generate

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. If the repository is not public, 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.

Parameters

NameInRequiredDescription
template_ownerpathyesThe account owner of the template repository. The name is not case sensitive.
template_repopathyesThe name of the template repository without the .git extension. The name is not case sensitive.

Responses

StatusDescriptionHas JSON body
201Responseyes

List public repositories

GET /repositories

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

Parameters

NameInRequiredDescription
sincequerynoA repository ID. Only return repositories with an ID greater than this ID.

Responses

StatusDescriptionHas JSON body
200Responseyes
422Validation failed, or the endpoint has been spammed.yes
304Not modifiedno

List repositories for the authenticated user

GET /user/repos

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

Parameters

NameInRequiredDescription
visibilityquerynoLimit results to repositories with the specified visibility.
affiliationquerynoComma-separated list of values. Can include:
typequerynoLimit results to repositories of the specified type. Will cause a 422 error if used in the same request as visibility or affiliation.
sortquerynoThe property to sort the results by.
directionquerynoThe order to sort by. Default: asc when using full_name, otherwise desc.
per_pagequerynoThe number of results per page (max 100). For more information, see "Using pagination in the REST API."
pagequerynoThe page number of the results to fetch. For more information, see "Using pagination in the REST API."
sincequerynoOnly show repositories updated after the given time. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.
beforequerynoOnly show repositories updated before the given time. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.

Responses

StatusDescriptionHas JSON body
200Responseyes
422Validation failed, or the endpoint has been spammed.yes
304Not modifiedno
403Forbiddenyes
401Requires authenticationyes

Create a repository for the authenticated user

POST /user/repos

Creates a new repository for the authenticated user.

Parameters

No parameters.

Responses

StatusDescriptionHas JSON body
201Responseyes
401Requires authenticationyes
304Not modifiedno
404Resource not foundyes
403Forbiddenyes
422Validation failed, or the endpoint has been spammed.yes
400Bad Requestyes

List repository invitations for the authenticated user

GET /user/repository_invitations

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

Parameters

NameInRequiredDescription
per_pagequerynoThe number of results per page (max 100). For more information, see "Using pagination in the REST API."
pagequerynoThe page number of the results to fetch. For more information, see "Using pagination in the REST API."

Responses

StatusDescriptionHas JSON body
200Responseyes
304Not modifiedno
404Resource not foundyes
403Forbiddenyes
401Requires authenticationyes

Accept a repository invitation

PATCH /user/repository_invitations/{invitation_id}

Parameters

NameInRequiredDescription
invitation_idpathyesThe unique identifier of the invitation.

Responses

StatusDescriptionHas JSON body
204Responseno
403Forbiddenyes
409Conflictyes
404Resource not foundyes
304Not modifiedno

Decline a repository invitation

DELETE /user/repository_invitations/{invitation_id}

Parameters

NameInRequiredDescription
invitation_idpathyesThe unique identifier of the invitation.

Responses

StatusDescriptionHas JSON body
204Responseno
409Conflictyes
304Not modifiedno
404Resource not foundyes
403Forbiddenyes

List repositories for a user

GET /users/{username}/repos

Lists public repositories for the specified user.

Parameters

NameInRequiredDescription
usernamepathyesThe handle for the GitHub user account.
typequerynoLimit results to repositories of the specified type.
sortquerynoThe property to sort the results by.
directionquerynoThe order to sort by. Default: asc when using full_name, otherwise desc.
per_pagequerynoThe number of results per page (max 100). For more information, see "Using pagination in the REST API."
pagequerynoThe page number of the results to fetch. For more information, see "Using pagination in the REST API."

Responses

StatusDescriptionHas JSON body
200Responseyes