liveBook · Manning

CloudEvents

As explained in The Design of Web APIs, Second Edition

CloudEvents is a protocol-agnostic standard specification for describing and exchanging event data across different technologies.

CloudEvents is a protocol-agnostic standard for describing and exchanging events across technologies. It improves interoperability and avoids inventing a provider-specific event format for webhooks and callbacks. section 14.6.4 section 16.2.1

A transaction notification

A banking notification sends a real-time HTTP request with Content-Type application/cloudevents+json. Its event object includes specversion 1.0, type com.banking.transaction.new, source /transactions, id 123456, and transaction-specific data. The concatenation of source and id uniquely identifies the event. section 14.6.4

Choose the event shape according to delivery and payload needs:

  • Send one event at a time for real-time notifications, or use application/cloudevents-batch+json for a JSON array of events. section 14.6.4
  • Use lightweight events that point to a resource when data is large or volatile; reserve heavyweight events for small, static data. section 14.7.2 section 14.9
  • Apply the same format to webhooks and callbacks, while offering retrieval alternatives when consumers cannot receive webhooks. section 14.7.2 section 14.9
Figure 14.8 The banking notification system notifies a consumer about a new transaction with a POST request whose body uses the CloudEvents format.
figure

Inspect the webhook POST example to connect CloudEvents fields with a consumer notification flow. section 14.6.4

How The Design of Web APIs, Second Edition covers it

How deep it goes
Defines content types, core event fields, uniqueness, and payload-weight trade-offs, but defers detailed event-specific data design.
Examples
Uses banking transaction notifications, account balance updates, and simulation-end callbacks.
What it assumes
Assumes webhook and callback design, HTTP requests, resource paths, and consumer/provider delivery roles.
What you can do after
Apply via HTTP webhooks or callbacks with interoperable event metadata and appropriately sized payloads.
How it connects
Connects webhooks, callbacks, HTTP, OpenAPI, polling, and resource-oriented event data.

Also explained in

Compare how 3 books explain CloudEvents →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of The Design of Web APIs, Second Edition. The section links point to the parts of the book it draws on.