Deploy Keys
You can launch projects from a GitHub repository to your server by using a deploy key, which is an SSH key that grants access to a single repository. GitHub attaches the public part of the key directly to your repository instead of a personal user account, and the private part of the key remains on your server. For more information, see "Delivering deployments."
Deploy keys can either be setup using the following API endpoints, or by using GitHub. To learn how to set deploy keys up in GitHub, see "Managing 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"
[
{
"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/:key_id
Response
Status: 200 OK
{
"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 |
Required. 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." |
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
{
"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/:key_id
Response
Status: 204 No Content