Skip to main content

webhooks

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

Overview

Namewebhooks
TypeResource
Idgithub.repos.webhooks

Fields

The following fields are returned by SELECT queries:

Response

NameDatatypeDescription
idintegerUnique identifier of the webhook.
namestringThe name of a valid service, use 'web' for a webhook. (example: web)
activebooleanDetermines whether the hook is actually triggered on pushes.
configobjectConfiguration object of the webhook (title: Webhook Configuration)
created_atstring (date-time) (example: 2011-09-06T17:26:27Z)
deliveries_urlstring (uri) (example: https://api.github.com/repos/octocat/Hello-World/hooks/1/deliveries)
eventsarrayDetermines what events the hook is triggered for. Default: ['push'].
last_responseobject (title: Hook Response)
ping_urlstring (uri) (example: https://api.github.com/repos/octocat/Hello-World/hooks/1/pings)
test_urlstring (uri) (example: https://api.github.com/repos/octocat/Hello-World/hooks/1/test)
typestring
updated_atstring (date-time) (example: 2011-09-06T20:39:23Z)
urlstring (uri) (example: https://api.github.com/repos/octocat/Hello-World/hooks/1)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
get_webhookselectowner, repo, hook_idReturns a webhook configured in a repository. To get only the webhook config properties, see "Get a webhook configuration for a repository."
list_webhooksselectowner, repoper_page, pageLists webhooks for a repository. last response may return null if there have not been any deliveries within 30 days.
create_webhookinsertowner, repoRepositories can have multiple webhooks installed. Each webhook should have a unique config. Multiple webhooks can
share the same config as long as those webhooks do not have any events that overlap.
update_webhookupdateowner, repo, hook_idUpdates a webhook configured in a repository. If you previously had a secret set, you must provide the same secret or set a new secret or the secret will be removed. If you are only updating individual webhook config properties, use "Update a webhook configuration for a repository."
delete_webhookdeleteowner, repo, hook_idDelete a webhook for an organization.

The authenticated user must be a repository owner, or have admin access in the repository, to delete the webhook.
ping_webhookexecowner, repo, hook_idThis will trigger a ping event to be sent to the hook.
test_push_webhookexecowner, repo, hook_idThis will trigger the hook with the latest push to the current repository if the hook is subscribed to push events. If the hook is not subscribed to push events, the server will respond with 204 but no test POST will be generated.

> [!NOTE]
> Previously /repos/:owner/:repo/hooks/:hook_id/test

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
hook_idintegerThe unique identifier of the hook. You can find this value in the X-GitHub-Hook-ID header of a webhook delivery.
ownerstringThe account owner of the repository. The name is not case sensitive.
repostringThe name of the repository without the .git extension. The name is not case sensitive.
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

Returns a webhook configured in a repository. To get only the webhook config properties, see "Get a webhook configuration for a repository."

SELECT
id,
name,
active,
config,
created_at,
deliveries_url,
events,
last_response,
ping_url,
test_url,
type,
updated_at,
url
FROM github.repos.webhooks
WHERE owner = '{{ owner }}' -- required
AND repo = '{{ repo }}' -- required
AND hook_id = '{{ hook_id }}' -- required
;

INSERT examples

Repositories can have multiple webhooks installed. Each webhook should have a unique config. Multiple webhooks can
share the same config as long as those webhooks do not have any events that overlap.

INSERT INTO github.repos.webhooks (
name,
config,
events,
active,
owner,
repo
)
SELECT
'{{ name }}',
'{{ config }}',
'{{ events }}',
{{ active }},
'{{ owner }}',
'{{ repo }}'
RETURNING
id,
name,
active,
config,
created_at,
deliveries_url,
events,
last_response,
ping_url,
test_url,
type,
updated_at,
url
;

UPDATE examples

Updates a webhook configured in a repository. If you previously had a secret set, you must provide the same secret or set a new secret or the secret will be removed. If you are only updating individual webhook config properties, use "Update a webhook configuration for a repository."

UPDATE github.repos.webhooks
SET
config = '{{ config }}',
events = '{{ events }}',
add_events = '{{ add_events }}',
remove_events = '{{ remove_events }}',
active = {{ active }}
WHERE
owner = '{{ owner }}' --required
AND repo = '{{ repo }}' --required
AND hook_id = '{{ hook_id }}' --required
RETURNING
id,
name,
active,
config,
created_at,
deliveries_url,
events,
last_response,
ping_url,
test_url,
type,
updated_at,
url;

DELETE examples

Delete a webhook for an organization.

The authenticated user must be a repository owner, or have admin access in the repository, to delete the webhook.

DELETE FROM github.repos.webhooks
WHERE owner = '{{ owner }}' --required
AND repo = '{{ repo }}' --required
AND hook_id = '{{ hook_id }}' --required
;

Lifecycle Methods

This will trigger a ping event to be sent to the hook.

EXEC github.repos.webhooks.ping_webhook 
@owner='{{ owner }}' --required,
@repo='{{ repo }}' --required,
@hook_id='{{ hook_id }}' --required
;