REST API endpoints for Git SSH keys

Use the REST API to manage Git SSH keys of authenticated users.

About Git SSH key administration

If a request URL does not include a {username} parameter then the response will be for the signed-in user (and you must pass authentication information with your request). Additional private information, such as whether a user has two-factor authentication enabled, is included when authenticated through OAuth with the user scope.

Note

Most endpoints use Authorization: Bearer <YOUR-TOKEN> and Accept: application/vnd.github+json headers, plus X-GitHub-Api-Version: 2026-03-10. Curl examples below omit these standard headers for brevity.

List public SSH keys for the authenticated user

GET /user/keys

Lists the public SSH keys for the authenticated user's GitHub account.
OAuth app tokens and personal access tokens (classic) need the read:public_key scope to use this endpoint.

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X GET \
  https://api.github.com/user/keys

Response schema (Status: 200):

Array of Key:

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.

Parameters

Headers

Body parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X POST \
  https://api.github.com/user/keys \
  -d '{
  "title": "ssh-rsa AAAAB3NzaC1yc2EAAA",
  "key": "2Sg8iYjAxxmI2LvUXpJjkYrMxURPc8r+dB7TJyvv1234"
}'

Response schema (Status: 201):

Get a public SSH key for the authenticated user

GET /user/keys/{key_id}

View extended details for a single public SSH key.
OAuth app tokens and personal access tokens (classic) need the read:public_key scope to use this endpoint.

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X GET \
  https://api.github.com/user/keys/KEY_ID

Response schema (Status: 200):

Same response schema as Create a public SSH key for the authenticated user.

Delete a public SSH key for the authenticated user

DELETE /user/keys/{key_id}

Removes a public SSH key from the authenticated user's GitHub account.
OAuth app tokens and personal access tokens (classic) need the admin:public_key scope to use this endpoint.

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X DELETE \
  https://api.github.com/user/keys/KEY_ID

Response schema (Status: 204):

List public keys for a user

GET /users/{username}/keys

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

Parameters

Headers

Path and query parameters

HTTP response status codes

Code examples

Example

Request:

curl -L \
  -X GET \
  https://api.github.com/users/USERNAME/keys

Response schema (Status: 200):

Array of Key Simple: