AsyncAPI

Also known as: AsyncAPI specification

On this page 7

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.

ObjectQuestion it answersTypical content
infoWhat is this applicationTitle, version, description, license
serversWhere are the brokersHost, protocol, security schemes
channelsWhich addresses carry messagesTopic or queue name, parameters, message list
operationsWhat does the application doAction send or receive, channel reference
messagesWhat travels on the wireHeaders, payload schema, content type
componentsWhat is reusedSchemas, traits, bindings, security
Core objects of an AsyncAPI 3.0 document

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.

AspectAsyncAPI 2.xAsyncAPI 3.0
Operation semanticsPublish and subscribe, often invertedExplicit send and receive actions
Channel and operationOperations nested inside channelsOperations are a separate top-level object
Channel addressChannel key was the addressSeparate address field, reusable channel IDs
Request and replyNot modeled directlyNative reply object with dynamic addresses
ReuseLimited reuse of channelsChannels and operations fully referenceable
Main differences between AsyncAPI 2.x and 3.0

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 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.

FormatInteraction styleTypical transportMain artifact
AsyncAPIEvent-driven, message-basedKafka, MQTT, AMQP, WebSocketChannels, operations, messages
OpenAPISynchronous request-responseHTTPPaths, methods, responses
GraphQL SDLClient-shaped queriesHTTP, WebSocket for subscriptionsTypes, queries, mutations
Protocol Buffers for gRPCRemote procedure calls and streamsHTTP/2Services, RPC methods
Webhook definitionsServer-initiated HTTP callbacksHTTPEvent payload, callback URL
AsyncAPI and neighboring API description formats

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.

SymptomLikely causeRecommended fix
Consumers misread directionVersion 2 publish and subscribe semanticsMigrate to 3.0 send and receive
Schema drift in productionDocument not tied to the buildValidate messages in CI and at runtime
Huge, unreadable documentsOne file for a whole platformSplit per application, share components
Missing broker detailsBindings left outAdd protocol bindings for each server
Breaking changes go unnoticedNo versioning policy for messagesVersion payloads and diff documents
Frequent AsyncAPI problems, causes and fixes

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.