Webhooks

Webhooks allow you to build or set up GitHub Apps 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.

You can create up to 20 webhooks for each event on each installation target (specific organization or specific 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.
installation Any time a GitHub App is installed or uninstalled.
installation_repositories Any time a repository is added or removed from an installation.
issue_comment Any time a comment on an issue is created, edited, or deleted.
issues Any time an Issue is assigned, unassigned, labeled, unlabeled, opened, edited, milestoned, demilestoned, closed, or reopened.
label Any time a Label is created, edited, or deleted.
marketplace_purchase Any time a user purchases, cancels, or changes their GitHub Marketplace plan.
member Any time a User is added or removed as a collaborator to a Repository, or has their permissions modified.
membership Any time a User is added or removed from a team. Organization hooks only.
milestone Any time a Milestone is created, closed, opened, edited, or deleted.
organization Any time a user is added, removed, or invited to an Organization. Organization hooks only.
org_block Any time an organization blocks or unblocks a user. Organization hooks only.
page_build Any time a Pages site is built or results in a failed build.
project_card Any time a Project Card is created, edited, moved, converted to an issue, or deleted.
project_column Any time a Project Column is created, edited, moved, or deleted.
project Any time a Project is created, edited, closed, reopened, or deleted.
public Any time a Repository changes from private to public.
pull_request_review_comment Any time a comment on a pull request's unified diff is created, edited, or deleted (in the Files Changed tab).
pull_request_review Any time a pull request review is submitted, edited, or dismissed.
pull_request Any time a pull request is assigned, unassigned, labeled, unlabeled, opened, edited, closed, reopened, or synchronized (updated due to a new push in the branch that the pull request is tracking). Also any time a pull request review is requested, or a review request is removed.
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, deleted (organization hooks only), made public, or made private.
release Any time a Release is published in a Repository.
status Any time a Repository has a status update from the API
team Any time a team is created, deleted, modified, or added to or removed from a repository. Organization hooks only
team_add Any time a team is added or modified on a Repository.
watch Any time a User stars a Repository.

Note: The following parameters are deprecated and will be removed on November 22, 2017:

Deprecated event Replaced by
integration_installation installation
integration_installation_repositories installation_repositories

If you're writing new API client code (or updating your existing code), use the replacement event names. The replacement objects contain the same information as the deprecated events.

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, and for a GitHub App's webhook may include the installation (installation) which an event relates to. An example is given in the PullRequestEvent payload.

Note: Payloads are capped at 5 MB. If your event generates a larger payload, a webhook will not be fired. This may happen, for example, on a create event if many branches or tags are pushed at once. We suggest monitoring your payload size to ensure delivery.

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

GitHub Apps

When you register a new GitHub App, GitHub sends a ping event to the webhook URL you specified during registration. The event contains the app_id (formerly the integration_id), which is required for authenticating an app. For example:

{
  "hook":{
    "type":"App",
    "id":11,
    "active":true,
    "events":["pull_request"],
    "app_id":37,
    ...
  }
}

Deprecation notice: integration_id

Note: The integration_id parameter, formerly used in the ping event above, is deprecated and will be removed on November 22, 2017.

Deprecated event Replaced by
integration_id app_id

If you're writing new API client code (or updating your existing code), use app_id instead of integration_id. The app_id object contains the same information as integration_id.