Public Keys

List public keys for a user

GET /users/:username/keys

Lists the verified public keys for a user. This is accessible by anyone.

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

List your public keys

GET /user/keys

Lists the current user’s keys. Requires that you are authenticated via Basic Auth or via OAuth with at least read:public_key scope.

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/user/keys/1",
    "title": "octocat@octomac",
    "verified": true,
    "created_at": "2014-12-10T15:53:42Z"
  }
]

Get a single public key

View extended details for a single public key. Requires that you are authenticated via Basic Auth or via OAuth with at least read:public_key scope.

GET /user/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/user/keys/1",
  "title": "octocat@octomac",
  "verified": true,
  "created_at": "2014-12-10T15:53:42Z"
}

Create a public key

Creates a public key. Requires that you are authenticated via Basic Auth, or OAuth with at least write:public_key scope.

If your GitHub Enterprise appliance has LDAP Sync enabled and the option to synchronize SSH keys enabled, this API is disabled and will return a 403 response. Users managed in LDAP won’t be able to add an SSH key address via the API with these options enabled.

POST /user/keys

Input

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

Response

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

Update a public key

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

Delete a public key

Removes a public key. Requires that you are authenticated via Basic Auth or via OAuth with at least admin:public_key scope.

If your GitHub Enterprise appliance has LDAP Sync enabled and the option to synchronize SSH keys enabled, this API is disabled and will return a 403 response. Users managed in LDAP won’t be able to remove an SSH key address via the API with these options enabled.

DELETE /user/keys/:id

Response

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