Create a public SSH key for the authenticated user
POST
/user/keys
Adds a public SSH key to the authenticated user’s GitHub account.
OAuth app tokens and personal access tokens (classic) need the write:public_key scope to use this endpoint.
Request Body required
Section titled “ Request Body required ” Media type application/json
object
title
A descriptive name for the new key.
string
key
required
The public SSH key to add to your GitHub account.
string
Examples
Example default
{ "title": "ssh-rsa AAAAB3NzaC1yc2EAAA", "key": "2Sg8iYjAxxmI2LvUXpJjkYrMxURPc8r+dB7TJyvv1234"}Responses
Section titled “ Responses ”Response
Media type application/json
Key
Key
object
key
required
string
id
required
integer format: int64
url
required
string
title
required
string
created_at
required
string format: date-time
verified
required
boolean
read_only
required
boolean
last_used
string format: date-time
Examples
Example default
{ "key": "2Sg8iYjAxxmI2LvUXpJjkYrMxURPc8r+dB7TJyvv1234", "id": 2, "url": "https://api.github.com/user/keys/2", "title": "ssh-rsa AAAAB3NzaC1yc2EAAA", "created_at": "2020-06-11T21:31:57Z", "verified": false, "read_only": false}Not modified
Requires authentication
Media type application/json
Basic Error
Basic Error
object
message
string
documentation_url
string
url
string
status
string
Example generated
{ "message": "example", "documentation_url": "example", "url": "example", "status": "example"}Forbidden
Media type application/json
Basic Error
Basic Error
object
message
string
documentation_url
string
url
string
status
string
Example generated
{ "message": "example", "documentation_url": "example", "url": "example", "status": "example"}Resource not found
Media type application/json
Basic Error
Basic Error
object
message
string
documentation_url
string
url
string
status
string
Example generated
{ "message": "example", "documentation_url": "example", "url": "example", "status": "example"}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
integer
Array<string>
Example generated
{ "message": "example", "documentation_url": "example", "errors": [ { "resource": "example", "field": "example", "message": "example", "code": "example", "index": 1, "value": [ "example" ] } ]}