By the Octri team · Updated
AsyncAPI vs OpenAPI: what each one describes
AsyncAPI and OpenAPI both describe APIs in a YAML or JSON file. OpenAPI covers requests and responses over HTTP, and AsyncAPI covers messages sent through brokers and sockets, so this guide writes one invoice event both ways.
What is the difference between AsyncAPI and OpenAPI?
OpenAPI describes an API you call. A client sends a request to a path, the server answers, and the conversation is over. The spec lists every path, the methods each one accepts, the parameters, and the responses that can come back.
AsyncAPI describes an API that talks in messages. One application sends a message to a channel, such as a Kafka topic, an MQTT topic or a WebSocket connection, and any number of others receive it, now or later. Nobody waits for a reply. The spec lists the servers and protocols, the channels, what each application sends or receives on them, and what the messages look like.
Think about a phone call and a radio station. A phone call is OpenAPI: you dial a number, ask a question and wait for the answer. A radio station is AsyncAPI: it broadcasts on a frequency, and whoever is tuned in hears it. Both need a description of what's said, and that's where the two specs meet, because both describe message bodies with JSON Schema. The same InvoicePaid schema can sit in either file.
| OpenAPI | AsyncAPI | |
|---|---|---|
| Describes | Requests and responses | Messages sent and received |
| Transport | HTTP | Kafka, MQTT, AMQP, WebSocket, HTTP and others |
| Main parts | paths, operations, components |
servers, channels, operations, components |
| Who starts it | The client, every time | Whoever has something to say |
| Payloads | JSON Schema 2020-12, from 3.1 | A superset of JSON Schema draft 07, or a format named in schemaFormat |
| Latest version | 3.2.0, September 2025 | 3.1.0, January 2026 |
What AsyncAPI 3 describes
An AsyncAPI 3 document has eight top-level fields: asyncapi, id, info, servers, defaultContentType, channels, operations and components. Four of them do most of the work.
Servers say where the messages flow and how. Each one has a host and a protocol. The 3.0 specification lists AMQP, HTTP, JMS, Kafka, Anypoint MQ, MQTT, Solace, STOMP, Mercure, WebSocket, Google Pub/Sub and Pulsar as examples, and 3.1 adds ROS 2.
Channels are the places messages go. A channel's address is whatever the protocol calls it, which the specification describes as typically a topic name, a routing key, an event type or a path.
Operations say what your application does on a channel. The action is send or receive. AsyncAPI 2 put publish and subscribe operations inside each channel. Version 3.0.0, released on 5 December 2023, moved operations to their own top-level section, each pointing at its channel with a $ref.
Messages are what travels, with a payload schema, a content type and optional headers.
Here's one event in AsyncAPI 3.1. The billing service publishes a message to a Kafka topic every time a customer pays an invoice, and this file describes it from the point of view of an application that receives it.
asyncapi: 3.1.0
info:
title: Acme Billing Events
version: 1.0.0
servers:
production:
host: kafka.acme.example:9092
protocol: kafka
channels:
invoicePaid:
address: billing.invoice.paid
messages:
invoicePaid:
$ref: "#/components/messages/InvoicePaid"
operations:
onInvoicePaid:
action: receive
channel:
$ref: "#/channels/invoicePaid"
components:
messages:
InvoicePaid:
contentType: application/json
payload:
$ref: "#/components/schemas/InvoicePaid"
schemas:
InvoicePaid:
type: object
required: [type, invoice_id, amount_paid, currency, paid_at]
properties:
type: { type: string, const: invoice.paid }
invoice_id: { type: string }
amount_paid: { type: integer }
currency: { type: string }
paid_at: { type: string, format: date-time }The same event in OpenAPI: webhooks
OpenAPI has one place for messages your API sends out. OpenAPI 3.1.0 added a top-level webhooks field for the incoming webhooks an API consumer may receive and choose to implement. The 3.0 specification has no such field. A webhook is still HTTP, though. Your server sends a POST to a URL the customer gave you, and the customer's endpoint answers with a 2xx.
openapi: 3.1.0
info:
title: Acme Billing Webhooks
version: 1.0.0
webhooks:
invoice.paid:
post:
operationId: invoicePaid
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/InvoicePaid"
responses:
"200":
description: Any 2xx acknowledges the event.The InvoicePaid schema under components is the same one as in the AsyncAPI file. What differs is everything around it. The OpenAPI version says the event arrives as an HTTP request that expects an answer. The AsyncAPI version says it sits on a Kafka topic until a consumer reads it, and the producer never hears back.

What tools did with each file
A spec is only as useful as what reads it, so I ran both files through Octri while writing this guide.
The OpenAPI version went through the SDK generator, with the spec's root x-sdk-webhook-signature extension set to standard-webhooks. The generated TypeScript and Python SDKs each got a webhooks module with an InvoicePaid event type and an unwrapWebhook function (unwrap_webhook in Python). It checks the Standard Webhooks signature from the webhook-id, webhook-timestamp and webhook-signature headers with HMAC-SHA256, then decodes the body. I signed a test delivery with a made-up secret and fed it to the Python SDK. The signed delivery came back as an InvoicePaid with invoice_id set to inv_123. When I changed the amount in the body without re-signing, it failed with no_matching_signature, and a delivery with an hour-old timestamp failed with timestamp_too_old, since the default window is five minutes.
The AsyncAPI version took two paths. When Octri imports an AsyncAPI file into a project, it translates it to OpenAPI 3.1 on the way in. My onInvoicePaid operation became POST /billing.invoice.paid, with the message as both the request and the response body, the server as kafka://kafka.acme.example:9092, and the direction kept in an x-asyncapi-action: receive extension. An SDK generated from that gets a typed InvoicePaid model, which is the useful part. It also gets a method that would send the event over HTTP, which no Kafka broker will answer.
The free Spec Converter is stricter. It recognized the file as AsyncAPI, then blocked the conversion until I chose an HTTP method, path, server, response status and parameter bindings for onInvoicePaid. It won't guess how an event maps to a request.

That's the honest limit of describing events in an HTTP format. The schemas translate cleanly. The delivery doesn't, because a Kafka topic has no URL to POST to. For consuming the topic, you still write code against your Kafka client library, and the generated models give that code its types.
When to use AsyncAPI, OpenAPI or both
Use OpenAPI for any API a client calls over HTTP and gets an answer from, which covers most public APIs. Use its webhooks section for events you deliver to your customers' HTTPS endpoints, since those are HTTP requests too.
Use AsyncAPI when messages move through a broker or a long-lived connection. That covers Kafka topics between internal services, MQTT from devices, AMQP queues and WebSocket streams. AsyncAPI is the only one of the two that can say which topic, which protocol and which side sends.
Use both when an API has both kinds. A payments platform might have a REST API, webhooks to customers and Kafka events between its own services. Keep the payload schemas in one shared file and reference it from both specs with $ref, so an InvoicePaid means the same thing everywhere.
Rule of thumb: if the receiver is a URL someone gave you, it's a webhook, and OpenAPI describes it. If the receiver subscribes to a topic or a channel, AsyncAPI does.
AsyncAPI vs OpenAPI checklist
- Request and response endpoints are in OpenAPI, with every path, parameter and response.
- Events you send to customer URLs are in OpenAPI's
webhooks, with the signing scheme documented. - Events on a broker or socket are in AsyncAPI, with the server, protocol and channel address.
- Each AsyncAPI operation says
sendorreceivefrom your application's point of view. - Message payloads that appear in both specs come from one shared schema file.
- Webhook payloads carry an event type field, such as
type: invoice.paid, so receivers can tell events apart. - Your tools are tested on your files, so you know what they keep and what they drop.
AsyncAPI with Octri
Octri imports AsyncAPI 2 and 3 files alongside OpenAPI, Swagger 2.0 and Postman collections. Each AsyncAPI operation becomes an endpoint in the project, so SDK Studio generates a typed model for every message in ten languages, and API Studio gives each one a reference page with its payload. The original direction stays on each operation, and the free Spec Converter shows every mapping decision when you'd rather choose the HTTP side yourself.
For events you deliver over HTTPS, write them in OpenAPI's webhooks. SDK Studio generates an event type for each webhook, and with Standard Webhooks signing it adds a function that checks the signature and the timestamp before decoding the body, which is the part every receiver otherwise writes by hand. API Studio publishes a page for each event with its payload, the way the GitHub showcase below lists every action an Issues event can carry.
