GitHub v3 REST API

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

Delete a personal access token

Deletes a personal access token. Returns a 403 - Forbidden status when a personal access token is in use. For example, if you access this endpoint with the same personal access token that you are trying to delete, you will receive this error.

delete
{protocol}://{hostname}/api/v3/admin/tokens/{token_id}

Path Parameters

token_idintegerrequired

Response

204

Response

delete/admin/tokens/{token_id}
 
204

Create a user

If an external authentication mechanism is used, the login name should match the login name in the external system. If you are using LDAP authentication, you should also update the LDAP mapping for the user.

The login name will be normalized to only contain alphanumeric characters or single hyphens. For example, if you send "octo_cat" as the login, a user named "octo-cat" will be created.

If the login name or email address is already associated with an account, the server will return a 422 response.

post
{protocol}://{hostname}/api/v3/admin/users

Body

application/json
loginstringrequired

The user’s username.

emailstring

Required for built-in authentication. The user’s email address. This parameter can be omitted when using CAS, LDAP, or SAML. For details on built-in and centrally-managed authentication, see the the GitHub authentication guide.

Response

201 application/json

Response

Simple User

Simple User

namestring | null
emailstring | null
loginstringrequired

Example:octocat

idintegerrequired

Example:1

node_idstringrequired

Example:MDQ6VXNlcjE=

avatar_urlstring(uri)required

Example:https://github.com/images/error/octocat_happy.gif

gravatar_idstring | nullrequired

Example:41d064eb2195891e12d0413f63227ea7

urlstring(uri)required

Example:https://api.github.com/users/octocat

html_urlstring(uri)required

Example:https://github.com/octocat

followers_urlstring(uri)required

Example:https://api.github.com/users/octocat/followers

following_urlstringrequired

Example:https://api.github.com/users/octocat/following{/other_user}

gists_urlstringrequired

Example:https://api.github.com/users/octocat/gists{/gist_id}

starred_urlstringrequired

Example:https://api.github.com/users/octocat/starred{/owner}{/repo}

subscriptions_urlstring(uri)required

Example:https://api.github.com/users/octocat/subscriptions

organizations_urlstring(uri)required

Example:https://api.github.com/users/octocat/orgs

repos_urlstring(uri)required

Example:https://api.github.com/users/octocat/repos

events_urlstringrequired

Example:https://api.github.com/users/octocat/events{/privacy}

received_events_urlstring(uri)required

Example:https://api.github.com/users/octocat/received_events

typestringrequired

Example:User

site_adminbooleanrequired
starred_atstring

Example:"2020-07-09T00:17:55Z"

post/admin/users

Body

{ "login": "monalisa", "email": "octocat@github.com" }
 
201 application/json