Skip to content

Create a deploy key

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

You can create a read-only deploy key.

API method documentation

owner
required
string

The account owner of the repository. The name is not case sensitive.

repo
required
string

The name of the repository without the .git extension. The name is not case sensitive.

Media type application/json
object
title

A name for the key.

string
key
required

The contents of the key.

string
read_only

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

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

Response

Media type application/json
Deploy Key

An SSH key granting access to a single repository.

object
id
required
integer
key
required
string
url
required
string
title
required
string
verified
required
boolean
created_at
required
string
read_only
required
boolean
added_by
string
nullable
last_used
string format: date-time
nullable
enabled
boolean
Examples
Example default
{
"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,
"added_by": "octocat",
"last_used": "2022-01-10T15:53:42Z",
"enabled": true
}
Location
string
Example
https://api.github.com/repos/octocat/Hello-World/keys/1

Validation failed, or the endpoint has been spammed.

Media type application/json
Validation Error

Validation Error

object
message
required
string
documentation_url
required
string
errors
Array<object>
object
resource
string
field
string
message
string
code
required
string
index
integer
value
One of:
string
nullable
Example generated
{
"message": "example",
"documentation_url": "example",
"errors": [
{
"resource": "example",
"field": "example",
"message": "example",
"code": "example",
"index": 1,
"value": [
"example"
]
}
]
}