Skip to main content

Pact Broker concepts

Pact tooling does not talk about projects and specifications. It talks about pacticipants — the applications on either side of a contract — and names each build of one by its version, its branch and its tags. Apiome keeps that registry per workspace. It is the model that pact publication, verification results and can-i-deploy are built on.

New to the broker? Start with the Pact Broker overview: how publishing, verifying, recording deployments and can-i-deploy fit together.

This release has the registry, publishing and fetching pacts with the Pact CLI and libraries, choosing the pacts a provider verifies with consumer-version selectors, publishing verification results, environments and deployments, can-i-deploy with the matrix, contract webhooks, public pact badges, and labels, deletes and retention. To browse the registry, open Pacticipants from Contracts in the rail. To change it, use the Pacticipants API.

Terms​

TermWhat it is
PacticipantAn application that takes part in a pact, as a consumer, a provider or both. It has a handle (billing-service), a display name, and optionally a repository URL and a main branch.
HandleThe lowercase name URLs and CI jobs use for a pacticipant. It is unique in the workspace and never changes.
VersionOne build of a pacticipant, named by a version number — usually a commit SHA or a semantic version. A version is recorded once and never changes.
BranchA branch of the pacticipant's repository (main, feat/new-invoice). A version is recorded on a branch.
HeadThe latest version recorded on a branch.
Main branchThe branch a query reads when it names none. The first version published on develop, main or master sets it, as on the Pact Broker; set it on the pacticipant to choose another.
TagA label on a version (prod). Tags are Pact's older way to name a branch or a stage; branches are preferred for new setups.
BindingA link from a pacticipant to what Apiome already knows about that application: the project that describes a provider, or the consumer registered on a project.
PactThe contract between one consumer and one provider: the requests the consumer makes and the responses it expects, written by the consumer's tests.
Consumer versionThe version of the consumer that published a pact. One consumer version has one pact per provider.
Pact versionOne distinct pact between a consumer and a provider, named by the SHA-256 of its content. Consumer versions that publish the same pact share one pact version.
Broker base URLThe address a Pact client is given: https://<api>/v1/tenants/<workspace>/pact-broker.
Consumer-version selectorA rule a provider's verifier sends to say which pacts it must verify — {"mainBranch": true}, {"tag": "prod", "latest": true}. See Choose pacts to verify with selectors.
Verification resultWhat a provider's verifier published after replaying a pact: whether that provider version honours that pact version, with the result of each interaction. See Publish verification results.
Pending pactA pact the provider has not yet verified successfully on the verifying branch. Its failure is reported but does not fail the provider's build. See Pending and work-in-progress pacts.
Work-in-progress (WIP) pactThe latest pact of a consumer branch or tag that no selector chose and the provider has not verified yet. A verifier that asks for WIP pacts verifies it as pending.
EnvironmentA place versions run (test, production), with a production flag. See Environments and deployments.
Deployed versionA version recorded as deployed to an environment. Recording the next deployment there replaces it; the replaced one stays in the history.
Application instanceOne of several copies of an application in one environment (eu-1, us-1). Each copy has its own deployed version.
Released versionA version released to an environment where several versions are in use at once, such as a mobile app. It stays supported until support is recorded as ended.
MatrixThe table of consumer versions against provider versions, with the verification result between each pair.
Can-i-deployThe question "is this version compatible with what runs in that environment?", answered from the matrix: yes, no or unknown, with reasons. See Can I deploy?.
Pact Broker compatibilityWhich Pact Broker endpoints Apiome serves (supported, partial, planned or not planned), checked in CI against the official tools. An endpoint Apiome does not serve answers 501 with a pointer, never a bare 404. See Pact Broker compatibility.
IntegrationA consumer and a provider that have a pact between them. A consumer needs its provider to be deployed; a provider does not need its consumers.
Contract webhookAn HTTP request Apiome sends when something happens to a pact: it was published, its content changed, it needs verifying, or a verification finished. See Contract webhooks.
Pact badgeA public SVG (or shields.io) badge that says whether the pacts of an application bound to a public project are verified, failing or unknown. See Pact badges.
Provider contractA provider version's OpenAPI document, published for bi-directional contract testing: a consumer's pact is checked against it instead of against a running provider. See Publish a provider contract.
LabelA free-form name on a pacticipant (team-billing, tier-1) that groups applications. See Labels, deletes and retention.
Soft deleteHow Apiome deletes a pacticipant or a version: it disappears from every read at once — its pacts, results and deployments with it — but can be restored until it is purged.
Grace periodHow long a deleted pacticipant or version can be restored: 30 days by default.
PurgeThe removal, for good, of what was deleted longer ago than the grace period.
Retention runOne cleanup: keep the versions the keep rules name (the newest per branch, anything deployed or released, anything recent, and always the latest), delete the rest. It always starts as a dry run.
EventWhat a webhook fires on, such as contract_requiring_verification_published or provider_verification_failed.
Template parameterA ${pactbroker.…} name in a webhook's URL, headers or body that is replaced when the webhook fires — the pact URL, a version number, a branch.
Triggered webhookOne firing of a webhook for one event, with its status (not_run, retrying, success, failure) and its execution log.
Dead-letteredA webhook delivery that failed on every attempt and is not sent again. Its status is failure.

How a pacticipant relates to projects and consumers​

A pacticipant stands on its own. It does not need a project, and one application is one pacticipant however many APIs it calls or serves. Two optional bindings connect it to the rest of the workspace:

  • Project — for a provider. Bind the pacticipant to the project that holds its specification.
  • Consumer — for a consumer. Bind it to the consumer you registered on a provider's project (see Consumers).

Both must belong to the same workspace as the pacticipant. Deleting a project or retiring a consumer does not delete the pacticipant. The binding is cleared, and the pacticipant keeps its versions, branches and tags. Restoring the project does not restore the binding; set it again.

The rules the registry keeps​

  • Names are unique per workspace. The handle is taken from the name when you do not give one (Billing Service becomes billing-service), and a second pacticipant with the same handle is refused with 409 pacticipant-slug-taken. You can read a pacticipant by its handle, its id or its name.
  • A version never changes. The first request that records version 1.4.0 creates it and stores its build URL. Recording 1.4.0 again answers with the stored version; the build URL is not replaced. Repeating a request is how a build adds a branch or a tag to a version it already recorded.
  • A branch head only moves forward. Recording a version on a branch adds it to the branch. It becomes the head only when it was recorded later than the current head. Re-running an old build does not move the head back, and nothing else moves a head: not a tag, not a version recorded on another branch.
  • Tags are added once. Tagging a version that already has the tag changes nothing.
  • Version numbers, branch names and tags are stored exactly as sent — case and punctuation included. A value with a leading or trailing space or a control character is refused, not repaired. Versions are ordered by when they were recorded, never by comparing their numbers.

Register a pacticipant​

Publishing a pact registers its consumer and provider for you. Register one yourself when you want to set its repository, main branch or bindings first. The registry takes the API key in the X-API-Key header.

curl -X POST https://api.apiome.dev/v1/tenants/acme/pacticipants \
-H "X-API-Key: sk_live_…" \
-H "Content-Type: application/json" \
-d '{
"name": "Billing Service",
"repository_url": "https://github.com/acme/billing-service",
"main_branch": "main",
"project": "billing-api"
}'

The answer carries the handle, billing-service. project takes a project's slug or id; consumer_id takes a consumer's id. Change the name, repository URL, main branch or bindings later with PATCH; send null to clear one.

Record a version from CI​

Record each build once it has a version number:

curl -X PUT https://api.apiome.dev/v1/tenants/acme/pacticipants/billing-service/versions/3f2a9c1 \
-H "X-API-Key: sk_live_…" \
-H "Content-Type: application/json" \
-d '{
"branch": "main",
"build_url": "https://ci.example.com/builds/4812",
"tags": ["prod"]
}'
  • The status is 201 when the request created the version and 200 when it already existed.
  • created says the same in the body, and head_moved says whether branch now has this version as its head.
  • The body is optional. A version can be recorded with no branch and no tags.
  • A version number cannot contain / in this URL. Branch names and tags can.

Add a tag to a version that is already recorded:

curl -X PUT https://api.apiome.dev/v1/tenants/acme/pacticipants/billing-service/versions/3f2a9c1/tags/prod \
-H "X-API-Key: sk_live_…"

Read versions and branch heads​

To readRequest
Every pacticipant, by handleGET /v1/tenants/acme/pacticipants
A pacticipant's versions, latest firstGET …/pacticipants/billing-service/versions
The versions on a branch — the first is its headGET …/versions?branch=main
The versions with a tag — the first is the latestGET …/versions?tag=prod
One version, with its branches and tagsGET …/versions/3f2a9c1
Every branch with its headGET …/pacticipants/billing-service/branches

Lists return 50 rows a page (at most 200 with limit). Pass the previous page's next_cursor as cursor until has_more is false.

Delete a pacticipant or a version​

curl -X DELETE https://api.apiome.dev/v1/tenants/acme/pacticipants/billing-service \
-H "X-API-Key: sk_live_…"

This deletes the pacticipant with all of its versions, branches and tags. The project and the consumer it was bound to are not touched. DELETE …/versions/3f2a9c1 deletes one version.

A delete is soft: everything disappears from every read at once, and you can restore it for 30 days before it is purged. A deployed or released version is protected unless you force the delete. Labels, deletes and retention covers restoring, the protection, and cleaning up old versions in one retention run.

Who can do what​

The whole Pact Broker — the registry, pacts, verification results, environments, webhooks and provider states — is guarded by the Pacts resource (pacts):

ActionNeedsViewerEditorAdminOwner
Read pacticipants, versions, pacts, results, the matrix, can-i-deploy and contract healthpacts:view✓✓✓✓
Register a pacticipant, record a version, add a tag, publish pacts and verification resultspacts:create—✓✓✓
Create an environment or a webhook, record a deployment or a release, create a provider statepacts:create—✓✓✓
Change a pacticipant, environment, webhook or provider state; add or remove a labelpacts:edit—✓✓✓
Mark a deployment undeployed, test a saved webhook, redeliver a webhook, retry a commit statuspacts:edit—✓✓✓
Save the verification settings or an override, remove an override, acknowledge a re-publish requestpacts:edit—✓✓✓
Delete or restore a pacticipant or a version, delete an environment, webhook or provider state, apply a retention runpacts:delete——✓✓

Running a verification from Apiome (Verify, Re-verify, Verify stale pacts) also needs Verification evidence → Create, and publishing a consumer's pact from its project also needs Consumer contracts → View. A role without the permission gets 403 naming it.

An API key acts with the role of the member it belongs to. Give a CI job a key from a member with the Editor role: it can register its application, publish pacts and results and record deployments, but cannot delete anything. Custom roles do not get Pacts automatically — grant it in the permission matrix on Roles.

Every change is audited​

Every call that changes Pact data writes an entry to the workspace's Access audit: who acted (the member, or the API key's runner), what changed (pacticipant/billing-service/version/3f2a9c1), and the route. The entry never holds a request body, so a webhook's token or a pact's content is never copied into it. Deletes, restores, label changes and retention runs write their entry in the same transaction as the change; every other change writes it as soon as the change succeeds. A refused call writes no change entry — a call refused for a missing permission writes permission.denied instead.

Workspaces never share Pact data​

Every pacticipant, pact, result, environment, deployment and webhook belongs to one workspace, and the database itself refuses a row that points at another workspace's row — not just the API. A publish, a verification result or a deployment can only name pacticipants, versions and environments of the workspace its API key belongs to; another workspace's handle is answered as unknown (404), never revealed.