Skip to main content

pat_grants

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

Overview

Namepat_grants
TypeResource
Idgithub.orgs.pat_grants

Fields

The following fields are returned by SELECT queries:

Response

NameDatatypeDescription
idintegerUnique identifier of the fine-grained personal access token grant. The pat_id used to get details about an approved fine-grained personal access token.
token_idintegerUnique identifier of the user's token. This field can also be found in audit log events and the organization's settings for their PAT grants.
token_namestringThe name given to the user's token. This field can also be found in an organization's settings page for Active Tokens.
access_granted_atstringDate and time when the fine-grained personal access token was approved to access the organization.
ownerobjectA GitHub user. (title: Simple User)
permissionsobjectPermissions requested, categorized by type of permission.
repositories_urlstringURL to the list of repositories the fine-grained personal access token can access. Only follow when repository_selection is subset.
repository_selectionstringType of repository selection requested. (none, all, subset)
token_expiredbooleanWhether the associated fine-grained personal access token has expired.
token_expires_atstringDate and time when the associated fine-grained personal access token expires.
token_last_used_atstringDate and time when the associated fine-grained personal access token was last used for authentication.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
list_pat_grantsselectorgper_page, page, sort, direction, owner, repository, permission, last_used_before, last_used_after, token_idLists approved fine-grained personal access tokens owned by organization members that can access organization resources.

Only GitHub Apps can use this endpoint.
update_pat_accessesexecorg, action, pat_idsUpdates the access organization members have to organization resources via fine-grained personal access tokens. Limited to revoking a token's existing access.

Only GitHub Apps can use this endpoint.
update_pat_accessexecorg, pat_id, actionUpdates the access an organization member has to organization resources via a fine-grained personal access token. Limited to revoking the token's existing access. Limited to revoking a token's existing access.

Only GitHub Apps can 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
orgstringThe organization name. The name is not case sensitive.
pat_idintegerThe unique identifier of the fine-grained personal access token.
directionstringThe direction to sort the results by.
last_used_afterstring (date-time)Only show fine-grained personal access tokens used after the given time. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.
last_used_beforestring (date-time)Only show fine-grained personal access tokens used before the given time. This is a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ.
ownerarrayA list of owner usernames to use to filter the results.
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."
permissionstringThe permission to use to filter the results.
repositorystringThe name of the repository to use to filter the results.
sortstringThe property by which to sort the results.
token_idarrayThe ID of the token

SELECT examples

Lists approved fine-grained personal access tokens owned by organization members that can access organization resources.

Only GitHub Apps can use this endpoint.

SELECT
id,
token_id,
token_name,
access_granted_at,
owner,
permissions,
repositories_url,
repository_selection,
token_expired,
token_expires_at,
token_last_used_at
FROM github.orgs.pat_grants
WHERE org = '{{ org }}' -- required
AND per_page = '{{ per_page }}'
AND page = '{{ page }}'
AND sort = '{{ sort }}'
AND direction = '{{ direction }}'
AND owner = '{{ owner }}'
AND repository = '{{ repository }}'
AND permission = '{{ permission }}'
AND last_used_before = '{{ last_used_before }}'
AND last_used_after = '{{ last_used_after }}'
AND token_id = '{{ token_id }}'
;

Lifecycle Methods

Updates the access organization members have to organization resources via fine-grained personal access tokens. Limited to revoking a token's existing access.

Only GitHub Apps can use this endpoint.

EXEC github.orgs.pat_grants.update_pat_accesses 
@org='{{ org }}' --required
@@json=
'{
"action": "{{ action }}",
"pat_ids": "{{ pat_ids }}"
}'
;