Webhooks

Admins and people with settings access can set up webhooks to send alerts to a particular URL. This means you can set up an alert to send the results of a question to an endpoint of your choice: to your app, a third-party service, or wherever.

Only admins and people with settings access can send alerts to webhooks.

For now, webhooks are only available for alerts; you can’t select a webhook as the recipient of a dashboard subscription.

Create a webhook

Admin > Settings > Notification channels

Before people can send alerts to a webhook, an admin or someone with settings access will need to create a webhook to target.

To create a webhook:

  1. Click the grid icon in top right corner and select Admin.
  2. In the Admin console, go Settings > Notification channels.
  3. In Webhooks for alerts, click Add a webhoor.
  4. Metabase will show you a short form to fill out:

    • Webhook URL. Where you want Metabase to send the results of an alert. Must be a valid URL.
    • Give it a name. Name the webhook so that people can pick the right hook when setting up an alert on a question.
    • Description. Tell people what the hook is for.
    • Authentication method:
      • None: Anything goes.
      • Basic: Set a username and password.
      • Bearer: Include a secret token.
      • API key: You can add the API key to the Header or as a Query param. Both approaches require a key and value (the API key itself).

Webhook payload

Metabase will send the results of an alert in JSON. The JSON will include some metadata about the question, like the alert’s creator and its ID (null in the case of test alerts).

Metabase will send the “attached” visualization as a base64-encoded PNG in the data key, under visualization.

The encoded PNG chart

And the data as seen in the table view, which Metabase will send as a raw_data.

Results as table view

Here’s an example payload for an alert (we truncated the PNG encoding because it’s boring):

{
  "type": "alert",
  "alert_id": null,
  "alert_creator_id": 2666,
  "alert_creator_name": "Roberto Bolaño",
  "data": {
    "type": "question",
    "question_id": 108,
    "question_name": "Sales",
    "question_url": "https://example.com/question/108",
    "visualization": "data:image/png;base64,=...LONG_ENCODED_PNG_HERE...",
    "raw_data": {
      "cols": [
        "CREATED_AT",
        "count"
      ],
      "rows": [
        [
          "2023-09-01T00:00:00Z",
          346
        ],
        [
          "2023-10-01T00:00:00Z",
          354
        ],
        [
          "2023-11-01T00:00:00Z",
          394
        ],
        [
          "2023-12-01T00:00:00Z",
          418
        ],
        [
          "2024-01-01T00:00:00Z",
          457
        ],
        [
          "2024-02-01T00:00:00Z",
          404
        ],
        [
          "2024-03-01T00:00:00Z",
          445
        ],
        [
          "2024-04-01T00:00:00Z",
          439
        ],
        [
          "2024-05-01T00:00:00Z",
          520
        ],
        [
          "2024-06-01T00:00:00Z",
          455
        ],
        [
          "2024-07-01T00:00:00Z",
          523
        ],
        [
          "2024-08-01T00:00:00Z",
          501
        ]
      ]
    }
  },
  "sent_at": "2024-09-30T20:16:15.76582Z"
}

Further reading

Read docs for other versions of Metabase.

Was this helpful?

Thanks for your feedback!
Want to improve these docs? Propose a change.