ZAF / CHAPTER 09 / 15

Integration, APIs and event contracts

Public reference edition 1.0 · 5 November 2026 · Fictional institutional example. No client outcome or deployment is claimed.

In this chapter
  1. 9.1 Distinguish a command from a fact
  2. 9.2 Contract fields and semantics
  3. 9.3 Commit and delivery sequence
  4. 9.4 Compatibility and partner onboarding
  5. 9.5 Verification matrix

9.1 Distinguish a command from a fact

A command asks an authority to decide or perform an action. An event describes a fact that has already occurred under a named authority. An API can carry either interaction; a broker does not turn an invalid fact into a valid one. In the worked example, ApproveRequest is a command directed to the request boundary. RequestApproved is a fact emitted only after a valid transition commits. A notification service may consume the fact but cannot change what was approved.

9.2 Contract fields and semantics

Contract elementRequired definitionFailure if omitted
Actor and organizational scopeDerived and checked by the authoritative serviceA valid account acts in the wrong department
Request ID and expected versionIdentify the object actually reviewedApproval silently targets changed content
Command identityScope, payload comparison and retentionRetry creates another business operation
Event identity and schema versionStable event ID and compatible meaningConsumers misinterpret or duplicate work
Failure responseRejection, conflict, retryable failure or unknown outcomeClient retries blindly

9.3 Commit and delivery sequence

Figure 9.1 · Command, atomic commit and deferred effects
Command, atomic commit and deferred effectsInvalid commands are rejected. Valid decisions commit before external delivery. Repeated delivery remains possible and requires idempotent handling.CommandActor, key, versionServer validationAuthority and stateAtomic transactionState, audit, outboxExplicit rejectionNo business mutationWorker and consumersRetries and deduplicationRecorded deliveryOutcome and exceptions
Invalid commands are rejected. Valid decisions commit before external delivery. Repeated delivery remains possible and requires idempotent handling.

Record the state change and outbox intention within one transaction. A worker claims committed work, delivers it and records progress. If delivery succeeds but acknowledgement is lost, processing may repeat. Consumers therefore require deduplication or idempotent effects; the outbox is not an end-to-end exactly-once guarantee. Ordering should be specified per business object when later facts depend on earlier ones. A global ordering requirement can impose unnecessary coordination. Decide how a consumer detects a missing predecessor, retries processing and exposes work that cannot proceed.

9.4 Compatibility and partner onboarding

Changing a field name is not the only breaking change. Reinterpreting “approved amount,” changing currency meaning or omitting an event for a previously included state can break a consumer without changing the schema shape. Maintain contract owner, version, example payloads, error catalogue and deprecation policy. Before a new integration is enabled, verify identity, permitted data, rate behaviour, timeout handling, replay behaviour and a named support route. Do not treat possession of an API key as agreement on business responsibility.

9.5 Verification matrix

  • Repeat the same command after an ambiguous timeout.
  • Change the payload while reusing its key and verify a defined refusal.
  • Deliver an event twice and verify one intended business effect.
  • Process a compatible old payload and reject an unsupported version clearly.
  • Interrupt the worker and recover pending work without losing its trace.

The output is a contract catalogue and testable interaction design. A broker or gateway purchase follows only when its capability is required and operated.