liveBook · Manning

Webhook

As explained in Contract Testing in Action

A webhook is an HTTP callback that delivers an event notification from one system to another when a specified event occurs.

A webhook is an HTTP callback that reacts to an event. In a Pact-based contract-testing pipeline, it closes the gap between separately maintained consumer and provider projects: when a consumer publishes a changed contract, the webhook can trigger provider verification automatically instead of waiting for a teammate to run it manually. section 10.4

Figure 10.15 Consumer and provider pipeline in different GitHub projects. When a consumer publishes a contract that has changed, this should trigger the provider verification job from the provider pipeline.
figure

Use this flow when consumer and provider pipelines live in different GitHub projects. A changed consumer contract publishes an event, which triggers only the provider verification job and returns verification results to the Pact Broker. section 10.4

Configure a Pact webhook to dispatch provider verification:

  • Create a GitHub personal access token with public_repo access, then store it as a PactFlow secret rather than placing it directly in the request. section 10.4.1
  • Select the consumer and provider, then listen for the Contract Published That Requires Verification event. section 10.4.1
  • Send a POST request to the GitHub repository dispatch endpoint with JSON headers, authorization, and a payload containing the pact URL, provider version SHA, and branch. section 10.4.1
  • Configure the provider to use the webhook-supplied pact URLs so it verifies the newly amended contract; allow can-i-deploy to retry while verification remains unknown. section 10.5

A changed response expectation

Change a consumer expectation for GET /movies from status 200 to 201, commit, and push it. The consumer pipeline can fail can-i-deploy because the deployed provider has not verified the new contract; meanwhile, the webhook triggers the provider workflow, which reports the 200-versus-201 mismatch. section 10.4.5 section 10.4

Webhooks are an advanced part of contract-testing automation, alongside versioning and can-i-deploy. They provide a continuous feedback loop for contract changes, but the event configuration must match the workflow that should run. section 2.5.4 section 10.0

How Contract Testing in Action covers it

How deep it goes
Walks through token storage, event selection, request payloads, provider configuration, and mismatch testing; defers other webhook event types.
Examples
Uses WebConsumer, MoviesAPI, GitHub repository dispatches, and a 200-to-201 response-status mismatch.
What it assumes
Assumes consumer and provider contract tests in CI/CD, while teaching webhook setup from token storage through event configuration.
What you can do after
Operate/configure Pact webhooks to dispatch provider verification and surface changed-contract mismatches in CI/CD.
How it connects
Connects webhooks with consumer-driven contract testing, Pact Broker, provider verification, can-i-deploy, versioning, and CI/CD pipelines.

Also explained in

Compare how 6 books explain webhook →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Contract Testing in Action. The section links point to the parts of the book it draws on.