Skip to main content

Publish a provider contract

Bi-directional contract testing checks a consumer's pact against the provider's OpenAPI document instead of replaying it against a running provider. That document, registered against a provider version, is the provider contract. Publish one from each provider build: upload the document, or name the Apiome version that describes the provider and let Apiome render it.

Apiome compares every pact that needs it with the contract, by the rules in Comparison rules, as soon as either side publishes. Each comparison is stored as a verification result, and the matrix and can-i-deploy read it like one a Pact verifier published. A contract counts only when the provider's self-verification evidence says the provider matches it. Publish from a pipeline with the CLI or the REST API, or from the UI — or set it up once and let Apiome publish it automatically on every project publish or repository push. The Pact comparisons page shows each comparison's fidelity report.

Before you start​

You need:

  1. The broker base URL and an API key — the same ones you publish pacts with. The key's member needs Pacts → Create (the built-in Editor role has it).
  2. An OpenAPI 3.0, 3.1 or 3.2 document for the provider, in JSON or YAML — or an Apiome project that describes it. Swagger 2.0 is not accepted: import it into Apiome and publish from the project instead. For a provider that sends messages, publish its AsyncAPI 2.x or 3.x document instead: see Message pacts.
  3. A self-verification report from a tool that tested the provider against that document — Schemathesis, Dredd, Newman or any JUnit writer — or an Apiome provider-verification report.

You do not need to register the provider first. The first contract that names it registers it as a pacticipant.

Publish from the UI​

The Publish a provider contract page does what apiome pact publish-provider-contract does, from the browser — and shows the verdict for each consumer before anything is saved. Open Contracts, find I provide an API and click “Publish a provider contract” (or go to /ade/dashboard/pacts/provider-contracts/new).

The Publish a provider contract page: The contract from the project Billing API version 2.7.0 with an OpenAPI 3.1 pill, Whose version this is with provider Billing Service, version 2.7.0+9f31c20 and branch main, and the five evidence choices with their strength. Beside them, If you publish now: 2 of 3 consumers stay compatible, Orders UI breaks because POST /invoices no longer returns currency and Orders UI 3.3.2 is in production; then Nobody uses: 5 of 12 operations appear in no pact.The Publish a provider contract page: The contract from the project Billing API version 2.7.0 with an OpenAPI 3.1 pill, Whose version this is with provider Billing Service, version 2.7.0+9f31c20 and branch main, and the five evidence choices with their strength. Beside them, If you publish now: 2 of 3 consumers stay compatible, Orders UI breaks because POST /invoices no longer returns currency and Orders UI 3.3.2 is in production; then Nobody uses: 5 of 12 operations appear in no pact.
Route/ade/dashboard/pacts/provider-contracts/new

1. The contract​

Choose one of the tabs under The contract:

TabWhat it does
A project versionPick the Project and the Version. Apiome renders the version as OpenAPI 3.1 from the canonical model — the same as --apiome-version billing-api@2.7.0. Tick Do this on every publish to have every later published version of the project published too (Publish automatically).
UploadDrop an OpenAPI or AsyncAPI document (.yaml, .yml or .json) on the box, or click “Browse files”. The pill beside the title says what was read, for example OpenAPI 3.1.
URLType the Specification URL. Apiome reads it once when you click “Compare only” (public addresses only) and publishes those exact bytes. To follow a file as it changes, use Repository.
RepositoryFollow a file of a registered repository: every push to its branch publishes it, with the commit as the provider version. Nothing is published now (Publish automatically).

A document that cannot be published says why under the box — for example Could not read this file: line 42, mapping values are not allowed here, or This is Swagger 2.0 — and Publish contract stays disabled.

2. Whose version this is​

Type the Provider (the pacticipant consumers name in their pacts — it is registered on the first publish), the Provider version (a commit SHA is ideal, for example 2.7.0+9f31c20), the Branch and any Tags. The Build URL is under More options.

3. Evidence​

A spec is a claim. Choose how the claim is backed — each choice is labelled with its strength:

ChoiceStrengthWhat you giveThe same as
Run it now against a providerStrongA Target (a verification target). Apiome's hosted verifier calls it and checks every operation, read-only by default. Needs A project version.Running provider verification, then --evidence-report <id>
Attach a verifier's reportStrongA JUnit XML, Newman JSON or Schemathesis NDJSON report; optionally the verifier, its version and its exit code.--evidence report.xml
Reuse an Apiome contract-test runStrongA Run already recorded for this version.--evidence-report <id>
My pipeline vouches for itWeakThe Verifier, its Version and the Exit code (0 is success).--verifier … --verification-exit-code 0
None yetNoneNothing. The contract is unverified: its verdicts read unverified and never unblock a deploy.No evidence flag

Run it now publishes only when the run passes. When it fails, nothing is published: the page lists the failing operations and the report the run was recorded as, so you can fix the provider and run again.

If you publish now​

The If you publish now preview beside the form, for Billing Service, which already publishes each version of Billing API: the ring reads 2 of 3 consumers stay compatible, Orders UI breaks because POST /invoices no longer returns currency and Orders UI 3.3.2 is in production, Mobile App and Checkout read Unverified, and Nobody uses lists 5 of 12 operations. Under the provider, Published automatically says each published version of Billing API becomes its contract, with a Stop publishing each version button; Do this on every publish is ticked.The If you publish now preview beside the form, for Billing Service, which already publishes each version of Billing API: the ring reads 2 of 3 consumers stay compatible, Orders UI breaks because POST /invoices no longer returns currency and Orders UI 3.3.2 is in production, Mobile App and Checkout read Unverified, and Nobody uses lists 5 of 12 operations. Under the provider, Published automatically says each published version of Billing API becomes its contract, with a Stop publishing each version button; Do this on every publish is ticked.
Route/ade/dashboard/pacts/provider-contracts/new

The aside is the preview: it compares the contract with every pact a publish would compare it with — each consumer's main-branch pact, the latest on this branch and everything deployed or released — and stores nothing. It refreshes as you fill the form (click “Compare only” for a URL, or to run it on demand):

  • The ring — how many consumers stay compatible, for example 2 of 3 consumers stay compatible.
  • One row per consumer pact — Fine, Unverified or Breaks, with the first difference (POST /invoices: no longer returns currency) and where that consumer version is deployed.
  • Nobody uses — the operations no pact touches: what the provider can change freely, as far as contracts know.

With no consumers yet the aside reads No pacts to compare with. The verdicts appear the moment a consumer publishes. A version that already has a different contract says so — 2.7.0+9f31c20 already has a different contract — use the new commit's version — and nothing is sent.

You can publish even when a consumer breaks: publishing records the truth, and can-i-deploy is what stops the version reaching an environment.

Publish​

Click “Publish contract”. The result dialog says how many verdicts were recorded as compatible, incompatible or unverified, and Can I deploy 2.7.0+9f31c20? opens can-i-deploy for the new version. Bi-directional verdicts send no webhooks or commit statuses yet; consumers see them in the matrix and can-i-deploy.

The same, from anywhere beside the form shows the page as an apiome pact publish-provider-contract command, a GitHub Actions step and the REST request, and lists what the command cannot carry (a URL, Run it now, a standing source) with the reason.

Publish automatically​

A provider does not have to remember to publish its contract for every version. Say once where it comes from, and Apiome publishes it each time that source moves — then compares it with every consumer's pact, exactly as a publish from the page does, so the verdicts recorded are the ones the preview showed.

Standing sourceSet it on the pageWhat is published, and when
On every project publishA project version → tick Do this on every publish → click “Publish contract”Each time a version of the project is published, it is rendered as OpenAPI 3.1 and published as the contract of provider version <version label> (for example 2.7.0), on the provider's main branch. Drafts are never published.
On every pushRepository → choose the Repository, type the Path and the Branch → click “Follow this file”Each push to that branch publishes the file at the pushed commit, as the contract of provider version <commit sha> on that branch.

On every project publish​

  1. Open Publish a provider contract and choose A project version.
  2. Pick the Project and a Version, and fill in Whose version this is.
  3. Tick “Do this on every publish” and click “Publish contract”.

The contract is published now, and the setting is saved with it — the provider has to exist first, and the publish registers it. A provider bound to no project is bound to the one you chose; a provider already bound to another project is refused with the reason (Billing Service is bound to Payments API…) — change its project on its pacticipant page first. The result dialog says which happened: Each published version of Billing API now becomes Billing Service's contract.

On every push​

  1. Open Publish a provider contract and choose Repository.
  2. Choose a Repository registered in the workspace, type the Path of the OpenAPI or AsyncAPI document (for example openapi/billing.yaml) and the Branch (it defaults to the repository's default branch).
  3. Type the Provider and click “Follow this file”.

Nothing is published or compared now: Compare only is off and the aside says The verdicts appear after the next push. Each push is then a provider version — its commit, on the pushed branch. Two things to know:

  • The repository needs a push webhook, or no push reaches Apiome. Without one the source is saved with a warning; register the webhook on the repository's page.
  • Only GitHub repositories can be followed: Apiome reads the file through GitHub's contents API. Other repositories are listed but cannot be chosen; publish from their pipeline with apiome pact publish-provider-contract instead.

A push publishes the file without self-verification evidence, so its verdicts read unverified until evidence is published for that commit from your pipeline (An unverified contract).

See and stop a standing source​

Once a provider is typed, Published automatically under Whose version this is says where its contract already comes from — Each published version of Billing API becomes its contract. Drafts never do. — with any warning (no project bound, no push webhook, the repository was deleted). Click “Stop publishing each version” or “Stop following openapi.yaml” to turn a source off. Turning a source off stops new publishes only; contracts already published stay.

What is recorded​

  • Once per version. A provider version's contract is write-once: the same document again changes nothing (unchanged), and a different one is refused — the attempt fails with the conflict as its reason. A redelivered webhook publishes nothing.
  • Every attempt is audited as pacts.contract.auto_publish in the access audit, with the trigger, the outcome (published, unchanged, failed or skipped) and why it did not publish — a draft, a file that could not be read or is larger than APIOME_PACT_MAX_BYTES, a document that is not OpenAPI 3.x or AsyncAPI. Nothing is dropped silently, and nothing fails the project publish or the push.
  • Changing a source is audited as pacts.contract_source.update.

With the API​

PUT /v1/tenants/{tenant}/pacticipants/{provider}/contract-sources replaces the whole setting; both off removes it. GET on the same path reads it, with warnings.

curl -fsS -X PUT "$APIOME_URL/v1/tenants/acme/pacticipants/billing-service/contract-sources" \
-H "Authorization: Bearer $APIOME_API_KEY" -H "Content-Type: application/json" \
-d '{"onProjectPublish": true,
"repository": {"repositoryId": "<repository id>", "path": "openapi/billing.yaml", "branch": "main"}}'
RefusalWhy
409 contract-source-no-projectonProjectPublish for a provider bound to no project — bind it first (PATCH …/pacticipants/{p} with project).
404 contract-source-repository-not-foundThe repository is not registered in this workspace.
422 contract-source-repository-unsupportedThe repository's files cannot be read on a push (only GitHub's can).
400 contract-source-invalid-pathThe path is not a repository-relative .yaml, .yml or .json file.

There is no apiome pact command for a standing source: the CLI publishes one version at a time, and a pipeline that already publishes every build needs none.

Publish an OpenAPI document​

PUT the contract to …/pact-broker/contracts/provider/<provider>/version/<provider version>, with the document base64-encoded in content:

curl -X PUT \
"https://api.apiome.dev/v1/tenants/acme/pact-broker/contracts/provider/ledger-api/version/$GIT_COMMIT" \
-H "Authorization: Bearer $APIOME_API_KEY" \
-H "Content-Type: application/json" \
--data @- <<EOF
{
"contractType": "oas",
"contentType": "application/yaml",
"content": "$(base64 < openapi.yaml | tr -d '\n')",
"branch": "$GIT_BRANCH",
"buildUrl": "$CI_BUILD_URL"
}
EOF
FieldWhat it is
contentThe OpenAPI (or AsyncAPI) document, base64-encoded.
contentTypeapplication/json or application/yaml. Leave it out and Apiome reads a document that starts with { as JSON and anything else as YAML.
contractTypeoas for an OpenAPI document, or asyncapi for an AsyncAPI document compared with message pacts. Leave it out and Apiome reads it from the document.
branch, tags, buildUrlRecorded on the provider version, as when you record a version.
verificationResultsThe provider's self-verification evidence. See Self-verification evidence.

Use the commit SHA as the provider version. A version's contract is fixed once published, so every build needs its own version number.

Publish from an Apiome version​

If an Apiome project describes the provider, send apiomeVersion instead of content. Apiome renders the version's OpenAPI 3.1 document — the same one GET /v1/schema/<workspace>/<project>/<version> serves — and stores it like an uploaded one:

{ "apiomeVersion": "ledger-api@1.4.0", "branch": "main" }
apiomeVersionRenders
ledger-api@1.4.0Version 1.4.0 of the project ledger-api.
ledger-api@latestThe project's newest version.
ledger-api@<revision id>That revision of the project.
1.4.0 or latestThat version of the project the provider is bound to.

To use the short form, bind the provider to its project once:

curl -X PATCH "https://api.apiome.dev/v1/tenants/acme/pacticipants/ledger-api" \
-H "Authorization: Bearer $APIOME_API_KEY" \
-H "Content-Type: application/json" \
-d '{"project": "ledger-api"}'

Draft versions can be published. What is stored is a copy, so a later edit of the version does not change a published contract. The key's member also needs Versions → View (every built-in role has it).

Self-verification evidence​

A provider contract is only as good as the provider's agreement with it. Apiome trusts a provider contract only when evidence says the provider matches it. Send that evidence with the contract in verificationResults: the report of a tool that tested the provider against its own document, or an Apiome provider-verification report. Apiome reads the report when you publish and records what it proved in selfVerification.

Publish with the CLI​

The quickest way is apiome pact publish-provider-contract. It base64-encodes the files and names their media types from the file extension:

apiome pact publish-provider-contract openapi.yaml \
--provider "Ledger API" \
--provider-app-version "$GIT_COMMIT" \
--branch "$GIT_BRANCH" \
--build-url "$CI_BUILD_URL" \
--evidence reports/junit.xml \
--verifier schemathesis
OptionWhat it sends
--evidence <file>The report, as verificationResults.content. .xml is sent as JUnit, .json as JSON, .ndjson or .jsonl as NDJSON, .txt or .log as plain text. --evidence-content-type overrides the guess.
--evidence-report <id>An Apiome provider-verification report instead of a file.
--verification-exit-code <n>success: true for 0. Leave it out and a report file counts as passing unless the report shows failures.
--verifier, --verifier-versionThe tool that wrote the report. Apiome detects Schemathesis, Dredd and Newman reports itself.
--apiome-version <project>@<version>Render the contract from an Apiome version instead of the file.
--fail-on-unverifiedExit 1 when the contract is not trusted, so the build fails.

The command prints what the evidence proved. The options follow PactFlow's pactflow publish-provider-contract, so a pipeline moves over by changing the command name. The full list is on the apiome pact reference.

One example per tool​

Each example tests the provider at $PROVIDER_URL against openapi.yaml, then publishes the contract with the report.

Schemathesis — JUnit XML. Write the report with --report junit:

st run openapi.yaml --url "$PROVIDER_URL" --report junit --report-dir reports
apiome pact publish-provider-contract openapi.yaml --provider "Ledger API" \
--provider-app-version "$GIT_COMMIT" --branch "$GIT_BRANCH" \
--evidence reports/junit-*.xml --verifier schemathesis

Schemathesis — NDJSON. --report ndjson writes one event per line. Apiome counts each finished scenario, and needs the event that says the run completed:

st run openapi.yaml --url "$PROVIDER_URL" --report ndjson --report-dir reports
apiome pact publish-provider-contract openapi.yaml --provider "Ledger API" \
--provider-app-version "$GIT_COMMIT" --evidence reports/ndjson-*.ndjson

Dredd — xunit. Dredd's xunit reporter writes JUnit XML:

dredd openapi.yaml "$PROVIDER_URL" --reporter xunit --output reports/dredd.xml
apiome pact publish-provider-contract openapi.yaml --provider "Ledger API" \
--provider-app-version "$GIT_COMMIT" --evidence reports/dredd.xml --verifier dredd

Postman / Newman — JSON. Run the collection with the json reporter. Each assertion is a test; a failed request or test script counts as an error:

newman run ledger.postman_collection.json --env-var "base=$PROVIDER_URL" \
-r json --reporter-json-export reports/newman.json
apiome pact publish-provider-contract openapi.yaml --provider "Ledger API" \
--provider-app-version "$GIT_COMMIT" --evidence reports/newman.json --verifier newman

Newman's -r junit report works too. Send it like the Dredd one.

Any other tool — JUnit XML. Any JUnit report is read the same way. Apiome counts the <testcase> elements, not the totals on <testsuite>:

apiome pact publish-provider-contract openapi.yaml --provider "Ledger API" \
--provider-app-version "$GIT_COMMIT" --evidence build/test-results/contract.xml --verifier rest-assured

Apiome provider verification. If you run Apiome's own provider verification against a registered verification target, cite its report instead of uploading a file. Publish the contract from the same Apiome version the report verified:

apiome pact publish-provider-contract --apiome-version ledger-api@1.4.0 \
--provider "Ledger API" --provider-app-version "$GIT_COMMIT" \
--evidence-report 6f1c2b3a-4d5e-4f60-8a7b-9c0d1e2f3a4b

The key's member needs Verification evidence → View to cite a report (every built-in role has it). Apiome looks the report up in your workspace only.

Send it in the request​

Without the CLI, put the same fields in verificationResults:

{
"content": "…",
"verificationResults": {
"success": true,
"content": "<the report, base64-encoded>",
"contentType": "application/xml",
"verifier": "schemathesis",
"verifierVersion": "4.34.2"
}
}
FieldWhat it is
contentThe report, base64-encoded. At most APIOME_PACT_EVIDENCE_MAX_BYTES once decoded (5 MiB unless your operator changed it).
contentTypeapplication/xml or text/xml (JUnit), application/json (Newman), application/x-ndjson (Schemathesis NDJSON), or text/plain. Leave it out and Apiome guesses from the first bytes.
providerVerificationReportIdAn Apiome provider-verification report, instead of content. Send one or the other.
successWhether the tool passed. Required, except with providerVerificationReportId: the report says.
verifier, verifierVersionThe tool and its version.

What the evidence proves​

The answer to a publish, and a read of the contract, carry selfVerification:

"selfVerification": {
"status": "failed",
"kind": "junit",
"tool": "dredd",
"digest": "sha256:5e0f…",
"contentType": "application/xml",
"summary": { "tests": 1, "passed": 0, "failed": 1, "errors": 0, "skipped": 0 },
"reasons": ["the report records 1 failed and 0 errored of 1 tests although success: true was sent"],
"providerContractVerified": false,
"unverifiedPolicy": "warn"
}
statusMeans
verifiedApiome read the report. It ran tests, and none failed or errored. The contract is trusted.
failedThe report records failed or errored tests, or success was false. A failure in the report wins over success: true.
inconclusiveEvidence was sent but proves nothing: a text/plain report or a JSON shape Apiome does not read, a report that ran no tests, a Schemathesis run that did not finish, a success flag without a report, or an Apiome report of a different project or version than the contract. reasons says which.
missingNo verificationResults were sent.

kind is junit, newman-json, schemathesis-ndjson, apiome-provider-verification, or unreadable. digest is the SHA-256 of the report as sent, so you can match it to a CI artifact. For an Apiome report, reportId, target and coverage say which run it was. notes tells you something worth knowing even when the evidence is verified, such as a verifier that does not match the report.

An unverified contract​

A contract whose status is anything but verified is unverified. Its comparisons are still run and stored, but their verdict reads unverified (a fail stays fail), and comparison.comparisonVerdict keeps what the comparison found. What happens next is set by your operator with APIOME_PACT_UNVERIFIED_PROVIDER_CONTRACT:

PolicyThe comparison resultcan-i-deploy
warn (default)Keeps the comparison's success, plus a test result with a provider-contract-unverified warning.Answers as before, with a provider-contract-unverified warning.
failFails, with a provider-contract-unverified mismatch.Says no.

The policy is applied when the comparison runs and stored with it, so unverifiedPolicy in comparison says which one decided the result. To fix an unverified contract, publish it again under a new provider version, with passing evidence.

What happens when you publish​

  • Only OpenAPI 3.x is a provider contract. The document must declare openapi: 3.0.x, 3.1.x or 3.2.x and validate against that version's schema.
  • YAML is read as the JSON it stands for. A status code written 200: becomes the key "200", and an unquoted date such as 2026-11-01 becomes the text "2026-11-01". A value JSON cannot hold, such as !!binary or .nan, is refused with its location.
  • The provider version is recorded with its branch, tags and build URL. The provider is registered if the workspace does not have it yet.
  • Identical documents are stored once. A contract is named by the SHA-256 of its canonical JSON (contentSha). Key order and format do not matter: the same document sent as JSON, as YAML or rendered from Apiome has one contentSha, and ten builds that publish it store it once.
  • A contract is written once. For a provider version that already has one:
You publishAnswer
Nothing yet for this version201 — the contract is stored.
The same document with the same verificationResults200 — nothing changes.
A different document, or different verificationResults409 provider-contract-conflict — nothing is stored. Publish under a new provider version.

What Apiome read from the evidence is not part of the match: the same verificationResults sent again is the same publish.

What is compared when you publish​

The answer to a publish lists the comparisons it ran in comparisons:

"comparisons": {
"compared": 1,
"alreadyCompared": 0,
"errors": 0,
"skipped": 0,
"results": [
{
"consumer": "Billing Service",
"consumerVersion": "2.0.0",
"provider": "Ledger API",
"providerVersion": "4f1e2d0",
"pactVersionSha": "9b2c…",
"status": "compared",
"verdict": "pass",
"success": true,
"verificationNumber": 1
}
]
}

A contract is compared with:

  1. each consumer's latest pact from its main branch (its latest pact, if it has none there);
  2. every pact of a consumer version currently deployed or released;
  3. the latest pact of each consumer on the provider version's branch;
  4. every pact that was compared with an earlier contract of that branch, so a new contract on main re-runs what main's previous contract was compared with.

A consumer that publishes a pact later is compared then: its publish answer carries the same comparisons, and pact-broker publish prints one line per comparison.

statusMeans
comparedThe comparison ran and its result is stored. verdict is pass, partial, fail, or unverified when the contract has no passing evidence. success is the stored result's.
already-comparedThis pact was compared with this provider version before. Nothing new is stored.
errorThe result could not be stored. reason says why. Publish the contract again to retry.
skippedOver the limit of 50 pacts per contract publish (20 provider versions per pact). reason says so.

A pact and a contract that cannot be compared at all are stored as a failed result whose comparison.error gives the reason. The same inputs would fail the same way again.

Read the comparison​

Each comparison is a verification result of the pact, numbered with the others. Read it at verificationNumber, or follow the row's link in the matrix:

curl "$PACT_BROKER_BASE_URL/pacts/provider/ledger-api/consumer/billing-service/pact-version/<sha>/verification-results/1" \
-H "Authorization: Bearer $PACT_BROKER_TOKEN"
FieldWhat it is
kindbidirectional. A result a Pact verifier published reads native.
successfalse for a fail verdict, and for an unverified one under the fail policy. A partial verdict passes.
providerApplicationVersionThe provider version whose contract was compared.
testResultsOne entry per interaction, with its verdict and, when it failed, a mismatches entry per failure (attribute is the failure code).
verifiedBy.implementationApiome bi-directional comparison.
comparisonThe whole comparison: verdict, summary, providerContractSha, providerContractEvidence (the contract's selfVerification at the time), and per interaction the checks run, the failures and warnings with their JSON Pointers, and the fidelity notes. An unverified one adds comparisonVerdict and unverifiedPolicy.
_links.pb:provider-contractThe contract the pact was compared with.
_links.apiome:comparison-fidelityThe result's fidelity report: what was compared, and what was not.

How the matrix and can-i-deploy use these results is on Can I deploy?.

Read the fidelity report​

A pass means nothing that was compared contradicts the pact. The fidelity report says how much was compared: for every interaction, each check with its status, the matching rules the comparison could not prove, and the items it could not compare. Read it before you trust a green verdict.

In the app​

  1. Browse to /ade/dashboard/pacts/comparisons. The Pact comparisons page lists the workspace's most recent comparisons, newest first.
  2. Each row names the consumer and provider versions, the verdict with its strength (for example Pass (partial) · Not everything compared) and the counts that matter.
  3. Click a row to open its report under the list. The first row opens on its own.
The comparison fidelity report: a partial pass, four interactions, each check marked Compared or Partly compared, and the unsupported matching rules and could-not-compare items listed with their pact pointers.The comparison fidelity report: a partial pass, four interactions, each check marked Compared or Partly compared, and the unsupported matching rules and could-not-compare items listed with their pact pointers.
Route/ade/dashboard/pacts/comparisons

The report shows:

  • the verdict beside its strength: only Compared in full is green;
  • one sentence to read the verdict by, and the counters Interactions, Compared in full, Failed, Unsupported rules, Not compared and Checks not run;
  • per interaction, every check as an icon and a word: Compared, Partly compared, Failed or Not run (a check that did not run says why);
  • Unsupported matching rules and Could not compare, each item with its code and its JSON Pointer into the pact.

What each status, strength and code means is on Comparison rules.

With the API​

List the recent comparisons, then read one report by the result's id:

curl "$APIOME_API_URL/v1/tenants/acme/pact-comparisons?limit=20" \
-H "X-API-Key: $APIOME_API_KEY"

curl "$APIOME_API_URL/v1/tenants/acme/pact-comparisons/<resultId>/fidelity" \
-H "X-API-Key: $APIOME_API_KEY"

limit is 1 to 100 (default 50). Each list entry has verdict, strength, statement, the summary counts and fidelityPath. The report adds interactions, each with checks, unsupportedMatchingRules and couldNotCompare. A result a Pact verifier published has no comparison, so its report is a 404 pact-verification-not-found that says so.

Read a contract back​

GET the same URL. The answer describes the contract and carries the document in content:

FieldWhat it is
providerVersionThe provider version that published it.
contentShaThe SHA-256 of the document's canonical JSON.
contractTypeoas or asyncapi.
oasVersion, operationCountThe openapi version it declares, and how many operations it has. An AsyncAPI contract has asyncapiVersion and messageCount instead.
contentTypeHow it was sent: application/json, application/yaml, or application/json when rendered from Apiome.
source{"kind": "inline"} for an uploaded document. For one rendered from Apiome, kind is apiome, with project and version as they were named at publishing, and their ids.
verificationResultsThe self-verification results as sent, with contentSha256 and contentBytes of the report and the evidence Apiome read, or null.
selfVerificationWhat the evidence proved. See What the evidence proves.
contentThe OpenAPI document, as JSON.
_linksself, pb:provider and pb:provider-version.

Deleting the Apiome project or version a contract was rendered from does not delete the contract. Its projectId or versionId becomes null, and project and version still say where it came from. Deleting the provider version or the provider deletes its contract.

Check a contract before publishing​

POST the publish body to the same URL with /check on the end — or, in place of content, a contentUrl for Apiome to read the document from once — and Apiome answers with what the publish would record, storing nothing. It is what the page's If you publish now aside and Compare only call:

curl -sS -X POST "$PACT_BROKER_BASE_URL/contracts/provider/Billing%20Service/version/2.7.0%2B9f31c20/check" \
-H "Authorization: Bearer $PACT_BROKER_TOKEN" -H "Content-Type: application/json" \
-d '{"apiomeVersion": "billing-api@2.7.0", "branch": "main"}'
FieldWhat it is
resultsOne entry per consumer pact a publish would compare with: consumer, consumerVersion, sha, the environments that consumer version is in, verdict and success (what the publish would store, evidence policy included), and its first failures (interaction, operation, message; moreFailures counts the rest). A pact that was not compared has success: null and a reason.
summarycompared, compatible, incompatible, notCompared, consumers, unverified, and publishable — false when this version already published a different contract (the publish would be 409).
coverageThe contract's operations, how many a compared pact used, and the unused ones (at most 50; unusedMore counts the rest). null for an AsyncAPI contract, with coverageReason.
existingThe contract this version already published (contentSha, sameContent), or null.
selfVerificationThe evidence as the publish would read it.
fetchedWith contentUrl: the url, the bytes read and the content (base64) to publish inline.
ignoredtags and buildUrl are accepted and not used by a check; each is named here.

An unknown provider is not an error: it has no pacts yet (provider.exists: false). A contentUrl that is refused (private and loopback addresses are), cannot be reached or is too large is 422 provider-contract-url-unreadable. Checks share the workspace's pre-publish check budget (429 pact-check-rate-limited). The check needs pacts:view; an API key needs the pact:read scope.

When a contract is refused​

Every refusal carries a stable code in detail. When the problem is in one place, pointer is its JSON Pointer, in the OpenAPI document or in the request:

{
"detail": {
"code": "provider-contract-invalid",
"message": "the OpenAPI document does not validate against the OpenAPI 3.1 schema (1 error(s)): /paths/~1invoices~1{id}/get/responses/404: 'description' is a required property",
"pointer": "/paths/~1invoices~1{id}/get/responses/404"
}
}
StatusCodeWhat to do
422provider-contract-invalidThe document is not an OpenAPI 3.x document. pointer is the place in the document: /swagger for Swagger 2.0, /asyncapi for an AsyncAPI document sent with contractType: oas (send asyncapi, or leave it out), /openapi for a missing or unsupported version, otherwise the first schema error. "" means the whole document: it does not parse, or breaks a size or nesting limit. For an AsyncAPI contract, see What is checked when you publish.
422provider-contract-request-invalidA field in the request is wrong: neither or both of content and apiomeVersion, content that is not base64, verificationResults without success (and without a report id), both a report and a report id, or a report id that is not a UUID.
422provider-contract-unsupportedA contractType other than oas or asyncapi, asyncapi with apiomeVersion (send an AsyncAPI contract inline), or a contentType that is neither JSON nor YAML.
422provider-contract-source-not-foundapiomeVersion names no project or version of this workspace, or names only a version for a provider that is not bound to a project.
422provider-contract-evidence-unsupportedThe report's contentType is not one a report is read as (pointer is /verificationResults/contentType).
422provider-contract-evidence-invalidThe report is not what its type says: XML that does not parse, is not JUnit or declares a DTD; JSON or NDJSON that does not parse; text that is not UTF-8. message says where.
422provider-contract-evidence-report-not-foundproviderVerificationReportId names no provider-verification report of this workspace.
409provider-contract-conflictThis provider version already has a different contract. Publish under a new version number.
413provider-contract-too-largeThe document is over the size limit (APIOME_PACT_MAX_BYTES, 10 MiB unless your operator changed it).
413provider-contract-evidence-too-largeThe report is over APIOME_PACT_EVIDENCE_MAX_BYTES (5 MiB unless your operator changed it).
429pact-publish-rate-limitedThe workspace is over its publish budget, shared with pact publishing. Retry after the seconds in Retry-After.
404provider-contract-not-found, pacticipant-not-foundOn a read: the version published no contract, or there is no such provider.

Consumers without a Pact file​

A consumer you registered on a project's Consumers tab by picking operations and fields has no contract test suite, so it has no pact to publish. Apiome can write one for it: a Pact v4 file generated from what the consumer declared, with the provider's own OpenAPI examples as the sample values. Publish it, and the consumer takes part in the matrix, can-i-deploy and bi-directional comparisons like any other.

Export the pact​

  1. Declare the consumer's surface on Consumers (or with PUT …/projects/<project>/consumers/<consumer>/contract). Only a revision declared this way is exported.

  2. Run the export from the CLI, naming the project and the consumer:

    apiome pact export-consumer-contract --project pets --consumer web-app -o web-app-pets.json

    The command writes the Pact file and prints a summary:

    Pact v4 for web-app → pets-api: 3 interaction(s) from contract revision 4 (specification 1.2.0)
    findings: 1 placeholder(s), 0 omitted
    placeholder [no-example] GET /pets/{petId} 404 response 'code': the specification has no example for the response field 'code'; wrote 0
    wrote web-app-pets.json
  3. Read the findings (see What the generated pact says). Add --fail-on-findings in CI to exit 1 while any value is invented or anything is left out.

--revision 3 exports an older revision; without it the current one is used. Without -o the Pact JSON goes to stdout and the summary to stderr. The same export is GET …/v1/tenants/<workspace>/projects/<project>/consumers/<consumer>/pact; it answers the pact in pact next to findings, placeholder_count and omitted_count.

Publish it to the broker​

Publish straight from Apiome for a consumer version, as pact-broker publish would:

apiome pact publish-consumer-contract --project pets --consumer web-app \
--consumer-app-version "$GIT_COMMIT" --branch main --tag prod

The version, branch, tags and --build-url are recorded; the pact is stored once however many versions publish it unchanged; a different pact for a version that already has one is refused with 409 pact-content-conflict; and the comparisons run against the provider's contracts, listed in the output. The API is POST …/consumers/<consumer>/pact/publish with consumer_version and, optionally, branch, tags, build_url, revision and provider. You can also publish the exported file with pact-broker publish yourself.

What the generated pact says​

  • One interaction per operation and response status. A consumer that reads fields of the 200 and the 404 of GET /pets/{petId} gets two interactions, showPet returns 200 and showPet returns 404. An operation declared without fields expects its first 2xx status and no body.
  • Only the declared fields. A response body carries the fields the consumer reads and the objects that hold them; a request body carries the fields it sends. Declared query, header and cookie parameters are sent; path parameters fill the path, after the first server URL's base path (/v1/pets/p-42).
  • Sample values from the specification, in this order: the media type's example or first examples value, then the field schema's example, first examples value, default, const or first enum value, then the same on an enclosing object. A parameter uses its own example or examples first.
  • Response values are matched by type. Every response body carries a type matcher at $: the examples are documentation, not the provider's data, so the provider must return the same shape, not the same values. See Comparison rules.
  • The same revision always gives the same pact, so publishing it again for a new version reuses the stored pact version.

Nothing is dropped silently. Every finding names its operation, status and field:

OutcomeReasonWhat happened
placeholderno-exampleNo example covers the field or parameter. A value of its type was written ("string", 0, true, or a date, UUID, email or URI for those formats).
placeholderstatus-rangeThe response is declared as a range such as 2XX; the interaction expects 200.
placeholdercomplex-parameter-valueA parameter's example is an object; it was sent as JSON text.
omittedstatus-default, status-not-numericFields declared under the default response name no status, so they are left out. Declare them under a numeric status.
omittedmedia-type-not-jsonThe body is not JSON (form data, XML, text); its fields are left out.
omittedmedia-type-conflictFields of one body were declared under two media types; only the JSON one is written.
omittedoperation-not-found, field-not-found, parameter-not-declaredThe specification version the contract was declared against no longer has it.
omittedno-response-declaredThe operation has no response with a single status, so it has no interaction.
omittedcontract-unresolvedThe contract itself recorded this as unresolved when it was declared.

Which names the pact carries​

  • Consumer — the pacticipant bound to the consumer, otherwise the consumer's handle (web-app).
  • Provider — --provider when you give it; otherwise the pacticipant bound to the project, otherwise the project's handle. When several pacticipants are bound to the project, name one with --provider, or the export is refused with 409 consumer-pact-export-provider-ambiguous.

Bind both before you publish, so the pact lands on the applications you already have rather than registering new ones.

When an export is refused​

StatusCodeWhat to do
404consumer-not-found, consumer-contract-not-foundThe project has no such consumer, or the consumer declared nothing yet.
404consumer-version-not-foundThe specification version the revision was declared against was deleted. Declare the contract again.
409consumer-pact-export-provider-ambiguousSeveral pacticipants are bound to the project. Name the provider.
422consumer-pact-export-unsupported-sourceThe revision came from a Pact file (publish that file instead) or from an agent's tools.
422consumer-pact-export-no-versionThe revision records no specification version. Declare the contract again.
422consumer-pact-export-emptyNo interaction could be written. findings says why for each operation.
422consumer-specification-unavailableThe specification version cannot be rendered as OpenAPI.

Publishing can also answer the publish refusals, such as 409 pact-content-conflict and 429 pact-publish-rate-limited.

Who can do what​

ActionNeedsViewerEditorAdminOwner
Read a provider contractpacts:view✓✓✓✓
Publish an uploaded documentpacts:create—✓✓✓
Publish from an Apiome versionpacts:create and versions:view—✓✓✓
Cite an Apiome provider-verification reportpacts:create and verification_evidence:view—✓✓✓
Check a contract before publishing (Compare only)pacts:view (and versions:view for a project version)✓✓✓✓
Run it now before publishingpacts:create, versions:view and verification_evidence:create—✓✓✓
Read a provider's standing sourcespacts:view✓✓✓✓
Set or stop a standing sourcepacts:edit (and imports:view to follow a repository file)—✓✓✓
List comparisons and read a fidelity reportpacts:view✓✓✓✓
Export a declared consumer surface as a pactconsumer_contracts:view and pacts:view✓✓✓✓
Publish a declared consumer surfaceconsumer_contracts:view and pacts:create—✓✓✓

A restricted API key (one with scopes) cannot use these routes yet; use a full-access key from a member with the Editor role.