February 2026 edition
Open Event Contract (OEC) — Examples
Version: 0.1.0
Disclaimer: This document is non-normative and describes recommended practices for the OKHAM ecosystem.
This document provides real-world examples of OEC-conformant events.
Table of Contents
- User Lifecycle Event
- Order Payment Event
- Inventory Stock Event
- Error Event with Severity
- Event Chain with Causality
1. User Lifecycle Event
Scenario: A new user registers on a platform.
event: 0.1.0
id: user.lifecycle.created
name: User Created Event
version: 1.0.0
status: stable
source:
capability: user-management-service
instance: user-svc-node-2
version: 3.2.1
timestamp: 2026-01-16T10:30:00.000Z
classification:
domain: user.lifecycle
lifecycle: created
severity: info
scope: public
payload:
type: "https://okham.org/types/user/1.0.0"
data:
user_id: usr_abc123xyz
email: [email protected]
username: alice_smith
created_at: 2026-01-16T10:30:00Z
email_verified: false
account_type: free
Key Points:
- Past tense naming:
created, notcreate - Minimal causality (initial event in a flow)
- Public scope (can be consumed by analytics, notifications, etc.)
2. Order Payment Event
Scenario: A payment is successfully processed for an order.
event: 0.1.0
id: order.payment.processed
name: Order Payment Processed
version: 1.2.0
status: stable
source:
capability: payment-service
instance: payment-node-3
version: 4.1.2
timestamp: 2026-01-16T11:15:22.456Z
causality:
correlation_id: order-req-uuid-abc123
causation_id: cmd-process-payment-xyz789
trace_id: trace-dist-id-456
span_id: span-payment-proc
classification:
domain: order.payment
lifecycle: completed
severity: info
scope: public
category: financial.transaction
payload:
type: "https://okham.org/types/payment/1.0.0"
data:
order_id: ord_12345
payment_id: pay_67890
amount: 99.99
currency: USD
payment_method: credit_card
card_last_four: "4242"
status: completed
processed_at: 2026-01-16T11:15:22Z
gateway: stripe
transaction_id: txn_stripe_abc123
metadata:
region: us-west-2
idempotency_key: pay-idem-key-123
retry_count: 0
Key Points:
- Causality tracking links payment to original order request
- Financial domain with semantic category
- Includes metadata for idempotency and regional routing
- Sensitive data (full card number) excluded
3. Inventory Stock Event
Scenario: A product goes out of stock.
event: 0.1.0
id: inventory.stock.depleted
name: Stock Depleted Alert
version: 1.0.0
status: stable
source:
capability: inventory-service
instance: inventory-node-1
timestamp: 2026-01-16T12:45:10.000Z
causality:
correlation_id: order-fulfillment-uuid-xyz
causation_id: event-order-confirmed-abc
classification:
domain: inventory.stock
lifecycle: depleted
severity: warn
scope: internal
payload:
type: "https://okham.org/types/stock-level/1.0.0"
data:
product_id: prod_xyz789
sku: SKU-ABC-123
warehouse_id: warehouse_west_1
current_quantity: 0
previous_quantity: 5
threshold: 10
depleted_at: 2026-01-16T12:45:10Z
Key Points:
severity: warnindicates actionable alertscope: internallimits visibility to internal systems- Causation links to order fulfillment event
4. Error Event with Severity
Scenario: A critical service failure occurs.
event: 0.1.0
id: system.service.failed
name: Service Failed Event
version: 1.0.0
status: stable
source:
capability: database-service
instance: db-primary-node-1
version: 5.3.2
timestamp: 2026-01-16T14:22:35.789Z
causality:
correlation_id: health-check-cron-uuid
trace_id: trace-health-check-123
classification:
domain: system.service
lifecycle: failed
severity: critical
scope: internal
payload:
type: "https://okham.org/types/error/1.0.0"
data:
error_code: DB_CONNECTION_LOST
error_message: "Primary database connection lost after 3 retry attempts"
service_name: database-service
error_timestamp: 2026-01-16T14:22:35Z
retry_count: 3
last_successful_ping: 2026-01-16T14:20:00Z
health_status: unhealthy
metadata:
alert_sent: true
pagerduty_incident_id: PD-INC-12345
Key Points:
severity: criticaltriggers alerts and escalation- Error events are still facts (what failed, when, how)
- Metadata tracks incident management integration
5. Event Chain with Causality
Scenario: A sequence of related events in an order flow.
Event 1: Order Created
event: 0.1.0
id: order.lifecycle.created
name: Order Created
version: 1.0.0
status: stable
source:
capability: order-service
instance: order-svc-1
timestamp: 2026-01-16T15:00:00.000Z
causality:
correlation_id: order-flow-uuid-abc123
causation_id: user-action-add-to-cart-xyz
classification:
domain: order.lifecycle
lifecycle: created
severity: info
scope: public
payload:
type: "https://okham.org/types/order/1.0.0"
data:
order_id: ord_99999
user_id: usr_alice_123
total_amount: 150.00
currency: USD
items_count: 3
created_at: 2026-01-16T15:00:00Z
Event 2: Payment Processed (caused by Order Created)
event: 0.1.0
id: order.payment.processed
name: Order Payment Processed
version: 1.2.0
status: stable
source:
capability: payment-service
instance: payment-node-2
timestamp: 2026-01-16T15:00:15.000Z
causality:
correlation_id: order-flow-uuid-abc123
causation_id: event-order.lifecycle.created-ord_99999
trace_id: trace-order-flow-123
classification:
domain: order.payment
lifecycle: completed
severity: info
scope: public
payload:
type: "https://okham.org/types/payment/1.0.0"
data:
order_id: ord_99999
payment_id: pay_88888
amount: 150.00
currency: USD
status: completed
Event 3: Order Shipped (caused by Payment Processed)
event: 0.1.0
id: order.fulfillment.shipped
name: Order Shipped Event
version: 1.0.0
status: stable
source:
capability: fulfillment-service
instance: fulfillment-node-1
timestamp: 2026-01-16T15:30:00.000Z
causality:
correlation_id: order-flow-uuid-abc123
causation_id: event-order.payment.processed-pay_88888
trace_id: trace-order-flow-123
classification:
domain: order.fulfillment
lifecycle: shipped
severity: info
scope: public
payload:
type: "https://okham.org/types/shipment/1.0.0"
data:
order_id: ord_99999
shipment_id: ship_77777
carrier: FedEx
tracking_number: "1Z999AA10123456784"
shipped_at: 2026-01-16T15:30:00Z
Key Points:
- All three events share the same
correlation_id(order-flow-uuid-abc123) - Each event's
causation_idreferences the preceding event - Enables full traceability of the order lifecycle
6. Event Versioning Example
Scenario: An event schema evolves from v1.0.0 to v2.0.0 (breaking change).
Version 1.0.0 (Old)
event: 0.1.0
id: notification.email.sent
name: Email Sent Event
version: 1.0.0
status: deprecated
source:
capability: notification-service
timestamp: 2026-01-16T16:00:00Z
payload:
type: "https://okham.org/types/email-notification/1.0.0"
data:
to: [email protected]
subject: "Welcome to OKHAM"
sent_at: 2026-01-16T16:00:00Z
Version 2.0.0 (New - Breaking Change)
event: 0.1.0
id: notification.email.sent
name: Email Sent Event
version: 2.0.0
status: stable
source:
capability: notification-service
instance: notify-node-2
timestamp: 2026-01-16T16:00:00Z
payload:
type: "https://okham.org/types/email-notification/2.0.0"
data:
recipients: # BREAKING: Changed from 'to' to 'recipients' array
- email: [email protected]
name: Alice Smith
subject: "Welcome to OKHAM"
template_id: welcome-email-v2 # NEW FIELD
sent_at: 2026-01-16T16:00:00Z
delivery_status: sent # NEW FIELD
Key Points:
versionfield incremented to 2.0.0 (MAJOR change)- Old version marked
deprecated - Breaking change:
tofield replaced withrecipientsarray - New fields added:
template_id,delivery_status
Anti-Patterns (What NOT to Do)
❌ Command Instead of Event
id: user.create # WRONG: Imperative, not past tense
name: Create User Command # WRONG: This is a command, not an event
❌ Missing Required Fields
event: 0.1.0
id: order.created
# MISSING: version, status, source, timestamp, payload
❌ Transport Coupling
payload:
data:
kafka_topic: orders # WRONG: Should not reference transport
nats_subject: order.created # WRONG: Transport-specific
❌ Execution Logic
payload:
data:
execute_hook: send_email # WRONG: Events don't execute hooks
End of Examples