PubSubHubbub

GitHub can also serve as a PubSubHubbub hub for all repositories. PSHB is a simple publish/subscribe protocol that lets servers register to receive updates when a topic is updated. The updates are sent with an HTTP POST request to a callback URL. Topic URLs for a GitHub repository's pushes are in this format:

https://github.com/:owner/:repo/events/:event

The event can be any event string that is listed at the top of this document.

Response format

The default format is what existing post-receive hooks should expect: A JSON body sent as the payload parameter in a POST. You can also specify to receive the raw JSON body with either an Accept header, or a .json extension.

Accept: application/json
https://github.com/:owner/:repo/events/push.json

Callback URLs

Callback URLs can use the http:// protocol. You can also github:// callbacks to specify a GitHub service.

Note: GitHub Enterprise release 2.17 and higher no longer allows admins to install new GitHub Services, and existing services will stop working in GitHub Enterprise release 2.20 and higher. You can use the Replacing GitHub Services guide to help you update your services to webhooks.

# Send updates to postbin.org
http://postbin.org/123
# Send updates to Campfire
github://campfire?subdomain=github&room=Commits&token=abc123

Subscribing

The GitHub PubSubHubbub endpoint is: http(s)://[hostname]/api/v3/hub. A successful request with curl looks like:

curl -u "user" -i \
  http(s)://[hostname]/api/v3/hub \
  -F "hub.mode=subscribe" \
  -F "hub.topic=https://github.com/:owner/:repo/events/push" \
  -F "hub.callback=http://postbin.org/123"

PubSubHubbub requests can be sent multiple times. If the hook already exists, it will be modified according to the request.

Parameters

Name Type Description
hub.mode string Required. Either subscribe or unsubscribe.
hub.topic string Required. The URI of the GitHub repository to subscribe to. The path must be in the format of /:owner/:repo/events/:event.
hub.callback string The URI to receive the updates to the topic.
hub.secret string A shared secret key that generates a SHA1 HMAC of the outgoing body content. You can verify a push came from GitHub by comparing the raw request body with the contents of the X-Hub-Signature header. You can see the PubSubHubbub documentation for more details.