Skip to content

Contract sections

The fields that name a service, say who owns it and list what it exposes: pactoVersion, service, interfaces, capabilities, metadata and extensions. Configuration and policy are in Configuration and policy; dependencies and state are in Dependencies and state; readiness is in Readiness.

pactoVersion

The contract specification version: "2.0", "2.1", "2.2", "2.3", "2.4" or "2.5".

Each version accepts every contract of the version before it. Versions lists the Pacto core and operator releases each version needs.

pactoVersion: "2.0"

The version picks the JSON Schema the contract is validated against: pacto-v2.0.schema.json, pacto-v2.1.schema.json, pacto-v2.2.schema.json, pacto-v2.3.schema.json, pacto-v2.4.schema.json or pacto-v2.5.schema.json. Any other value fails to load with PARSE_ERROR (unsupported pactoVersion "3.0"; supported: 2.0, 2.1, 2.2, 2.3, 2.4, 2.5). See Validation layers.


service

Identifies the service. A "2.5" contract may leave out service, name and version; see the smallest contract.

Field Type Required Constraints
name string Yes (2.0 to 2.4) Pattern: ^[a-z0-9]([a-z0-9-]*[a-z0-9])?$
version string Yes (2.0 to 2.4) Parses as semver (for example 2.1.0). See the note below
owner OwnerInfo No Object only (string form removed)
domain string No Pattern: ^[a-z0-9]([a-z0-9-]*[a-z0-9])?$, at most 63 characters. pactoVersion 2.4
offering string No Pattern: ^[a-z0-9]([a-z0-9-]*[a-z0-9])?$, at most 63 characters. pactoVersion 2.4
summary string No 1 to 200 characters on one line with no control characters. pactoVersion 2.4
lifecycle object No pactoVersion 2.4. See service lifecycle
template object No pactoVersion 2.4. See golden path template
origin object No pactoVersion 2.4. See service origin
external string No The canonical identity of the external system the contract describes, for example stripe or host/corp-legacy.example; the dependencies[].identity pattern, at most 253 characters. pactoVersion 2.5

service carries identity only. The contract has no image or chart field: how you build and deploy a service is a delivery concern that lives outside the contract.

version is parsed leniently, so write it strictly

Pacto accepts any version that Masterminds/semver can parse. That parser fills in the parts you leave out and accepts a leading v, so 1, 0.1 and v0.1 all validate and all mean 0.1.0-style coerced versions. 1.2.3.4, abc, a capital V1.0.0 and anything with surrounding whitespace are rejected with INVALID_SEMVER.

Later steps keep the coerced string as written, so that string is what gets published. pacto push tags the artifact with the literal string, and two contracts written 1 and 1.0.0 become two different tags of the same version. Write the full MAJOR.MINOR.PATCH and skip the v.

Business domain

service.domain names the business domain the service belongs to, such as payments. The operational graph groups services by it. Use the same value in every contract of the domain. The value is a lowercase slug, so Payments and payments can never become two domains.

pactoVersion: "2.4"
service:
  name: payments-service
  version: 2.1.2
  domain: payments

The business domain differs from the registry path in a service's key, such as ghcr.io/acme, which the dashboard shows as Registry. A "2.0" to "2.3" contract that sets domain reports NEEDS_PACTO_2_4.

Platform offering

service.offering names the kind of offering a service provides to other teams, such as postgresql or shared-config. The operational graph lists providers of the same offering together. The value is an open lowercase slug: a new kind of offering needs no change to Pacto. The offering is unrelated to capabilities, which are assertions the service makes about itself.

Summary

service.summary is a one-line purpose that the graph shows next to the service, such as on an offering's provider list.

pactoVersion: "2.4"
service:
  name: postgresql
  version: 16.0.1
  offering: postgresql
  summary: Primary relational database for transactional data

A "2.0" to "2.3" contract that sets offering or summary reports NEEDS_PACTO_2_4.

Service lifecycle

service.lifecycle retires a whole service on a schedule its consumers can see, with the fields of the interface lifecycle:

pactoVersion: "2.4"
service:
  name: postgresql
  version: 16.1.0
  offering: postgresql
  lifecycle:
    deprecated: "2026-11-01"
    sunset: "2027-06-30"
    successor: oci://ghcr.io/trianalab/pacto/postgresql:17.0.0
Field Type Required Constraints
deprecated string Yes YYYY-MM-DD. The date the service was deprecated
sunset string No YYYY-MM-DD, not before deprecated. The date from which the service may be retired
successor string No An absolute URL, such as the oci:// reference of the service that replaces this one

Consumers that reach the service through a dependency or a configuration reference are warned with DEPENDENCY_SERVICE_DEPRECATED, then DEPENDENCY_SERVICE_SUNSET from the sunset date; see Validation layers. pacto diff reports the schedule (change classification). A "2.0" to "2.3" contract that sets lifecycle reports NEEDS_PACTO_2_4.

Golden path template

service.template marks the contract as a golden path, which pacto init --from copies into a new service:

pactoVersion: "2.4"
service:
  name: http-service
  version: 1.0.0
  owner: {team: platform}
  summary: An HTTP API on the platform runtime with a PostgreSQL database and the HTTP baseline policy
  template:
    plugins:
      - name: dockerfile
        description: A Dockerfile for a Go HTTP service
      - name: github-actions
        description: A CI workflow that validates and publishes the contract
        options: {go-version: "1.27"}
Field Type Required Constraints
plugins array No 1 to 32 generate plugins a person may run when they create a service. template may be {}
plugins[].name string Yes Pattern: ^[a-z0-9]([a-z0-9-]*[a-z0-9])?$, at most 63 characters. Pacto runs the pacto-plugin-<name> binary it finds. Listed once: a repeat reports DUPLICATE_TEMPLATE_PLUGIN
plugins[].description string No 1 to 200 characters on one line with no control characters
plugins[].options map of string No At most 32 entries, each value at most 1024 characters. Passed to the plugin
  • service.summary describes the golden path.
  • Creation removes the path's service.offering, and the operational graph gives a golden path no offering membership.

Service origin

service.origin records the golden path a service was created from:

pactoVersion: "2.4"
service:
  name: gift-cards
  version: 0.1.0
  owner: {team: checkout}
  domain: commerce
  origin:
    ref: oci://ghcr.io/trianalab/pacto/http-service:1.0.0
    digest: sha256:077937b6249c6a7e1e47d7affdc54e6d4c57c14f3e339e0092d43a12b2659649
Field Type Required Constraints
ref string Yes 1 to 512 characters with no control characters. An oci:// reference or a directory path: any other scheme or an oci:// reference that does not parse reports INVALID_ORIGIN_REF
digest string Yes Pattern: ^sha256:[a-f0-9]{64}$. The content digest of the golden path bundle, as pacto.lock records it
  • pacto init --from and pacto_create write it, and the graph shows it labelled declared.
  • A golden path derived from another golden path sets both fields.
  • Changes to either field are non-breaking (change classification).
  • A "2.0" to "2.3" contract that sets template or origin reports NEEDS_PACTO_2_4.

OwnerInfo

Structured ownership metadata. All fields are optional but at least one must be present. The field you set decides the canonical owner key that the graph groups by. See Ownership and the canonical owner key.

Field Type Required Constraints
team string No The team's bare name, such as billing: usually the team label on its workloads. pacto init and pacto_check flag a team/ prefix
dri string No Directly Responsible Individual
contacts OwnerContact[] No Contact points

OwnerContact

Field Type Required Constraints
type string Yes One of: email, url, group, oncall, chat, other
value string Yes Non-empty
purpose string No One of: ownership, support, escalation, oncall, notifications

Examples:

# Structured form (the owner is always an object)
service:
  owner:
    team: foundations
    dri: eduardo.diaz
    contacts:
      - type: email
        value: foundations@acme.com
        purpose: ownership
      - type: chat
        value: "#foundations"

# Minimal object form (at least one field required)
service:
  owner:
    team: payments

interfaces

Declares the service's communication boundaries. Optional: a service with no network interfaces, such as a batch job or shared library, can omit this section. The ref field points at the spec you already publish: an OpenAPI document, an AsyncAPI document, a gRPC service descriptor or the MCP tools a service exposes. Pacto reads that spec in place.

Field Type Required Constraints
name string Yes Non-empty. Must be unique across interfaces
type string Yes Enum: openapi, asyncapi, grpc, mcp (2.1)
ref string Yes Non-empty. Path to the spec file within the bundle
visibility string No Enum: public, internal. Default: internal
lifecycle object No 2.2. See interface lifecycle
guarantees object No 2.2. Behavior consumers may rely on. See Guarantees
compatibilityEpoch integer No 2.2. Minimum 0. Default: 0. See Compatibility epoch
port integer No 2.5. 1 to 65535. The port the interface listens on. Several interfaces may share one port

Interface types

Value Spec kind
openapi OpenAPI document for HTTP/REST traffic
asyncapi AsyncAPI document for event-driven communication
grpc gRPC service descriptor
mcp The tools a service such as an AI agent exposes, as an MCP tools/list result. See an agent is a service

Note

Interface names must be unique within a contract. Every interface requires a non-empty ref (SCHEMA_VIOLATION otherwise), and the referenced file must exist in the bundle (FILE_NOT_FOUND otherwise). A .json, .yaml or .yml ref must also parse (INVALID_INTERFACE_SPEC otherwise). For any other extension, such as a gRPC .proto, Pacto checks only that the file exists. pacto diff reports a declared or dropped port as non-breaking and a moved one as potentially breaking. Declare health and metrics endpoints as capabilities.

Interface lifecycle

A provider retires an interface on a schedule its consumers can see. A lifecycle marks the interface deprecated:

interfaces:
  - name: orders-v1
    type: openapi
    ref: interfaces/orders-v1.yaml
    lifecycle:
      deprecated: "2026-10-01"
      sunset: "2027-04-01"
      successor: orders-v2
  - name: orders-v2
    type: openapi
    ref: interfaces/orders-v2.yaml
Field Type Required Constraints
deprecated string Yes YYYY-MM-DD. The date the interface was deprecated
sunset string No YYYY-MM-DD, not before deprecated. The date from which the interface may be removed
successor string No Another interface of this service, or an absolute URL such as an oci:// reference to another service

pacto validate --closure warns a consumer about each deprecated interface of the services it depends on; see Dependency closure. A dependency names a service and not an interface, so the consumer is warned about every deprecated interface of that service. pacto diff reports the schedule; see change classification.

Guarantees

guarantees declares the behavior a consumer may rely on, in a closed vocabulary: an unknown key fails to load.

Guarantee Value For Stronger value
delivery at-most-once or at-least-once events Neither: they trade loss for duplicates
ordering per-key or global events global, which also orders every key
dedupeWindow duration events Longer
retention duration events Longer
idempotent boolean calls true
timeout duration calls Shorter
profile "1" both The vocabulary version. Omitted means 1

A duration is written like 500ms, 5m or 168h.

interfaces:
  - name: order-events
    type: asyncapi
    ref: interfaces/events.yaml
    guarantees:
      delivery: at-least-once
      ordering: per-key
      dedupeWindow: 10m
      retention: 168h

A consumer lists what it relies on in dependencies[].requires. pacto diff classifies a removed or weakened guarantee as breaking.

Compatibility epoch

Raise compatibilityEpoch when an interface's behavior changes incompatibly while its spec stays the same, for example when an amount field switches from cents to euros. pacto diff reports the change as BREAKING with the interface's name in the reason, so pacto impact lists the consumers to review.

interfaces:
  - name: payments-api
    type: openapi
    ref: interfaces/openapi.yaml
    compatibilityEpoch: 2

An epoch only goes up. Lowering it is also BREAKING, because consumers that adapted to the higher epoch break in turn. A "2.0" or "2.1" contract that sets it reports NEEDS_PACTO_2_2.

Interfaces at runtime

The Kubernetes operator checks two fields of a running interface: type and visibility.

  • type. The operator sends a probe to the port and looks at the protocol that answers. openapi accepts HTTP/1 or HTTP/2 and grpc accepts HTTP/2. Anything else is INTERFACE_PROTOCOL_MISMATCH. A TLS port, no answer and asyncapi stay unverified.
  • visibility (internal when omitted). It is contradicted only when the operator sees an address outside private networks: a public externalIPs entry, or a LoadBalancer Service (without an internal load balancer annotation) or an Ingress whose status carries a public IP or hostname. That is INTERFACE_VISIBILITY_MISMATCH. A NodePort Service, an internal or address-less load balancer and an HTTPRoute leave exposure unknown, so the field stays unverified. A public interface seen only in-cluster also stays unverified, because a gateway the operator cannot see may expose it.

A field the operator cannot check leaves the contract status unchanged. See Runtime conformance.


capabilities

Optional. Declares standard observability capabilities (health, metrics) or custom extension capabilities. Use this section to tell the platform that a service exposes health and metrics endpoints.

Field Type Required Constraints
type string Yes Enum: health, metrics, extension
ref string Conditional Required for extension only. A namespaced identifier (e.g. example.com/custom). Not allowed for health/metrics
binding Binding No Standard types only (health/metrics). Binds the endpoint to a declared interface. Not allowed for extension

Capability binding

Binds a standard capability endpoint (health/metrics) to a declared interface so a collector can probe it. binding.type is a closed set and http is the only supported transport in this release. Any other transport fails structural validation.

A binding resolves as follows:

  • binding.type: http means the capability is probed over HTTP.
  • binding.interface names the declared interface that provides the address and port for the probe. It is the platform-neutral counterpart of the Kubernetes CR's spec.target.interfaceBindings[].interface, which resolves to a concrete Kubernetes Service port. The capability path is independent of that interface's OpenAPI, AsyncAPI or gRPC specification.
  • binding.path is relative to the resolved endpoint.
Field Type Required Constraints
type string Yes Enum: http (only supported transport; any other value fails validation)
interface string Yes Must match a declared interfaces[].name: the interface whose platform binding provides the address and port (CAPABILITY_INTERFACE_UNKNOWN otherwise)
path string No Application path relative to the resolved endpoint. Must start with a single / and carry no scheme/host/fragment (CAPABILITY_PATH_INVALID otherwise)
capabilities:
  - type: health
    binding:
      type: http
      interface: rest-api
      path: /health
  - type: metrics
    binding:
      type: http
      interface: rest-api
      path: /metrics
  - type: extension
    ref: example.com/tracing

You can declare a health or metrics capability with no binding. Another collector can verify that declaration. The Kubernetes integration reports an unbound capability as Unsupported/Unknown because it has no endpoint to probe. An extension capability requires a namespaced ref and cannot declare a binding. Pacto has no evaluator for extensions, so it lists each one in coverage.unverified as capabilities[ref=<ref>] and excludes it from required assertions. A contract that declares one can still reach Compliant, and that verdict covers none of its extensions.


metadata

Optional. Free-form key-value pairs for organizational use. Pacto validates only the type.

metadata:
  team: payments
  tier: critical
  on-call: "#payments-oncall"

The schema sets additionalProperties: false at every level except inside metadata, so an unknown field fails validation.

Tip

metadata is a deliberate extension point for tooling. Platform teams use it to attach signals that their CI or deployment systems read from a contract. Provisioning adapters map a provider's service.offering to their implementation, so infrastructure contracts need no provider labels. See Infrastructure contracts.


extensions

Optional. A free-form object for forward-compatible, namespaced extension data outside the core contract model. Use metadata for organizational key-value pairs and extensions for structured data that future Pacto features or third-party tools interpret. Namespace each key, for example with a domain, to avoid collisions. In this release Pacto validates only the type.

extensions:
  example.com/custom-tool:
    enabled: true