[%# This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. # # This Source Code Form is | "Incompatible With Secondary Licenses", as # defined by the Mozilla Public License, v. 2.0. #%] [% PROCESS global/header.html.tmpl title = "Webhooks Documentation" style = "#bugzilla-body li { margin: 5px } h4 { margin-bottom: 0px } .heading { font-weight: bold } #main-inner{ margin-left: 20%; margin-right: 20%; margin-bottom: 5% } " %]

[% terms.Bugzilla %] Webhooks

A webhook is a custom callback defined by events. Is triggered when those events happen, and a POST request is sent to a defined URL.

In the case of [% terms.Bugzilla %], a webhook can be triggered by a change to, or creation of a [% terms.bug %]. The parameters of the [% terms.bug %] are exposed to the webhook handler which makes a callback (over HTTP) to another web application.

Examples of [% terms.Bugzilla %] webhooks could include:

Creating a webhook

To create a webhook follow the next steps:

  1. Access to your [% terms.Bugzilla %] Account.
  2. Go to your Preferences Panel > Webhooks.
  3. Fill out all of the parameters:
  4. Name

    A name for the webhook, which should be descriptive (e.g. “Jira Webhook for New & Updated [% terms.Bugs %] in Core::Graphics”)

    URL

    The URL which will receive and process the webhook.

    Events

    The [% terms.bug %] events that will trigger your new webhook.

    Filters

    Properties of a [% terms.bug %] that specify which [% terms.bugs %] you will receive.


  5. Add the webhook.

You can see your registered webhooks in the same panel.

If you want to delete a webhook, select the webhook in “Your webhooks” table and click remove selected. You can select more than one.

Delivered webhook

When a webhook is triggered the HTTP POST of a fixed JSON structure payload that is delivered contains the webhook_id, webhook_name and the information about the [% terms.bug %] that matches the event and filters.

If the [% terms.bug %] is private, only the [% terms.bug %] id and some other basic information is sent and the external system will need to query BMO over the REST API to get the actual details of the [% terms.bug %].

The webhooks will be called in the same order as the events triggering them and will be one request per new [% terms.bug %] and per changed [% terms.bug %]. The "changes" parameter will be sent only when the triggered event is changed and will content every change made in the [% terms.bug %].

Public [% terms.Bug %] Request

{ "webhook_id": 23, "webhook_name": "Example webhook", "event": { "action": "create", "time": "2020-07-24T20:11:22", "user": { "id": 1, "login": "admin@bmo.test", "real_name": "Vagrant User" }, "changes": [ { "field": "priority", "removed": "P3", "added": "P1" } ], }, "[% terms.bug %]": { "version": { "name": "unspecified", "id": 1 }, "qa_contact": null, "product": { "id": 1, "name": "TestProduct" }, "creation_time": "2020-07-23T00:01:45", "resolution": "", "flags": [], "classification": "Unclassified", "url": "", "type": "enhancement", "operating_system": "Linux", "keywords": [], "status": { "name": "CONFIRMED", "id": 2 }, "last_change_time": "2020-07-23T00:01:45", "is_private": false, "severity": "normal", "summary": "Test", "alias": "", "reporter": { "id": 1, "real_name": "Vagrant User", "login": "admin@bmo.test" }, "assigned_to": { "id": 1, "login": "admin@bmo.test", "real_name": "Vagrant User" }, "platform": "PC", "id": 11, "priority": "P1", "target_milestone": null, "cf_user_story": "", "cf_last_resolved": null, "whiteboard": "", "component": { "id": 2, "name": "TestComponent" } } }

Private [% terms.Bug %] Request

{ "webhook_id": 23, "webhook_name": "Example webhook", "event": { "action": "change", "time": "2020-07-24T20:11:22", "user": { "id": 1, "login": "admin@bmo.test", "real_name": "Vagrant User" }, }, "[% terms.bug %]": { "id": 2, "is_private": true } }

Response

HTTP 200 OK. The request has succeeded.

Errors

If the response is not 200, the [% terms.Bugzilla %] system will retry 4 attempts, waiting 5s, 10s, 15s and 20s between each attempt. If none of those attempts is successful, the system will continue trying every 15 minutes.

If a message is stuck without a successful attempt, the next messages that trigger the webhook will be stored in a queue in the order that were triggered and will be delivered in that order when the first message in the queue is delivered.

[% INCLUDE global/footer.html.tmpl %]