Use the REST API to manage Git SSH keys of authenticated users.
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.
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.
accept (string)application/vnd.github+json is recommended.per_page (integer)
The number of results per page (max 100). For more information, see "Using pagination in the REST API."
Default: 30
page (integer)
The page number of the results to fetch. For more information, see "Using pagination in the REST API."
Default: 1
200 - OK
304 - Not modified
401 - Requires authentication
403 - Forbidden
404 - Resource not found
Request:
curl -L \
-X GET \
https://api.github.com/user/keys
Response schema (Status: 200):
Array of Key:
key: required, stringid: required, integer, format: int64url: required, stringtitle: required, stringcreated_at: required, string, format: date-timeverified: required, booleanread_only: required, booleanlast_used: string or null, format: date-timePOST /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.
accept (string)application/vnd.github+json is recommended.title (string)
A descriptive name for the new key.
key (string) (required)
The public SSH key to add to your GitHub account.
201 - Created
304 - Not modified
401 - Requires authentication
403 - Forbidden
404 - Resource not found
422 - Validation failed, or the endpoint has been spammed.
Request:
curl -L \
-X POST \
https://api.github.com/user/keys \
-d '{
"title": "ssh-rsa AAAAB3NzaC1yc2EAAA",
"key": "2Sg8iYjAxxmI2LvUXpJjkYrMxURPc8r+dB7TJyvv1234"
}'
Response schema (Status: 201):
key: required, stringid: required, integer, format: int64url: required, stringtitle: required, stringcreated_at: required, string, format: date-timeverified: required, booleanread_only: required, booleanlast_used: string or null, format: date-timeGET /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.
accept (string)application/vnd.github+json is recommended.key_id (integer) (required)200 - OK
304 - Not modified
401 - Requires authentication
403 - Forbidden
404 - Resource not found
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 /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.
accept (string)application/vnd.github+json is recommended.key_id (integer) (required)204 - No Content
304 - Not modified
401 - Requires authentication
403 - Forbidden
404 - Resource not found
Request:
curl -L \
-X DELETE \
https://api.github.com/user/keys/KEY_ID
Response schema (Status: 204):
GET /users/{username}/keys
Lists the verified public SSH keys for a user. This is accessible by anyone.
accept (string)application/vnd.github+json is recommended.username (string) (required)
The handle for the GitHub user account.
per_page (integer)
The number of results per page (max 100). For more information, see "Using pagination in the REST API."
Default: 30
page (integer)
The page number of the results to fetch. For more information, see "Using pagination in the REST API."
Default: 1
Request:
curl -L \
-X GET \
https://api.github.com/users/USERNAME/keys
Response schema (Status: 200):
Array of Key Simple:
id: required, integerkey: required, stringcreated_at: string, format: date-timelast_used: string or null, format: date-time