GitHub API
  1. repos
GitHub API
  • meta
    • GitHub API Root
    • Get GitHub Enterprise Server meta information
    • Get Octocat
    • Get the Zen of GitHub
  • enterprise-admin
    • List global webhooks
    • Create a global webhook
    • Delete a global webhook
    • Get a global webhook
    • Update a global webhook
    • Ping a global webhook
    • List public keys
    • Delete a public key
    • Update LDAP mapping for a team
    • Sync LDAP mapping for a team
    • Update LDAP mapping for a user
    • Sync LDAP mapping for a user
    • Create an organization
    • Update an organization name
    • List pre-receive environments
    • Create a pre-receive environment
    • Delete a pre-receive environment
    • Get a pre-receive environment
    • Update a pre-receive environment
    • Start a pre-receive environment download
    • Get the download status for a pre-receive environment
    • List pre-receive hooks
    • Create a pre-receive hook
    • Delete a pre-receive hook
    • Get a pre-receive hook
    • Update a pre-receive hook
    • List personal access tokens
    • Delete a personal access token
    • Create a user
    • Delete a user
    • Update the username for a user
    • Delete an impersonation OAuth token
    • Create an impersonation OAuth token
    • Get license information
    • Get statistics
    • List self-hosted runner groups for an enterprise
    • Create a self-hosted runner group for an enterprise
    • Delete a self-hosted runner group from an enterprise
    • Get a self-hosted runner group for an enterprise
    • Update a self-hosted runner group for an enterprise
    • List organization access to a self-hosted runner group in an enterprise
    • Set organization access for a self-hosted runner group in an enterprise
    • Remove organization access to a self-hosted runner group in an enterprise
    • Add organization access to a self-hosted runner group in an enterprise
    • List self-hosted runners in a group for an enterprise
    • Set self-hosted runners in a group for an enterprise
    • Remove a self-hosted runner from a group for an enterprise
    • Add a self-hosted runner to a group for an enterprise
    • List self-hosted runners for an enterprise
    • List runner applications for an enterprise
    • Create a registration token for an enterprise
    • Create a remove token for an enterprise
    • Delete a self-hosted runner from an enterprise
    • Get a self-hosted runner for an enterprise
    • List pre-receive hooks for an organization
    • Remove pre-receive hook enforcement for an organization
    • Get a pre-receive hook for an organization
    • Update pre-receive hook enforcement for an organization
    • List pre-receive hooks for a repository
    • Remove pre-receive hook enforcement for a repository
    • Get a pre-receive hook for a repository
    • Update pre-receive hook enforcement for a repository
    • Get the configuration status
    • Start a configuration process
    • Get the maintenance status
    • Enable or disable maintenance mode
    • Get settings
    • Set settings
    • Remove an authorized SSH key
    • Get all authorized SSH keys
    • Add an authorized SSH key
    • Create a GitHub license
    • Upgrade a license
    • Demote a site administrator
    • Promote a user to be a site administrator
    • Unsuspend a user
    • Suspend a user
  • apps
    • Get the authenticated app
    • Create a GitHub App from a manifest
    • List installations for the authenticated app
    • Delete an installation for the authenticated app
    • Get an installation for the authenticated app
    • Create an installation access token for an app
    • Unsuspend an app installation
    • Suspend an app installation
    • Delete an app authorization
    • Revoke a grant for an application
    • Delete an app token
    • Reset a token
    • Check a token
    • Revoke an authorization for an application
    • Check an authorization
    • Reset an authorization
    • Get an app
    • List repositories accessible to the app installation
    • Revoke an installation access token
    • Get an organization installation for the authenticated app
    • Create a content attachment
    • Get a repository installation for the authenticated app
    • List app installations accessible to the user access token
    • List repositories accessible to the user access token
    • Remove a repository from an app installation
    • Add a repository to an app installation
    • Get a user installation for the authenticated app
  • oauth-authorizations
    • List your grants
    • Delete a grant
    • Get a single grant
    • List your authorizations
    • Create a new authorization
    • Get-or-create an authorization for a specific app
    • Get-or-create an authorization for a specific app and fingerprint
    • Delete an authorization
    • Get a single authorization
    • Update an existing authorization
  • codes-of-conduct
    • Get all codes of conduct
    • Get a code of conduct
  • emojis
    • Get emojis
  • activity
    • List public events
    • Get feeds
    • List public events for a network of repositories
    • List notifications for the authenticated user
    • Mark notifications as read
    • Get a thread
    • Mark a thread as read
    • Delete a thread subscription
    • Get a thread subscription for the authenticated user
    • Set a thread subscription
    • List public organization events
    • List repository events
    • List repository notifications for the authenticated user
    • Mark repository notifications as read
    • List stargazers
    • List watchers
    • Delete a repository subscription
    • Get a repository subscription
    • Set a repository subscription
    • List repositories starred by the authenticated user
    • Unstar a repository for the authenticated user
    • Check if a repository is starred by the authenticated user
    • Star a repository for the authenticated user
    • List repositories watched by the authenticated user
    • List events for the authenticated user
    • List organization events for the authenticated user
    • List public events for a user
    • List events received by the authenticated user
    • List public events received by a user
    • List repositories starred by a user
    • List repositories watched by a user
  • gists
    • List gists for the authenticated user
    • Create a gist
    • List public gists
    • List starred gists
    • Delete a gist
    • Get a gist
    • Update a gist
    • List gist comments
    • Create a gist comment
    • Delete a gist comment
    • Get a gist comment
    • Update a gist comment
    • List gist commits
    • List gist forks
    • Fork a gist
    • Unstar a gist
    • Check if a gist is starred
    • Star a gist
    • Get a gist revision
    • List gists for a user
  • gitignore
    • Get all gitignore templates
    • Get a gitignore template
  • issues
    • List issues assigned to the authenticated user
    • List organization issues assigned to the authenticated user
    • List assignees
    • Check if a user can be assigned
    • List repository issues
    • Create an issue
    • List issue comments for a repository
    • Delete an issue comment
    • Get an issue comment
    • Update an issue comment
    • List issue events for a repository
    • Get an issue event
    • Get an issue
    • Update an issue
    • Remove assignees from an issue
    • Add assignees to an issue
    • List issue comments
    • Create an issue comment
    • List issue events
    • Remove all labels from an issue
    • List labels for an issue
    • Add labels to an issue
    • Set labels for an issue
    • Remove a label from an issue
    • Unlock an issue
    • Lock an issue
    • List timeline events for an issue
    • List labels for a repository
    • Create a label
    • Delete a label
    • Get a label
    • Update a label
    • List milestones
    • Create a milestone
    • Delete a milestone
    • Get a milestone
    • Update a milestone
    • List labels for issues in a milestone
    • List user account issues assigned to the authenticated user
  • licenses
    • Get all commonly used licenses
    • Get a license
    • Get the license for a repository
  • markdown
    • Render a Markdown document
    • Render a Markdown document in raw mode
  • orgs
    • List organizations
    • Get an organization
    • Update an organization
    • List organization webhooks
    • Create an organization webhook
    • Delete an organization webhook
    • Get an organization webhook
    • Update an organization webhook
    • Ping an organization webhook
    • List app installations for an organization
    • List organization members
    • Remove an organization member
    • Check organization membership for a user
    • Remove organization membership for a user
    • Get organization membership for a user
    • Set organization membership for a user
    • List outside collaborators for an organization
    • Remove outside collaborator from an organization
    • Convert an organization member to outside collaborator
    • List public organization members
    • Remove public organization membership for the authenticated user
    • Check public organization membership for a user
    • Set public organization membership for the authenticated user
    • List organization memberships for the authenticated user
    • Get an organization membership for the authenticated user
    • Update an organization membership for the authenticated user
    • List organizations for the authenticated user
    • List organizations for a user
  • actions
    • List self-hosted runner groups for an organization
    • Create a self-hosted runner group for an organization
    • Delete a self-hosted runner group from an organization
    • Get a self-hosted runner group for an organization
    • Update a self-hosted runner group for an organization
    • List repository access to a self-hosted runner group in an organization
    • Set repository access for a self-hosted runner group in an organization
    • Remove repository access to a self-hosted runner group in an organization
    • Add repository access to a self-hosted runner group in an organization
    • List self-hosted runners in a group for an organization
    • Set self-hosted runners in a group for an organization
    • Remove a self-hosted runner from a group for an organization
    • Add a self-hosted runner to a group for an organization
    • List self-hosted runners for an organization
    • List runner applications for an organization
    • Create a registration token for an organization
    • Create a remove token for an organization
    • Delete a self-hosted runner from an organization
    • Get a self-hosted runner for an organization
    • List organization secrets
    • Get an organization public key
    • Delete an organization secret
    • Get an organization secret
    • Create or update an organization secret
    • List selected repositories for an organization secret
    • Set selected repositories for an organization secret
    • Remove selected repository from an organization secret
    • Add selected repository to an organization secret
    • List artifacts for a repository
    • Delete an artifact
    • Get an artifact
    • Download an artifact
    • Get a job for a workflow run
    • Download job logs for a workflow run
    • List self-hosted runners for a repository
    • List runner applications for a repository
    • Create a registration token for a repository
    • Create a remove token for a repository
    • Delete a self-hosted runner from a repository
    • Get a self-hosted runner for a repository
    • List workflow runs for a repository
    • Delete a workflow run
    • Get a workflow run
    • List workflow run artifacts
    • Cancel a workflow run
    • List jobs for a workflow run
    • Delete workflow run logs
    • Download workflow run logs
    • Re-run a workflow
    • List repository secrets
    • Get a repository public key
    • Delete a repository secret
    • Get a repository secret
    • Create or update a repository secret
    • List repository workflows
    • Get a workflow
    • Create a workflow dispatch event
    • List workflow runs
  • projects
    • List organization projects
    • Create an organization project
    • Delete a project card
    • Get a project card
    • Update an existing project card
    • Move a project card
    • Delete a project column
    • Get a project column
    • Update an existing project column
    • List project cards
    • Create a project card
    • Move a project column
    • Delete a project
    • Get a project
    • Update a project
    • List project collaborators
    • Remove user as a collaborator
    • Add project collaborator
    • Get project permission for a user
    • List project columns
    • Create a project column
    • List repository projects
    • Create a repository project
    • Create a user project
    • List user projects
  • repos
    • List organization repositories
      GET
    • Create an organization repository
      POST
    • Delete a repository
      DELETE
    • Get a repository
      GET
    • Update a repository
      PATCH
    • List branches
      GET
    • Get a branch
      GET
    • Delete branch protection
      DELETE
    • Get branch protection
      GET
    • Update branch protection
      PUT
    • Delete admin branch protection
      DELETE
    • Get admin branch protection
      GET
    • Set admin branch protection
      POST
    • Delete pull request review protection
      DELETE
    • Get pull request review protection
      GET
    • Update pull request review protection
      PATCH
    • Delete commit signature protection
      DELETE
    • Get commit signature protection
      GET
    • Create commit signature protection
      POST
    • Remove status check protection
      DELETE
    • Get status checks protection
      GET
    • Update status check protection
      PATCH
    • Remove status check contexts
      DELETE
    • Get all status check contexts
      GET
    • Add status check contexts
      POST
    • Set status check contexts
      PUT
    • Delete access restrictions
      DELETE
    • Get access restrictions
      GET
    • Remove app access restrictions
      DELETE
    • Get apps with access to the protected branch
      GET
    • Add app access restrictions
      POST
    • Set app access restrictions
      PUT
    • Remove team access restrictions
      DELETE
    • Get teams with access to the protected branch
      GET
    • Add team access restrictions
      POST
    • Set team access restrictions
      PUT
    • Remove user access restrictions
      DELETE
    • Get users with access to the protected branch
      GET
    • Add user access restrictions
      POST
    • Set user access restrictions
      PUT
    • List repository collaborators
      GET
    • Remove a repository collaborator
      DELETE
    • Check if a user is a repository collaborator
      GET
    • Add a repository collaborator
      PUT
    • Get repository permissions for a user
      GET
    • List commit comments for a repository
      GET
    • Delete a commit comment
      DELETE
    • Get a commit comment
      GET
    • Update a commit comment
      PATCH
    • List commits
      GET
    • List branches for HEAD commit
      GET
    • List commit comments
      GET
    • Create a commit comment
      POST
    • List pull requests associated with a commit
      GET
    • Get a commit
      GET
    • Get the combined status for a specific reference
      GET
    • List commit statuses for a reference
      GET
    • Compare two commits
      GET
    • Delete a file
      DELETE
    • Get repository content
      GET
    • Create or update file contents
      PUT
    • List repository contributors
      GET
    • List deployments
      GET
    • Create a deployment
      POST
    • Delete a deployment
      DELETE
    • Get a deployment
      GET
    • List deployment statuses
      GET
    • Create a deployment status
      POST
    • Get a deployment status
      GET
    • Create a repository dispatch event
      POST
    • List forks
      GET
    • Create a fork
      POST
    • List repository webhooks
      GET
    • Create a repository webhook
      POST
    • Delete a repository webhook
      DELETE
    • Get a repository webhook
      GET
    • Update a repository webhook
      PATCH
    • Ping a repository webhook
      POST
    • Test the push repository webhook
      POST
    • List repository invitations
      GET
    • Delete a repository invitation
      DELETE
    • Update a repository invitation
      PATCH
    • List deploy keys
      GET
    • Create a deploy key
      POST
    • Delete a deploy key
      DELETE
    • Get a deploy key
      GET
    • List repository languages
      GET
    • Merge a branch
      POST
    • Delete a GitHub Enterprise Server Pages site
      DELETE
    • Get a GitHub Enterprise Server Pages site
      GET
    • Create a GitHub Enterprise Server Pages site
      POST
    • Update information about a GitHub Enterprise Server Pages site
      PUT
    • List GitHub Enterprise Server Pages builds
      GET
    • Request a GitHub Enterprise Server Pages build
      POST
    • Get latest Pages build
      GET
    • Get GitHub Enterprise Server Pages build
      GET
    • Get a repository README
      GET
    • Get a repository README for a directory
      GET
    • List releases
      GET
    • Create a release
      POST
    • Delete a release asset
      DELETE
    • Get a release asset
      GET
    • Update a release asset
      PATCH
    • Get the latest release
      GET
    • Get a release by tag name
      GET
    • Delete a release
      DELETE
    • Get a release
      GET
    • Update a release
      PATCH
    • List release assets
      GET
    • Upload a release asset
      POST
    • Get the weekly commit activity
      GET
    • Get the last year of commit activity
      GET
    • Get all contributor commit activity
      GET
    • Get the weekly commit count
      GET
    • Get the hourly commit count for each day
      GET
    • Create a commit status
      POST
    • List repository tags
      GET
    • Download a repository archive (tar)
      GET
    • List repository teams
      GET
    • Get all repository topics
      GET
    • Replace all repository topics
      PUT
    • Transfer a repository
      POST
    • Download a repository archive (zip)
      GET
    • Create a repository using a template
      POST
    • List public repositories
      GET
    • List repositories for the authenticated user
      GET
    • Create a repository for the authenticated user
      POST
    • List repository invitations for the authenticated user
      GET
    • Decline a repository invitation
      DELETE
    • Accept a repository invitation
      PATCH
    • List repositories for a user
      GET
  • teams
    • List teams
    • Create a team
    • Delete a team
    • Get a team by name
    • Update a team
    • List discussions
    • Create a discussion
    • Delete a discussion
    • Get a discussion
    • Update a discussion
    • List discussion comments
    • Create a discussion comment
    • Delete a discussion comment
    • Get a discussion comment
    • Update a discussion comment
    • List team members
    • Remove team membership for a user
    • Get team membership for a user
    • Add or update team membership for a user
    • List team projects
    • Remove a project from a team
    • Check team permissions for a project
    • Add or update team project permissions
    • List team repositories
    • Remove a repository from a team
    • Check team permissions for a repository
    • Add or update team repository permissions
    • List child teams
    • Delete a team (Legacy)
    • Get a team (Legacy)
    • Update a team (Legacy)
    • List discussions (Legacy)
    • Create a discussion (Legacy)
    • Delete a discussion (Legacy)
    • Get a discussion (Legacy)
    • Update a discussion (Legacy)
    • List discussion comments (Legacy)
    • Create a discussion comment (Legacy)
    • Delete a discussion comment (Legacy)
    • Get a discussion comment (Legacy)
    • Update a discussion comment (Legacy)
    • List team members (Legacy)
    • Remove team member (Legacy)
    • Get team member (Legacy)
    • Add team member (Legacy)
    • Remove team membership for a user (Legacy)
    • Get team membership for a user (Legacy)
    • Add or update team membership for a user (Legacy)
    • List team projects (Legacy)
    • Remove a project from a team (Legacy)
    • Check team permissions for a project (Legacy)
    • Add or update team project permissions (Legacy)
    • List team repositories (Legacy)
    • Remove a repository from a team (Legacy)
    • Check team permissions for a repository (Legacy)
    • Add or update team repository permissions (Legacy)
    • List child teams (Legacy)
    • List teams for the authenticated user
  • reactions
    • List reactions for a team discussion comment
    • Create reaction for a team discussion comment
    • Delete team discussion comment reaction
    • List reactions for a team discussion
    • Create reaction for a team discussion
    • Delete team discussion reaction
    • Delete a reaction (Legacy)
    • List reactions for a commit comment
    • Create reaction for a commit comment
    • Delete a commit comment reaction
    • List reactions for an issue comment
    • Create reaction for an issue comment
    • Delete an issue comment reaction
    • List reactions for an issue
    • Create reaction for an issue
    • Delete an issue reaction
    • List reactions for a pull request review comment
    • Create reaction for a pull request review comment
    • Delete a pull request comment reaction
    • List reactions for a team discussion comment (Legacy)
    • Create reaction for a team discussion comment (Legacy)
    • List reactions for a team discussion (Legacy)
    • Create reaction for a team discussion (Legacy)
  • rate-limit
    • Get rate limit status for the authenticated user
  • checks
    • Create a check run
    • Get a check run
    • Update a check run
    • List check run annotations
    • Create a check suite
    • Update repository preferences for check suites
    • Get a check suite
    • List check runs in a check suite
    • Rerequest a check suite
    • List check runs for a Git reference
    • List check suites for a Git reference
  • code-scanning
    • List code scanning alerts for a repository
    • Get a code scanning alert
    • Update a code scanning alert
    • List code scanning analyses for a repository
    • Upload an analysis as SARIF data
  • git
    • Create a blob
    • Get a blob
    • Create a commit
    • Get a commit
    • List matching references
    • Get a reference
    • Create a reference
    • Delete a reference
    • Update a reference
    • Create a tag object
    • Get a tag
    • Create a tree
    • Get a tree
  • pulls
    • List pull requests
    • Create a pull request
    • List review comments in a repository
    • Delete a review comment for a pull request
    • Get a review comment for a pull request
    • Update a review comment for a pull request
    • Get a pull request
    • Update a pull request
    • List review comments on a pull request
    • Create a review comment for a pull request
    • Create a reply for a review comment
    • List commits on a pull request
    • List pull requests files
    • Check if a pull request has been merged
    • Merge a pull request
    • Remove requested reviewers from a pull request
    • List requested reviewers for a pull request
    • Request reviewers for a pull request
    • List reviews for a pull request
    • Create a review for a pull request
    • Delete a pending review for a pull request
    • Get a review for a pull request
    • Update a review for a pull request
    • List comments for a pull request review
    • Dismiss a review for a pull request
    • Submit a review for a pull request
    • Update a pull request branch
  • search
    • Search code
    • Search commits
    • Search issues and pull requests
    • Search labels
    • Search repositories
    • Search topics
    • Search users
  • users
    • Get the authenticated user
    • Update the authenticated user
    • Delete an email address for the authenticated user
    • List email addresses for the authenticated user
    • Add an email address for the authenticated user
    • List followers of the authenticated user
    • List the people the authenticated user follows
    • Unfollow a user
    • Check if a person is followed by the authenticated user
    • Follow a user
    • List GPG keys for the authenticated user
    • Create a GPG key for the authenticated user
    • Delete a GPG key for the authenticated user
    • Get a GPG key for the authenticated user
    • List public SSH keys for the authenticated user
    • Create a public SSH key for the authenticated user
    • Delete a public SSH key for the authenticated user
    • Get a public SSH key for the authenticated user
    • List public email addresses for the authenticated user
    • List users
    • Get a user
    • List followers of a user
    • List the people a user follows
    • Check if a user follows another user
    • List GPG keys for a user
    • Get contextual information for a user
    • List public keys for a user
  • billing
  • interactions
  • migrations
  1. repos

Create a deploy key

POST
/repos/{owner}/{repo}/keys
repos
You can create a read-only deploy key.
请求示例请求示例
Shell
JavaScript
Java
Swift
curl --location --request POST 'https://api.github.com/repos///keys' \
--header 'Content-Type: application/json' \
--data-raw '{
    "key": "ssh-rsa AAA...",
    "read_only": true,
    "title": "octocat@octomac"
}'
响应示例响应示例
201 - 示例 1
{
  "created_at": "string",
  "id": 0,
  "key": "string",
  "read_only": true,
  "title": "string",
  "url": "string",
  "verified": true
}

请求参数

Authorization
在 Header 添加参数
Authorization
,其值为在 Bearer 之后拼接 Token
示例:
Authorization: Bearer ********************
Path 参数
owner
string 
必需
repo
string 
必需
Body 参数application/json
key
string 
必需
The contents of the key.
read_only
boolean 
可选
If true, the key will only be able to read repository contents. Otherwise, the key will be able to read and write.
Deploy keys with write access can perform the same actions as an organization member with admin access, or a collaborator on a personal repository. For more information, see "Repository permission levels for an organization" and "Permission levels for a user account repository."
title
string 
可选
A name for the key.
示例

返回响应

🟢201Response
application/json
Body
An SSH key granting access to a single repository.
created_at
string 
必需
id
integer 
必需
key
string 
必需
read_only
boolean 
必需
title
string 
必需
url
string 
必需
verified
boolean 
必需
🟠422422

【GitHub】API开发者 微信交流群

用微信扫右侧二维码,加入【GitHub】API开发者 交流群,互助沟通

扫码加入交流群
上一页
List deploy keys
下一页
Delete a deploy key
Built with