When consumer and provider code live in separate repositories, passing contract files around quickly becomes unreliable: versions diverge, updates need manual notification, and teams lose sight of what has been verified. A contract broker is the shared service that stores those contracts and coordinates their life cycle. In Pact-based consumer-driven contract testing, it records consumer and provider versions, contract metadata, and provider verification results. section 3.4 section 9.1
The broker is not the system that tests an API. A consumer test generates a contract from interactions with a mock provider, then publishes that contract and its version. The real provider retrieves it, replays the requests against its running service, compares actual and expected responses, and publishes the verification result back. The consumer can then check whether that specific contract version is safe to deploy. section 1.5.1 section 1.5.2 section 3.5
A broker supports a release workflow by keeping four responsibilities separate:
- Store contracts independently of consumer and provider repositories, including versions and metadata. section 3.4
- Give providers the contract version needed for verification and retain the resulting status. section 3.5
- Let CI/CD pipelines report whether changes are safe to deploy; failed verification sends developers back to fix and repeat. section 2.6.5
- Show dependencies and version compatibility through a network diagram and verification matrix. section 9.1.1
Publishing a consumer contract to a hosted broker
After generating Pact files, configure the broker base URL and API token as environment variables, then run a Pact CLI publish command with a consumer application version. The newly uploaded contract starts unverified until the provider retrieves and verifies it. A managed PactFlow service is one way to host the broker. section 4.4 section 9.2
Figure 3.5 CDCT life cycle from a JavaScript web application, through the broker to Java API or event service, and finally using the can-i-deploy tool to verify the changes in the web application
The lifecycle view connects consumer publication, provider verification, broker status updates, and the final can-i-deploy check. section 3.5
Choose hosting based on operational needs. PactFlow supplies a managed service, bearer-token authentication, and additional features; self-hosted open-source Pact Broker offers control and flexibility but requires infrastructure, security patches, dependency updates, and maintenance. A Docker deployment uses a PostgreSQL dependency and can provide the core broker locally or within existing infrastructure. section 9.5 section 9.4.1
