keys
Creates, updates, deletes, gets or lists a keys resource.
Overview
| Name | keys |
| Type | Resource |
| Id | github.users.keys |
Fields
The following fields are returned by SELECT queries:
- get_public_ssh_key_for_authenticated_user
- list_public_keys_for_user
- list_public_ssh_keys_for_authenticated_user
Response
| Name | Datatype | Description |
|---|---|---|
id | integer (int64) | |
created_at | string (date-time) | |
key | string | |
last_used | string (date-time) | |
read_only | boolean | |
title | string | |
url | string | |
verified | boolean |
Response
| Name | Datatype | Description |
|---|---|---|
id | integer | |
created_at | string (date-time) | |
key | string | |
last_used | string (date-time) |
Response
| Name | Datatype | Description |
|---|---|---|
id | integer (int64) | |
created_at | string (date-time) | |
key | string | |
last_used | string (date-time) | |
read_only | boolean | |
title | string | |
url | string | |
verified | boolean |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
get_public_ssh_key_for_authenticated_user | select | 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. | |
list_public_keys_for_user | select | username | per_page, page | Lists the verified public SSH keys for a user. This is accessible by anyone. |
list_public_ssh_keys_for_authenticated_user | select | per_page, page | 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. | |
create_public_ssh_key_for_authenticated_user | insert | key | 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. | |
delete_public_ssh_key_for_authenticated_user | delete | 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
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.
| Name | Datatype | Description |
|---|---|---|
key_id | integer | The unique identifier of the key. |
username | string | The handle for the GitHub user account. |
page | integer | The page number of the results to fetch. For more information, see "Using pagination in the REST API." |
per_page | integer | The number of results per page (max 100). For more information, see "Using pagination in the REST API." |
SELECT examples
- get_public_ssh_key_for_authenticated_user
- list_public_keys_for_user
- list_public_ssh_keys_for_authenticated_user
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
;
Lists the verified public SSH keys for a user. This is accessible by anyone.
SELECT
id,
created_at,
key,
last_used
FROM github.users.keys
WHERE username = '{{ username }}' -- required
AND per_page = '{{ per_page }}'
AND page = '{{ page }}'
;
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.
SELECT
id,
created_at,
key,
last_used,
read_only,
title,
url,
verified
FROM github.users.keys
WHERE per_page = '{{ per_page }}'
AND page = '{{ page }}'
;
INSERT examples
- create_public_ssh_key_for_authenticated_user
- Manifest
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
;
# Description fields are for documentation purposes
- name: keys
props:
- name: title
value: "{{ title }}"
description: |
A descriptive name for the new key.
- name: key
value: "{{ key }}"
description: |
The public SSH key to add to your GitHub account.
DELETE examples
- delete_public_ssh_key_for_authenticated_user
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
;