Skip to main content

dbt-webhook

PyPI version

A dbt plugin that allows defining HTTP hooks for DBT commands and/or models, triggering them at execution start/end, and injecting the returned data into the model's metadata.

How It Works

Below is a diagram describing how the plugin works and the different types of hooks:

dbt-webhook design


Getting Started

dbt-webhook is designed to work with dbt-core, allowing data infrastructure teams to extend functionality via additional Python packages.

To start using dbt-webhook, follow these three steps:

1. Install the dbt-webhook Package

Install dbt-webhook in your local development environment and in the environment running scheduled jobs (e.g., Airflow):

pip install dbt-webhook

2. Create a dbt-webhook Configuration File

Create in work dir file dbt_webhook.yml and configure hooks you want to run.

Example Configuration

command_start_hook:
  command_types:
    - "compile"
  webhook_url: "https;//domain.example.com/dbt/command/start"
  webhok_method: "POST"
  headers:
    Content-Type: "application/json"

command_end_hook:
    # Same schema as above

model_start_hook:
    # Same schema as above

model_end_hook:
    # Same schema as above

Configuration Notes:

  • By default, the plugin will search for dbt_webhook.yml in the working directory:
    • In VSCode (when using the dbt Power User extension), this is the workspace directory.
    • In Airflow, the working directory may differ (e.g., the project directory).
    • If the local and scheduled work directories differ, you can create a symlink to avoid duplicating the configuration file.
  • If the HTTP endpoint requires authentication, pass secrets via environment variables:
  headers:
    Authorization: "bearer {DBT_WEBHOOK_AUTH_TOKEN}"
    Content-Type: "application/json"
  env_vars:
    - "DBT_WEBHOOK_AUTH_TOKEN"

3. Create HTTP Endpoints

The format of request and response payloads is defined in dbt_webhook/webhook_model.py using Pydantic models.

Command Hooks Request/Response Schema

{
    "command_type": "run",
    "invocation_id": "<UUID generated on dbt command start>",
    "run_started_at": "<timestamp>",
    "run_finished_at": "<timestamp>",
    "success": True | False | None
    "nodes": {
        "model.project.my_first_dbt_model": {
            "unique_id": "model.project.my_first_dbt_model",
            "meta": {"field1": 'val1'},
            "node_started_at": "<timestamp>",
            "node_finished_at": "<timestamp>",
            "target_database": "<db | project>",
            "target_schema": "<dataset | schema>",
            "target_table_name": "my_first_dbt_model",
            "success": True | False | None,
        },
        "<some other model unique id>": {...},
        ...
    },
}

Node Hooks Request/Response Schema

For node hooks, the schema is similar, but instead of a nodes dictionary, there is a single node object:

{
    "command_type": "run",
    "invocation_id": "<UUID generated on dbt command start>",
    "run_started_at": "<timestamp>",
    "run_finished_at": "<timestamp>",
    "success": True | False | None
    "node": {
        "unique_id": "model.project.my_first_dbt_model",
        "meta": {"field1": 'val1'},
        "node_started_at": "<timestamp>",
        "node_finished_at": "<timestamp>",
        "target_database": "<db | project>",
        "target_schema": "<dataset | schema>",
        "target_table_name": "my_first_dbt_model",
        "success": True | False | None,
    },
}

Contributing

Contributions are welcome! Feel free to submit issues or open pull requests on GitHub.

Metadata

Release files for dbt-webhook 0.3.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dbt-webhook 0.3.7
File Size Uploaded Provenance Actions
dbt_webhook-0.3.7.tar.gz 12.6 kB Without provenance Details for dbt_webhook-0.3.7.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dbt-webhook 0.3.7
File Interpreter ABI Platform Actions
dbt_webhook-0.3.7-py3-none-any.whl Python 3 none any Details for dbt_webhook-0.3.7-py3-none-any.whl

Total release size: 26.1 kB

Release files / dbt_webhook-0.3.7.tar.gz

Download URL dbt_webhook-0.3.7.tar.gz
Size 12.6 kB
Tags Source
SHA-256 checksum
How to use checksums
f1f80aaba3ffee200c4a83ebd3923bf05768b76041274a8d1b95208ba0139c95
BLAKE2b-256 checksum
How to use checksums
e16de29bd1b1c80c972f0edf57e7f74b424faeb6aeeec27e56ef994682ac8e02
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.11

Release files / dbt_webhook-0.3.7-py3-none-any.whl

Download URL dbt_webhook-0.3.7-py3-none-any.whl
Size 13.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
26928bf641625181e333af1b417e939288b9e81686b5fcd218a717e8d578a0be
BLAKE2b-256 checksum
How to use checksums
2b82be9ef5515746e35c96dcd5782d58055bb63b2aebaf0f3d3fc118776e4824
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.11

Security for dbt-webhook 0.3.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page