GitHub v3 REST API

Create a pre-receive hook

post
{protocol}://{hostname}/api/v3/admin/pre-receive-hooks

Body

application/json
namestringrequired

The name of the hook.

scriptstringrequired

The script that the hook runs.

script_repositoryobjectrequired

The GitHub repository where the script is kept.

* Additional properties are allowed.
environmentobjectrequired

The pre-receive environment where the script is executed.

* Additional properties are allowed.
enforcementstring

The state of enforcement for this hook. default: disabled

allow_downstream_configurationboolean

Whether enforcement can be overridden at the org or repo level. default: false

Response

201 application/json

Response

pre-receive-hook

idinteger
namestring
enforcementstring
scriptstring
script_repositoryobject
Show Child Parameters
environmentobject
Show Child Parameters
allow_downstream_configurationboolean
post/admin/pre-receive-hooks

Body

{ "name": "Check Commits", "script": "scripts/commit_check.sh", "enforcement": "disabled", "allow_downstream_configuration": false, "script_repository": { "full_name": "DevIT/hooks" }, "environment": { "id": 2 } }
 
201 application/json

Get a pre-receive hook

get
{protocol}://{hostname}/api/v3/admin/pre-receive-hooks/{pre_receive_hook_id}

Path Parameters

pre_receive_hook_idintegerrequired

pre_receive_hook_id parameter

Response

200 application/json

Response

pre-receive-hook

idinteger
namestring
enforcementstring
scriptstring
script_repositoryobject
Show Child Parameters
environmentobject
Show Child Parameters
allow_downstream_configurationboolean
get/admin/pre-receive-hooks/{pre_receive_hook_id}
 
200 application/json

Update a pre-receive hook

patch
{protocol}://{hostname}/api/v3/admin/pre-receive-hooks/{pre_receive_hook_id}

Path Parameters

pre_receive_hook_idintegerrequired

pre_receive_hook_id parameter

Body

application/json
namestring

The name of the hook.

scriptstring

The script that the hook runs.

script_repositoryobject

The GitHub repository where the script is kept.

* Additional properties are allowed.
environmentobject

The pre-receive environment where the script is executed.

* Additional properties are allowed.
enforcementstring

The state of enforcement for this hook.

allow_downstream_configurationboolean

Whether enforcement can be overridden at the org or repo level.

Response

200 application/json

Response

pre-receive-hook

idinteger
namestring
enforcementstring
scriptstring
script_repositoryobject
Show Child Parameters
environmentobject
Show Child Parameters
allow_downstream_configurationboolean
patch/admin/pre-receive-hooks/{pre_receive_hook_id}

Body

{ "name": "Check Commits", "environment": { "id": 1 }, "allow_downstream_configuration": true }
 
200 application/json

Delete a pre-receive hook

delete
{protocol}://{hostname}/api/v3/admin/pre-receive-hooks/{pre_receive_hook_id}

Path Parameters

pre_receive_hook_idintegerrequired

pre_receive_hook_id parameter

Response

204

Response

delete/admin/pre-receive-hooks/{pre_receive_hook_id}
 
204

List personal access tokens

Lists personal access tokens for all users, including admin users.

get
{protocol}://{hostname}/api/v3/admin/tokens

Query Parameters

per_pageinteger

Results per page (max 100)

Default:30

pageinteger

Page number of the results to fetch.

Default:1

Response

200 application/json

Response

The authorization for an OAuth app, GitHub App, or a Personal Access Token.

idintegerrequired
urlstring(uri)required
scopesarray | null[string]required

A list of scopes that this authorization is in.

tokenstringrequired
token_last_eightstring | nullrequired
hashed_tokenstring | nullrequired
appobjectrequired
Show Child Parameters
notestring | nullrequired
note_urlstring | null(uri)required
updated_atstring(date-time)required
created_atstring(date-time)required
fingerprintstring | nullrequired
userobject | null

Simple User

Show Child Parameters
installationobject | null
Show Child Parameters
get/admin/tokens
 
200 application/json