Webhooks

Webhooks allow you to build or set up integrations which subscribe to certain events on GitHub.com. When one of those events is triggered, we’ll send a HTTP POST payload to the webhook’s configured URL. Webhooks can be used to update an external issue tracker, trigger CI builds, update a backup mirror, or even deploy to your production server. You’re only limited by your imagination.

Each webhook can be installed on an organization or a specific repository. Once installed, they will be triggered each time one or more subscribed events occurs on that organization or repository.

Events

When configuring a webhook, you can choose which events you would like to receive payloads for. You can even opt-in to all current and future events. Only subscribing to the specific events you plan on handling is useful for limiting the number of HTTP requests to your server. You can change the list of subscribed events through the API or UI anytime. By default, webhooks are only subscribed to the push event.

Each event corresponds to a certain set of actions that can happen to your organization and/or repository. For example, if you subscribe to the issues event you’ll receive detailed payloads every time an issue is opened, closed, labeled, etc.

The available events are:

Name Description
* Any time any event is triggered (Wildcard Event).
commit_comment Any time a Commit is commented on.
create Any time a Branch or Tag is created.
delete Any time a Branch or Tag is deleted.
deployment Any time a Repository has a new deployment created from the API.
deployment_status Any time a deployment for a Repository has a status update from the API.
fork Any time a Repository is forked.
gollum Any time a Wiki page is updated.
issue_comment Any time an Issue is commented on.
issues Any time an Issue is assigned, unassigned, labeled, unlabeled, opened, closed, or reopened.
member Any time a User is added as a collaborator to a non-Organization Repository.
membership Any time a User is added or removed from a team. Organization hooks only.
page_build Any time a Pages site is built or results in a failed build.
public Any time a Repository changes from private to public.
pull_request_review_comment Any time a Commit is commented on while inside a Pull Request review (the Files Changed tab).
pull_request Any time a Pull Request is assigned, unassigned, labeled, unlabeled, opened, closed, reopened, or synchronized (updated due to a new push in the branch that the pull request is tracking).
push Any Git push to a Repository, including editing tags or branches. Commits via API actions that update references are also counted. This is the default event.
repository Any time a Repository is created. Organization hooks only.
release Any time a Release is published in a Repository.
status Any time a Repository has a status update from the API
team_add Any time a team is added or modified on a Repository.
watch Any time a User watches a Repository.

Wildcard Event

We also support a wildcard (*) that will match all supported events. When you add the wildcard event, we’ll replace any existing events you have configured with the wildcard event and send you payloads for all supported events. You’ll also automatically get any new events we might add in the future.

Payloads

Each event type has a specific payload format with the relevant event information. All event payloads mirror the payloads for the Event types, with the exception of the original push event, which has a more detailed webhook payload.

In addition to the fields documented for each event, webhook payloads include the user who performed the event (sender) as well as the organization (organization) and/or repository (repository) which the event occurred on.

Delivery headers

HTTP requests made to your webhook’s configured URL endpoint will contain several special headers:

Header Description
X-Github-Event Name of the event that triggered this delivery.
X-Hub-Signature HMAC hex digest of the payload, using the hook’s secret as the key (if configured).
X-Github-Delivery Unique ID for this delivery.

Also, the User-Agent for the requests will have the prefix GitHub-Hookshot/.

Example delivery

POST /payload HTTP/1.1

Host: localhost:4567
X-Github-Delivery: 72d3162e-cc78-11e3-81ab-4c9367dc0958
User-Agent: GitHub-Hookshot/044aadd
Content-Type: application/json
Content-Length: 6615
X-Github-Event: issues

{
  "action": "opened",
  "issue": {
    "url": "https://api.github.com/repos/octocat/Hello-World/issues/1347",
    "number": 1347,
    ...
  },
  "repository" : {
    "id": 1296269,
    "full_name": "octocat/Hello-World",
    "owner": {
      "login": "octocat",
      "id": 1,
      ...
    },
    ...
  },
  "sender": {
    "login": "octocat",
    "id": 1,
    ...
  }
}

Ping Event

When you create a new webhook, we’ll send you a simple ping event to let you know you’ve set up the webhook correctly. This event isn’t stored so it isn’t retrievable via the Events API. You can trigger a ping again by calling the ping endpoint.

Ping Event Payload

Key Value
zen Random string of GitHub zen
hook_id The ID of the webhook that triggered the ping
hook The webhook configuration

Service Hooks

In addition to webhooks, we also offer the ability to install pre-rolled integrations for a variety of existing services. These services are contributed and maintained by the Open Source community.

Service hooks are installed and configured in a similar fashion as webhooks. When creating a hook, just set the :name parameter to a service name instead of “web” (for webhook). The main differences to keep in mind between webhooks and service hooks are:

To see a full list of available services, their supported events, and configuration options, check out https://api.github.com/hooks. Documentation for all service hooks can be found in the docs directory of the github-services repository.

Note: If you are building a new integration, you should build it as webhook. We suggest creating an OAuth application to automatically install and manage your users’ webhooks. We will no longer be accepting new services to the github-services repository.