Skip to main content

gpg_keys

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

Overview

Namegpg_keys
TypeResource
Idgithub.users.gpg_keys

Fields

The following fields are returned by SELECT queries:

Response

NameDatatypeDescription
idinteger (int64)
namestring (example: Octocat's GPG Key)
key_idstring (example: 3262EFF25BA0D270)
primary_key_idinteger
can_certifyboolean
can_encrypt_commsboolean
can_encrypt_storageboolean
can_signboolean
created_atstring (date-time) (example: 2016-03-24T11:31:04-06:00)
emailsarray
expires_atstring (date-time)
public_keystring (example: xsBNBFayYZ...)
raw_keystring
revokedboolean
subkeysarray

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
get_gpg_key_for_authenticated_userselectgpg_key_idView extended details for a single GPG key.

OAuth app tokens and personal access tokens (classic) need the read:gpg_key scope to use this endpoint.
list_gpg_keys_for_userselectusernameper_page, pageLists the GPG keys for a user. This information is accessible by anyone.
list_gpg_keys_for_authenticated_userselectper_page, pageLists the current user's GPG keys.

OAuth app tokens and personal access tokens (classic) need the read:gpg_key scope to use this endpoint.
create_gpg_key_for_authenticated_userinsertarmored_public_keyAdds a GPG key to the authenticated user's GitHub account.

OAuth app tokens and personal access tokens (classic) need the write:gpg_key scope to use this endpoint.
delete_gpg_key_for_authenticated_userdeletegpg_key_idRemoves a GPG key from the authenticated user's GitHub account.

OAuth app tokens and personal access tokens (classic) need the admin:gpg_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
gpg_key_idintegerThe unique identifier of the GPG 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 GPG key.

OAuth app tokens and personal access tokens (classic) need the read:gpg_key scope to use this endpoint.

SELECT
id,
name,
key_id,
primary_key_id,
can_certify,
can_encrypt_comms,
can_encrypt_storage,
can_sign,
created_at,
emails,
expires_at,
public_key,
raw_key,
revoked,
subkeys
FROM github.users.gpg_keys
WHERE gpg_key_id = '{{ gpg_key_id }}' -- required
;

INSERT examples

Adds a GPG key to the authenticated user's GitHub account.

OAuth app tokens and personal access tokens (classic) need the write:gpg_key scope to use this endpoint.

INSERT INTO github.users.gpg_keys (
name,
armored_public_key
)
SELECT
'{{ name }}',
'{{ armored_public_key }}' /* required */
RETURNING
id,
name,
key_id,
primary_key_id,
can_certify,
can_encrypt_comms,
can_encrypt_storage,
can_sign,
created_at,
emails,
expires_at,
public_key,
raw_key,
revoked,
subkeys
;

DELETE examples

Removes a GPG key from the authenticated user's GitHub account.

OAuth app tokens and personal access tokens (classic) need the admin:gpg_key scope to use this endpoint.

DELETE FROM github.users.gpg_keys
WHERE gpg_key_id = '{{ gpg_key_id }}' --required
;