Write an AsyncAPI 3.1.0 document: connect channels, messages, and operations
An AsyncAPI document is a machine-readable contract for a message-driven API: it describes the servers an application connects to, the channels it uses, the messages exchanged, and whether the documented application sends or receives them. This example documents a consumer receiving a signup event. It follows the current published AsyncAPI 3.1.0 specification; example host, topic, and fields are fictional.
An AsyncAPI document is a machine-readable contract for a message-driven API: it describes the servers an application connects to, the channels it uses, the messages exchanged, and whether the documented application sends or receives them. This example documents a consumer receiving a signup event. It follows the current published AsyncAPI 3.1.0 specification; example host, topic, and fields are fictional.
Keep the three concepts separate
A **channel** is an addressable communication point. Its map key is a document ID; its `address` is the runtime topic, routing key, event type, or path. They need not be identical.
A **message** describes a payload and optional application headers. Its payload can use an AsyncAPI Schema Object.
An **operation** describes what the application does through a channel. In v3, `action: receive` or `send` is from the documented application's perspective.
AsyncAPI 3 decouples channels, messages, and operations so multiple operations can reference a channel. Definitions under components become part of the contract only when referenced elsewhere.
Example consumer document
The YAML below describes an application receiving JSON signup events from a Kafka topic. It does not configure a broker, grant access, or generate consumer code.
asyncapi: 3.1.0
info:
title: User signup consumer
version: 1.0.0
defaultContentType: application/json
servers:
production:
host: broker.example.com:9092
protocol: kafka
channels:
userSignupChannel:
address: user.signedup
messages:
userSignup:
$ref: '#/components/messages/UserSignup'
operations:
receiveUserSignup:
action: receive
channel:
$ref: '#/channels/userSignupChannel'
messages:
- $ref: '#/channels/userSignupChannel/messages/userSignup'
components:
messages:
UserSignup:
name: UserSignup
title: User signed up
summary: Announces a new signup
contentType: application/json
payload:
type: object
additionalProperties: false
required: [eventId, userId, occurredAt]
properties:
eventId:
type: string
userId:
type: string
occurredAt:
type: string
format: date-timeThe top-level asyncapi is the specification version; info.version versions this API description. userSignupChannel is a document ID, while user.signedup is the address. The reusable message lives under components.messages and is referenced by the channel. The operation references the channel and, when listing messages, points to a message defined on that channel. If omitted, the operation processes every channel message.
Check direction and scope
Do not infer a consumer's send operation from the fact that a broker or producer publishes the event. Describe each application from its own perspective; the specification advises against mechanically deriving a receiver document from a sender one. If the channel address is unknown, leave it absent or null instead of inventing one. Add protocol bindings only for protocol-specific details; the common contract does not specify broker configuration, delivery guarantees, retries, retention, or runtime behavior.
Verify the document
Confirm your pinned parser, validator, Studio, or generator supports AsyncAPI 3.1.0; do not assume a 2.x tool understands v3.
Check channel IDs and addresses, then verify every operation's action and channel reference.
If `messages` is listed on an operation, ensure each reference points to that channel's message definition.
Compare payload examples with the schema and document operational policies elsewhere.
Run the project's pinned validator/CLI. Fix version and reference errors first; a valid description still does not prove a live broker connection or application behavior.
A successful document parses as 3.1.0 in the chosen tool and has connected channel, message, and operation references. This illustrative example was not run through a validator or broker.
Sources
[AsyncAPI Specification 3.1.0](https://www.asyncapi.com/docs/reference/specification/v3.1.0)
[AsyncAPI document structure](https://www.asyncapi.com/docs/concepts/asyncapi-document/structure)
[Adding messages](https://www.asyncapi.com/docs/concepts/asyncapi-document/adding-messages)
[Migrating from AsyncAPI 2.x to 3.x](https://www.asyncapi.com/docs/migration/migrating-to-v3)