AsyncAPI is an open, machine-readable specification for describing event-driven and message-based APIs, written as a YAML or JSON document that defines servers, channels, operations and message payloads. Among APIs in programming, it plays the role for asynchronous communication that OpenAPI plays for request-response HTTP interfaces: it is a contract that humans can read and tools can process.
The AsyncAPI specification is protocol-agnostic. The same document format can describe a Kafka topic, an MQTT broker, an AMQP exchange or a WebSocket stream, which lets teams document, validate, mock and generate code for systems in which producers and consumers never call each other directly but exchange messages through a broker.
How an AsyncAPI document describes a message flow
An AsyncAPI document describes who sends which message, to which address, over which protocol. It does not describe a server that answers calls; it describes an application’s view of a messaging system, including what that application publishes and what it expects to receive.
The document is organized into a small set of top-level objects. Each object answers a separate question, and reusable definitions live under components so that schemas, messages and bindings are written once and referenced with $ref pointers.
| Object | Question it answers | Typical content |
|---|---|---|
| info | What is this application | Title, version, description, license |
| servers | Where are the brokers | Host, protocol, security schemes |
| channels | Which addresses carry messages | Topic or queue name, parameters, message list |
| operations | What does the application do | Action send or receive, channel reference |
| messages | What travels on the wire | Headers, payload schema, content type |
| components | What is reused | Schemas, traits, bindings, security |
Bindings carry protocol-specific details that the generic model cannot express, such as a Kafka partition key, an MQTT quality-of-service level or an AMQP exchange type. Keeping these details in bindings lets the core of the document stay portable across brokers.
Versions of the AsyncAPI specification
The AsyncAPI specification has gone through two major redesigns, and the version declared in the asyncapi field changes how a document must be read. The project began in 2017 and is now hosted under the Linux Foundation, with a public, community-driven change process.
The most important change came with version 3.0, released in December 2023. Version 2 attached publish and subscribe keywords to channels, and their meaning was frequently misread because it described what other applications could do rather than what the documented application did.
| Aspect | AsyncAPI 2.x | AsyncAPI 3.0 |
|---|---|---|
| Operation semantics | Publish and subscribe, often inverted | Explicit send and receive actions |
| Channel and operation | Operations nested inside channels | Operations are a separate top-level object |
| Channel address | Channel key was the address | Separate address field, reusable channel IDs |
| Request and reply | Not modeled directly | Native reply object with dynamic addresses |
| Reuse | Limited reuse of channels | Channels and operations fully referenceable |
Migration is not automatic in every case. Tooling support for 3.0 has matured steadily, but some older generators and plugins still accept only 2.x documents, so teams should confirm tool compatibility before upgrading a large catalog.
AsyncAPI compared with related API description formats
AsyncAPI is best understood by contrast with the other contract formats used in API work. Each format targets a different interaction style, and many organizations maintain several formats side by side for the same product.
| Format | Interaction style | Typical transport | Main artifact |
|---|---|---|---|
| AsyncAPI | Event-driven, message-based | Kafka, MQTT, AMQP, WebSocket | Channels, operations, messages |
| OpenAPI | Synchronous request-response | HTTP | Paths, methods, responses |
| GraphQL SDL | Client-shaped queries | HTTP, WebSocket for subscriptions | Types, queries, mutations |
| Protocol Buffers for gRPC | Remote procedure calls and streams | HTTP/2 | Services, RPC methods |
| Webhook definitions | Server-initiated HTTP callbacks | HTTP | Event payload, callback URL |
The boundary with OpenAPI is the one most often blurred. OpenAPI 3.1 can describe webhooks, which are outbound HTTP events, but it has no concept of a broker, topic or consumer group. When messages pass through middleware rather than direct HTTP calls, AsyncAPI is the more accurate model. The two formats deliberately share the JSON Schema vocabulary, so payload schemas can be reused between them.
Tooling and the contract-first workflow
The practical value of AsyncAPI comes from tools that read the document. Because the format is machine-readable, one file can drive documentation, validation, code generation and testing, which supports an API-first design approach for event-driven systems.
- Parsers and validators check that a document conforms to the specification and resolve all references.
- Generators produce HTML documentation, Markdown and client or server skeletons from templates.
- Model generators such as Modelina create typed payload classes in languages like Java, TypeScript and Python.
- Studio editors render the document visually and show errors while it is being written.
- Mock servers and contract tests check that real producers emit messages matching the declared schema.
Payload schemas default to the AsyncAPI Schema format, a superset of JSON Schema. The schemaFormat field also allows Apache Avro and other formats, which matters for Kafka deployments that already keep Avro schemas in a schema registry.
Limitations and common mistakes with AsyncAPI
AsyncAPI describes structure, not runtime guarantees. It cannot by itself enforce delivery semantics, ordering or retention, and a document that looks complete may still hide operational assumptions that consumers need to know.
| Symptom | Likely cause | Recommended fix |
|---|---|---|
| Consumers misread direction | Version 2 publish and subscribe semantics | Migrate to 3.0 send and receive |
| Schema drift in production | Document not tied to the build | Validate messages in CI and at runtime |
| Huge, unreadable documents | One file for a whole platform | Split per application, share components |
| Missing broker details | Bindings left out | Add protocol bindings for each server |
| Breaking changes go unnoticed | No versioning policy for messages | Version payloads and diff documents |
A frequent misconception is that one AsyncAPI file should describe an entire event platform. The specification is designed around a single application’s perspective, so a platform is normally documented as several files whose channels and messages are linked through shared references.
The simple explanation
Many modern programs do not talk to each other directly. Instead, they drop messages into a shared mailbox system, and other programs pick them up later. AsyncAPI is a written rulebook for that mailbox system.
It lists which mailboxes exist, what each message must look like and which program sends or reads it. Because the rulebook follows a fixed format, computers can read it too, and they can produce documentation and starter code automatically. The key benefit is simple: every team agrees on the same message shapes before anything breaks.
How it is used in practice
An online grocery retailer runs its order system on Apache Kafka. When a customer pays, the checkout service emits an order.paid event, and the warehouse, invoicing and notification services all consume it. Before adopting AsyncAPI, each team kept its own notes about the payload, and a renamed field once stopped invoices for several hours.
The platform team now requires an AsyncAPI 3.0 document for every service. The checkout document declares a send operation on the order.paid channel, with an Avro payload and a Kafka binding that sets the customer ID as the partition key. The continuous integration pipeline validates each document, generates typed models for the consumers and rejects builds that change a payload incompatibly. Since the change, schema mismatches are caught during code review instead of in production.