Skip to main content

keys

Creates, updates, deletes, gets or lists a keys resource.

Overview

Namekeys
TypeResource
Idgithub.users.keys

Fields

The following fields are returned by SELECT queries:

Response

NameDatatypeDescription
idinteger (int64)
created_atstring (date-time)
keystring
last_usedstring (date-time)
read_onlyboolean
titlestring
urlstring
verifiedboolean

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
get_public_ssh_key_for_authenticated_userselectkey_idView 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.
list_public_keys_for_userselectusernameper_page, pageLists the verified public SSH keys for a user. This is accessible by anyone.
list_public_ssh_keys_for_authenticated_userselectper_page, pageLists 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.
create_public_ssh_key_for_authenticated_userinsertkeyAdds 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.
delete_public_ssh_key_for_authenticated_userdeletekey_idRemoves 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

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
key_idintegerThe unique identifier of the key.
usernamestringThe handle for the GitHub user account.
pageintegerThe page number of the results to fetch. For more information, see "Using pagination in the REST API."
per_pageintegerThe number of results per page (max 100). For more information, see "Using pagination in the REST API."

SELECT examples

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.

SELECT
id,
created_at,
key,
last_used,
read_only,
title,
url,
verified
FROM github.users.keys
WHERE key_id = '{{ key_id }}' -- required
;

INSERT examples

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.

INSERT INTO github.users.keys (
title,
key
)
SELECT
'{{ title }}',
'{{ key }}' /* required */
RETURNING
id,
created_at,
key,
last_used,
read_only,
title,
url,
verified
;

DELETE examples

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.

DELETE FROM github.users.keys
WHERE key_id = '{{ key_id }}' --required
;