Deploy Keys

List deploy keys

GET /repos/:owner/:repo/keys

Response

Status: 200 OK
Link: <https://api.github.com/resource?page=2>; rel="next",
      <https://api.github.com/resource?page=5>; rel="last"
X-RateLimit-Limit: 5000
X-RateLimit-Remaining: 4999
[
  {
    "id": 1,
    "key": "ssh-rsa AAA...",
    "url": "https://api.github.com/repos/octocat/Hello-World/keys/1",
    "title": "octocat@octomac",
    "verified": true,
    "created_at": "2014-12-10T15:53:42Z",
    "read_only": true
  }
]

Get a deploy key

GET /repos/:owner/:repo/keys/:id

Response

Status: 200 OK
X-RateLimit-Limit: 5000
X-RateLimit-Remaining: 4999
{
  "id": 1,
  "key": "ssh-rsa AAA...",
  "url": "https://api.github.com/repos/octocat/Hello-World/keys/1",
  "title": "octocat@octomac",
  "verified": true,
  "created_at": "2014-12-10T15:53:42Z",
  "read_only": true
}

Add a new deploy key

POST /repos/:owner/:repo/keys

Parameters

Name Type Description
title string A name for the key.
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.

Example

Here’s how you can create a read-only deploy key:

{
  "title": "octocat@octomac",
  "key": "ssh-rsa AAA...",
  "read_only": true
}

Response

Status: 201 Created
Location: https://api.github.com/repos/octocat/Hello-World/keys/1
X-RateLimit-Limit: 5000
X-RateLimit-Remaining: 4999
{
  "id": 1,
  "key": "ssh-rsa AAA...",
  "url": "https://api.github.com/repos/octocat/Hello-World/keys/1",
  "title": "octocat@octomac",
  "verified": true,
  "created_at": "2014-12-10T15:53:42Z",
  "read_only": true
}

Edit a deploy key

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

Remove a deploy key

DELETE /repos/:owner/:repo/keys/:id

Response

Status: 204 No Content
X-RateLimit-Limit: 5000
X-RateLimit-Remaining: 4999