Skip to main content

webhooks

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

Overview

Namewebhooks
TypeResource
Idgithub.orgs.webhooks

Fields

The following fields are returned by SELECT queries:

Response

NameDatatypeDescription
idinteger
namestring (example: web)
activeboolean
configobject
created_atstring (date-time) (example: 2011-09-06T17:26:27Z)
deliveries_urlstring (uri) (example: https://api.github.com/orgs/octocat/hooks/1/deliveries)
eventsarray
ping_urlstring (uri) (example: https://api.github.com/orgs/octocat/hooks/1/pings)
typestring
updated_atstring (date-time) (example: 2011-09-06T20:39:23Z)
urlstring (uri) (example: https://api.github.com/orgs/octocat/hooks/1)

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
get_webhookselectorg, hook_idReturns a webhook configured in an organization. To get only the webhook
config properties, see "Get a webhook configuration for an organization.

You must be an organization owner to use this endpoint.

OAuth app tokens and personal access tokens (classic) need admin:org_hook scope. OAuth apps cannot list, view, or edit
webhooks that they did not create and users cannot list, view, or edit webhooks that were created by OAuth apps.
list_webhooksselectorgper_page, pageList webhooks for an organization.

The authenticated user must be an organization owner to use this endpoint.

OAuth app tokens and personal access tokens (classic) need admin:org_hook scope. OAuth apps cannot list, view, or edit
webhooks that they did not create and users cannot list, view, or edit webhooks that were created by OAuth apps.
create_webhookinsertorg, name, configCreate a hook that posts payloads in JSON format.

You must be an organization owner to use this endpoint.

OAuth app tokens and personal access tokens (classic) need admin:org_hook scope. OAuth apps cannot list, view, or
edit webhooks that they did not create and users cannot list, view, or edit webhooks that were created by OAuth apps.
update_webhookupdateorg, hook_idUpdates a webhook configured in an organization. When you update a webhook,
the secret will be overwritten. 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 an organization
".

You must be an organization owner to use this endpoint.

OAuth app tokens and personal access tokens (classic) need admin:org_hook scope. OAuth apps cannot list, view, or edit
webhooks that they did not create and users cannot list, view, or edit webhooks that were created by OAuth apps.
delete_webhookdeleteorg, hook_idDelete a webhook for an organization.

The authenticated user must be an organization owner to use this endpoint.

OAuth app tokens and personal access tokens (classic) need admin:org_hook scope. OAuth apps cannot list, view, or edit
webhooks that they did not create and users cannot list, view, or edit webhooks that were created by OAuth apps.
ping_webhookexecorg, hook_idThis will trigger a ping event
to be sent to the hook.

You must be an organization owner to use this endpoint.

OAuth app tokens and personal access tokens (classic) need admin:org_hook scope. OAuth apps cannot list, view, or edit
webhooks that they did not create and users cannot list, view, or edit webhooks that were created by OAuth apps.

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.
orgstringThe organization name. 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 an organization. To get only the webhook
config properties, see "Get a webhook configuration for an organization.

You must be an organization owner to use this endpoint.

OAuth app tokens and personal access tokens (classic) need admin:org_hook scope. OAuth apps cannot list, view, or edit
webhooks that they did not create and users cannot list, view, or edit webhooks that were created by OAuth apps.

SELECT
id,
name,
active,
config,
created_at,
deliveries_url,
events,
ping_url,
type,
updated_at,
url
FROM github.orgs.webhooks
WHERE org = '{{ org }}' -- required
AND hook_id = '{{ hook_id }}' -- required
;

INSERT examples

Create a hook that posts payloads in JSON format.

You must be an organization owner to use this endpoint.

OAuth app tokens and personal access tokens (classic) need admin:org_hook scope. OAuth apps cannot list, view, or
edit webhooks that they did not create and users cannot list, view, or edit webhooks that were created by OAuth apps.

INSERT INTO github.orgs.webhooks (
name,
config,
events,
active,
org
)
SELECT
'{{ name }}' /* required */,
'{{ config }}' /* required */,
'{{ events }}',
{{ active }},
'{{ org }}'
RETURNING
id,
name,
active,
config,
created_at,
deliveries_url,
events,
ping_url,
type,
updated_at,
url
;

UPDATE examples

Updates a webhook configured in an organization. When you update a webhook,
the secret will be overwritten. 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 an organization
".

You must be an organization owner to use this endpoint.

OAuth app tokens and personal access tokens (classic) need admin:org_hook scope. OAuth apps cannot list, view, or edit
webhooks that they did not create and users cannot list, view, or edit webhooks that were created by OAuth apps.

UPDATE github.orgs.webhooks
SET
config = '{{ config }}',
events = '{{ events }}',
active = {{ active }},
name = '{{ name }}'
WHERE
org = '{{ org }}' --required
AND hook_id = '{{ hook_id }}' --required
RETURNING
id,
name,
active,
config,
created_at,
deliveries_url,
events,
ping_url,
type,
updated_at,
url;

DELETE examples

Delete a webhook for an organization.

The authenticated user must be an organization owner to use this endpoint.

OAuth app tokens and personal access tokens (classic) need admin:org_hook scope. OAuth apps cannot list, view, or edit
webhooks that they did not create and users cannot list, view, or edit webhooks that were created by OAuth apps.

DELETE FROM github.orgs.webhooks
WHERE org = '{{ org }}' --required
AND hook_id = '{{ hook_id }}' --required
;

Lifecycle Methods

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

You must be an organization owner to use this endpoint.

OAuth app tokens and personal access tokens (classic) need admin:org_hook scope. OAuth apps cannot list, view, or edit
webhooks that they did not create and users cannot list, view, or edit webhooks that were created by OAuth apps.

EXEC github.orgs.webhooks.ping_webhook 
@org='{{ org }}' --required,
@hook_id='{{ hook_id }}' --required
;