POST/user/keys

Create a public SSH key for the authenticated user

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.

  • IdempotentThe SDK sends Idempotency-Key, so a retried request is only applied once.

2 body fields
titlestringoptional
A descriptive name for the new key.
keystringrequired
The public SSH key to add to your GitHub account.

6 status codes
201Response
keystringrequired
idintegerrequired
urlstringrequired
titlestringrequired
created_atstringrequired
verifiedbooleanrequired
read_onlybooleanrequired
last_usedstringoptional
304Not modified
401Requires authentication
messagestringoptional
documentation_urlstringoptional
urlstringoptional
statusstringoptional
403Forbidden
messagestringoptional
documentation_urlstringoptional
urlstringoptional
statusstringoptional
404Resource not found
messagestringoptional
documentation_urlstringoptional
urlstringoptional
statusstringoptional
422Validation failed, or the endpoint has been spammed.
messagestringrequired
documentation_urlstringrequired
errorsarray<object>optional

Error handling

A 401 is returned: Requires authentication. A 403 is returned: Forbidden. A 404 is returned: Resource not found. A 422 is returned: Validation failed, or the endpoint has been spammed.