3.0.0

Found an error? Have a suggestion?Edit this page on GitHub

What is new in v3.0.0? Have a look at the release notes.
Interested in release notes of other versions of the specification? Check list of release notes.

AsyncAPI Specification

Attribution

Part of this content has been taken from the great work done by the folks at the OpenAPI Initiative.

Version 3.0.0

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119.

The AsyncAPI Specification is licensed under The Apache License, Version 2.0.

Introduction

The AsyncAPI Specification is a project used to describe message-driven APIs in a machine-readable format. It’s protocol-agnostic, so you can use it for APIs that work over any protocol (e.g., AMQP, MQTT, WebSockets, Kafka, STOMP, HTTP, Mercure, etc).

The AsyncAPI Specification defines a set of fields that can be used in an AsyncAPI document to describe an application's API. The document may reference other files for additional details or shared fields, but it is typically a single, primary document that encapsulates the API description.

The AsyncAPI document SHOULD describe the operations an application performs. For instance, consider the following AsyncAPI definition snippet:

1channels:
2  userSignedUp:
3    # ...(redacted for brevity)
4operations:
5  onUserSignedUp:
6    action: receive
7    channel:
8      $ref: "#/channels/userSignedUp"

It means that the application will receive messages from the userSignedUp channel.

The AsyncAPI specification does not assume any kind of software topology, architecture or pattern. Therefore, a server MAY be a message broker, a web server or any other kind of computer program capable of sending and/or receiving data. However, AsyncAPI offers a mechanism called "bindings" that aims to help with more specific information about the protocol.

It's NOT RECOMMENDED to derive a receiver AsyncAPI document from a sender one or vice versa. There are no guarantees that the channel used by an application to receive messages will be the same channel where another application is sending them. Also, certain fields in the document like summary, description, and the id of the operation might stop making sense. For instance, given the following receiver snippet:

1operations:
2  onUserSignedUp:
3    summary: On user signed up.
4    description: Event received when a user signed up on the product.
5    action: receive
6    channel:
7      $ref: "#/channels/userSignedUp"

We can't automatically assume that an opposite application exists by simply replacing receive with send:

1operations:
2  onUserSignedUp: # <-- This doesn't make sense now. Should be something like sendUserSignedUp.
3    summary: On user signed up. # <-- This doesn't make sense now. Should say something like "Sends a user signed up event".
4    description: Event received when a user signed up on the product. # <-- This doesn't make sense now. Should speak about sending an event, not receiving it.
5    action: send
6    channel:
7      $ref: "#/channels/userSignedUp"

Aside from the issues mentioned above, there may also be infrastructure configuration that is not represented here. For instance, a system may use a read-only channel for receiving messages, a different one for sending them, and an intermediary process that will forward messages from one channel to the other.

Definitions

Server

A server MAY be a message broker that is capable of sending and/or receiving between a sender and receiver. A server MAY be a service with WebSocket API that enables message-driven communication between browser-to-server or server-to-server.

Application

An application is any kind of computer program or a group of them. It MUST be a sender, a receiver, or both. An application MAY be a microservice, IoT device (sensor), mainframe process, message broker, etc. An application MAY be written in any number of different programming languages as long as they support the selected protocol. An application MUST also use a protocol supported by the server in order to connect and exchange messages.

Sender

A sender is a type of application, that is sending messages to channels. A sender MAY send to multiple channels depending on the server, protocol, and use-case pattern.

Receiver

A receiver is a type of application that is receiving messages from channels. A receiver MAY receive from multiple channels depending on the server, protocol, and the use-case pattern. A receiver MAY forward a received message further without changing it. A receiver MAY act as a consumer and react to the message. A receiver MAY act as a processor that, for example, aggregates multiple messages in one and forwards them.

Message

A message is the mechanism by which information is exchanged via a channel between servers and applications. A message MAY contain a payload and MAY also contain headers. The headers MAY be subdivided into protocol-defined headers and header properties defined by the application which can act as supporting metadata. The payload contains the data, defined by the application, which MUST be serialized into a format (JSON, XML, Avro, binary, etc.). Since a message is a generic mechanism, it can support multiple interaction patterns such as event, command, request, or response.

Channel

A channel is an addressable component, made available by the server, for the organization of messages. Sender applications send messages to channels and receiver applications receive messages from channels. Servers MAY support many channel instances, allowing messages with different content to be addressed to different channels. Depending on the server implementation, the channel MAY be included in the message via protocol-defined headers.

Protocol

A protocol is the mechanism (wireline protocol or API) by which messages are exchanged between the application and the channel. Example protocols include, but are not limited to, AMQP, HTTP, JMS, Kafka, Anypoint MQ, MQTT, Solace, STOMP, Mercure, WebSocket, Google Pub/Sub, Pulsar.

Bindings

A "binding" (or "protocol binding") is a mechanism to define protocol-specific information. Therefore, a protocol binding MUST define protocol-specific information only.

Specification

Format

The files describing the message-driven API in accordance with the AsyncAPI Specification are represented as JSON objects and conform to the JSON standards. YAML, being a superset of JSON, can be used as well to represent a A2S (AsyncAPI Specification) file.

For example, if a field is said to have an array value, the JSON array representation will be used:

1{
2   "field" : [...]
3}

While the API is described using JSON it does not impose a JSON input/output to the API itself.

All field names in the specification are case sensitive.

The schema exposes two types of fields. Fixed fields, which have a declared name, and Patterned fields, which declare a regex pattern for the field name. Patterned fields can have multiple occurrences as long as each has a unique name.

In order to preserve the ability to round-trip between YAML and JSON formats, YAML version 1.2 is recommended along with some additional constraints:

  • Tags MUST be limited to those allowed by the JSON Schema ruleset
  • Keys used in YAML maps MUST be limited to a scalar string, as defined by the YAML Failsafe schema ruleset

File Structure

An AsyncAPI document MAY be made up of a single document or be divided into multiple, connected parts at the discretion of the author. In the latter case, Reference Objects are used.

It is important to note that everything that is defined in an AsyncAPI document MUST be used by the implemented Application, with the exception of the Components Object. Everything that is defined inside the Components Object represents a resource that MAY or MAY NOT be used by the implemented Application.

By convention, the AsyncAPI Specification (A2S) file is named asyncapi.json or asyncapi.yaml.

Absolute URLs

Unless specified otherwise, all properties that are absolute URLs are defined by RFC3986, section 4.3.

Schema

AsyncAPI Object

This is the root document object for the API specification. It combines resource listing and API declaration together into one document.

Fixed Fields
Field NameTypeDescription
asyncapiAsyncAPI Version StringREQUIRED. Specifies the AsyncAPI Specification version being used. It can be used by tooling Specifications and clients to interpret the version. The structure shall be major.minor.patch, where patch versions must be compatible with the existing major.minor tooling. Typically patch versions will be introduced to address errors in the documentation, and tooling should typically be compatible with the corresponding major.minor (1.0.*). Patch versions will correspond to patches of this document.
idIdentifierIdentifier of the application the AsyncAPI document is defining.
infoInfo ObjectREQUIRED. Provides metadata about the API. The metadata can be used by the clients if needed.
serversServers ObjectProvides connection details of servers.
defaultContentTypeDefault Content TypeDefault content type to use when encoding/decoding a message's payload.
channelsChannels ObjectThe channels used by this application.
operationsOperations ObjectThe operations this application MUST implement.
componentsComponents ObjectAn element to hold various reusable objects for the specification. Everything that is defined inside this object represents a resource that MAY or MAY NOT be used in the rest of the document and MAY or MAY NOT be used by the implemented Application.

This object MAY be extended with Specification Extensions.

AsyncAPI Version String

The version string signifies the version of the AsyncAPI Specification that the document complies to. The format for this string must be major.minor.patch. The patch may be suffixed by a hyphen and extra alphanumeric characters.

A major.minor shall be used to designate the AsyncAPI Specification version, and will be considered compatible with the AsyncAPI Specification specified by that major.minor version. The patch version will not be considered by tooling, making no distinction between 1.0.0 and 1.0.1.

In subsequent versions of the AsyncAPI Specification, care will be given such that increments of the minor version should not interfere with operations of tooling developed to a lower minor version. Thus a hypothetical 1.1.0 specification should be usable with tooling designed for 1.0.0.

Identifier

This field represents a unique universal identifier of the application the AsyncAPI document is defining. It must conform to the URI format, according to RFC3986.

It is RECOMMENDED to use a URN to globally and uniquely identify the application during long periods of time, even after it becomes unavailable or ceases to exist.

Examples
1{
2  "id": "urn:example:com:smartylighting:streetlights:server"
3}
id: 'urn:example:com:smartylighting:streetlights:server'
1{
2  "id": "https://github.com/smartylighting/streetlights-server"
3}
id: 'https://github.com/smartylighting/streetlights-server'

Info Object

The object provides metadata about the API. The metadata can be used by the clients if needed.

Fixed Fields
Field NameTypeDescription
titlestringREQUIRED. The title of the application.
versionstringREQUIRED Provides the version of the application API (not to be confused with the specification version).
descriptionstringA short description of the application. CommonMark syntax can be used for rich text representation.
termsOfServicestringA URL to the Terms of Service for the API. This MUST be in the form of an absolute URL.
contactContact ObjectThe contact information for the exposed API.
licenseLicense ObjectThe license information for the exposed API.
tagsTags ObjectA list of tags for application API documentation control. Tags can be used for logical grouping of applications.
externalDocsExternal Documentation Object | Reference ObjectAdditional external documentation of the exposed API.

This object MAY be extended with Specification Extensions.

Info Object Example
1{
2  "title": "AsyncAPI Sample App",
3  "version": "1.0.1",
4  "description": "This is a sample app.",
5  "termsOfService": "https://asyncapi.org/terms/",
6  "contact": {
7    "name": "API Support",
8    "url": "https://www.asyncapi.org/support",
9    "email": "support@asyncapi.org"
10  },
11  "license": {
12    "name": "Apache 2.0",
13    "url": "https://www.apache.org/licenses/LICENSE-2.0.html"
14  },
15  "externalDocs": {
16    "description": "Find more info here",
17    "url": "https://www.asyncapi.org"
18  },
19  "tags": [
20    {
21      "name": "e-commerce"
22    }
23  ]
24}
1title: AsyncAPI Sample App
2version: 1.0.1
3description: This is a sample app.
4termsOfService: https://asyncapi.org/terms/
5contact:
6  name: API Support
7  url: https://www.asyncapi.org/support
8  email: support@asyncapi.org
9license:
10  name: Apache 2.0
11  url: https://www.apache.org/licenses/LICENSE-2.0.html
12externalDocs:
13  description: Find more info here
14  url: https://www.asyncapi.org
15tags:
16  - name: e-commerce

Contact Object

Contact information for the exposed API.

Fixed Fields
Field NameTypeDescription
namestringThe identifying name of the contact person/organization.
urlstringThe URL pointing to the contact information. This MUST be in the form of an absolute URL.
emailstringThe email address of the contact person/organization. MUST be in the format of an email address.

This object MAY be extended with Specification Extensions.

Contact Object Example
1{
2  "name": "API Support",
3  "url": "https://www.example.com/support",
4  "email": "support@example.com"
5}
1name: API Support
2url: https://www.example.com/support
3email: support@example.com

License Object

License information for the exposed API.

Fixed Fields
Field NameTypeDescription
namestringREQUIRED. The license name used for the API.
urlstringA URL to the license used for the API. This MUST be in the form of an absolute URL.

This object MAY be extended with Specification Extensions.

License Object Example
1{
2  "name": "Apache 2.0",
3  "url": "https://www.apache.org/licenses/LICENSE-2.0.html"
4}
1name: Apache 2.0
2url: https://www.apache.org/licenses/LICENSE-2.0.html

Servers Object

The Servers Object is a map of Server Objects.

Patterned Fields
Field PatternTypeDescription
^[A-Za-z0-9_\-]+$Server Object | Reference ObjectThe definition of a server this application MAY connect to.
Servers Object Example
1{
2  "development": {
3    "host": "localhost:5672",
4    "description": "Development AMQP broker.",
5    "protocol": "amqp",
6    "protocolVersion": "0-9-1",
7    "tags": [
8      { 
9        "name": "env:development",
10        "description": "This environment is meant for developers to run their own tests."
11      }
12    ]
13  },
14  "staging": {
15    "host": "rabbitmq-staging.in.mycompany.com:5672",
16    "description": "RabbitMQ broker for the staging environment.",
17    "protocol": "amqp",
18    "protocolVersion": "0-9-1",
19    "tags": [
20      { 
21        "name": "env:staging",
22        "description": "This environment is a replica of the production environment."
23      }
24    ]
25  },
26  "production": {
27    "host": "rabbitmq.in.mycompany.com:5672",
28    "description": "RabbitMQ broker for the production environment.",
29    "protocol": "amqp",
30    "protocolVersion": "0-9-1",
31    "tags": [
32      { 
33        "name": "env:production",
34        "description": "This environment is the live environment available for final users."
35      }
36    ]
37  }
38}
1development:
2  host: localhost:5672
3  description: Development AMQP broker.
4  protocol: amqp
5  protocolVersion: 0-9-1
6  tags:
7    - name: "env:development"
8      description: "This environment is meant for developers to run their own tests."
9staging:
10  host: rabbitmq-staging.in.mycompany.com:5672
11  description: RabbitMQ broker for the staging environment.
12  protocol: amqp
13  protocolVersion: 0-9-1
14  tags:
15    - name: "env:staging"
16      description: "This environment is a replica of the production environment."
17production:
18  host: rabbitmq.in.mycompany.com:5672
19  description: RabbitMQ broker for the production environment.
20  protocol: amqp
21  protocolVersion: 0-9-1
22  tags:
23    - name: "env:production"
24      description: "This environment is the live environment available for final users."

Server Object

An object representing a message broker, a server or any other kind of computer program capable of sending and/or receiving data. This object is used to capture details such as URIs, protocols and security configuration. Variable substitution can be used so that some details, for example usernames and passwords, can be injected by code generation tools.

Fixed Fields
Field NameTypeDescription
hoststringREQUIRED. The server host name. It MAY include the port. This field supports Server Variables. Variable substitutions will be made when a variable is named in {braces}.
protocolstringREQUIRED. The protocol this server supports for connection.
protocolVersionstringThe version of the protocol used for connection. For instance: AMQP 0.9.1, HTTP 2.0, Kafka 1.0.0, etc.
pathnamestringThe path to a resource in the host. This field supports Server Variables. Variable substitutions will be made when a variable is named in {braces}.
descriptionstringAn optional string describing the server. CommonMark syntax MAY be used for rich text representation.
titlestringA human-friendly title for the server.
summarystringA short summary of the server.
variablesMap[string, Server Variable Object | Reference Object]]A map between a variable name and its value. The value is used for substitution in the server's host and pathname template.
security[Security Scheme Object | Reference Object]A declaration of which security schemes can be used with this server. The list of values includes alternative security scheme objects that can be used. Only one of the security scheme objects need to be satisfied to authorize a connection or operation.
tagsTags ObjectA list of tags for logical grouping and categorization of servers.
externalDocsExternal Documentation Object | Reference ObjectAdditional external documentation for this server.
bindingsServer Bindings Object | Reference ObjectA map where the keys describe the name of the protocol and the values describe protocol-specific definitions for the server.
Server Object Example

A single server would be described as:

1{
2  "host": "kafka.in.mycompany.com:9092",
3  "description": "Production Kafka broker.",
4  "protocol": "kafka",
5  "protocolVersion": "3.2"
6}
1host: kafka.in.mycompany.com:9092
2description: Production Kafka broker.
3protocol: kafka
4protocolVersion: '3.2'

An example of a server that has a pathname:

1{
2  "host": "rabbitmq.in.mycompany.com:5672",
3  "pathname": "/production",
4  "protocol": "amqp",
5  "description": "Production RabbitMQ broker (uses the `production` vhost)."
6}
1host: rabbitmq.in.mycompany.com:5672
2pathname: /production
3protocol: amqp
4description: Production RabbitMQ broker (uses the `production` vhost).

Server Variable Object

An object representing a Server Variable for server URL template substitution.

Fixed Fields
Field NameTypeDescription
enum[string]An enumeration of string values to be used if the substitution options are from a limited set.
defaultstringThe default value to use for substitution, and to send, if an alternate value is not supplied.
descriptionstringAn optional description for the server variable. CommonMark syntax MAY be used for rich text representation.
examples[string]An array of examples of the server variable.

This object MAY be extended with Specification Extensions.

Server Variable Object Example
1{
2  "host": "rabbitmq.in.mycompany.com:5672",
3  "pathname": "/{env}",
4  "protocol": "amqp",
5  "description": "RabbitMQ broker. Use the `env` variable to point to either `production` or `staging`.",
6  "variables": {
7    "env": {
8      "description": "Environment to connect to. It can be either `production` or `staging`.",
9      "enum": [
10        "production",
11        "staging"
12      ]
13    }
14  }
15}
1host: 'rabbitmq.in.mycompany.com:5672'
2pathname: '/{env}'
3protocol: amqp
4description: RabbitMQ broker. Use the `env` variable to point to either `production` or `staging`.
5variables:
6  env:
7    description: Environment to connect to. It can be either `production` or `staging`.
8    enum:
9      - production
10      - staging

Default Content Type

A string representing the default content type to use when encoding/decoding a message's payload. The value MUST be a specific media type (e.g. application/json). This value MUST be used by schema parsers when the contentType property is omitted.

In case a message can't be encoded/decoded using this value, schema parsers MUST use their default content type.

Default Content Type Example
1{
2  "defaultContentType": "application/json"
3}
defaultContentType: application/json

Channels Object

An object containing all the Channel Object definitions the Application MUST use during runtime.

Patterned Fields
Field PatternTypeDescription
{channelId}Channel Object | Reference ObjectAn identifier for the described channel. The channelId value is case-sensitive. Tools and libraries MAY use the channelId to uniquely identify a channel, therefore, it is RECOMMENDED to follow common programming naming conventions.
Channels Object Example
1{
2  "userSignedUp": {
3    "address": "user.signedup",
4    "messages": {
5      "userSignedUp": {
6        "$ref": "#/components/messages/userSignedUp"
7      }
8    }
9  }
10}
1userSignedUp:
2  address: 'user.signedup'
3  messages:
4    userSignedUp:
5      $ref: '#/components/messages/userSignedUp'

Channel Object

Describes a shared communication channel.

Fixed Fields
Field NameTypeDescription
addressstring | nullAn optional string representation of this channel's address. The address is typically the "topic name", "routing key", "event type", or "path". When null or absent, it MUST be interpreted as unknown. This is useful when the address is generated dynamically at runtime or can't be known upfront. It MAY contain Channel Address Expressions. Query parameters and fragments SHALL NOT be used, instead use bindings to define them.
messagesMessages ObjectA map of the messages that will be sent to this channel by any application at any time. Every message sent to this channel MUST be valid against one, and only one, of the message objects defined in this map.
titlestringA human-friendly title for the channel.
summarystringA short summary of the channel.
descriptionstringAn optional description of this channel. CommonMark syntax can be used for rich text representation.
servers[Reference Object]An array of $ref pointers to the definition of the servers in which this channel is available. If the channel is located in the root Channels Object, it MUST point to a subset of server definitions located in the root Servers Object, and MUST NOT point to a subset of server definitions located in the Components Object or anywhere else. If the channel is located in the Components Object, it MAY point to a Server Objects in any location. If servers is absent or empty, this channel MUST be available on all the servers defined in the Servers Object. Please note the servers property value MUST be an array of Reference Objects and, therefore, MUST NOT contain an array of Server Objects. However, it is RECOMMENDED that parsers (or other software) dereference this property for a better development experience.
parametersParameters ObjectA map of the parameters included in the channel address. It MUST be present only when the address contains Channel Address Expressions.
tagsTags ObjectA list of tags for logical grouping of channels.
externalDocsExternal Documentation Object | Reference ObjectAdditional external documentation for this channel.
bindingsChannel Bindings Object | Reference ObjectA map where the keys describe the name of the protocol and the values describe protocol-specific definitions for the channel.

This object MAY be extended with Specification Extensions.

Channel Object Example
1{
2  "address": "users.{userId}",
3  "title": "Users channel",
4  "description": "This channel is used to exchange messages about user events.",
5  "messages": {
6    "userSignedUp": {
7      "$ref": "#/components/messages/userSignedUp"
8    },
9    "userCompletedOrder": {
10      "$ref": "#/components/messages/userCompletedOrder"
11    }
12  },
13  "parameters": {
14    "userId": {
15      "$ref": "#/components/parameters/userId"
16    }
17  },
18  "servers": [
19    { "$ref": "#/servers/rabbitmqInProd" },
20    { "$ref": "#/servers/rabbitmqInStaging" }
21  ],
22  "bindings": {
23    "amqp": {
24      "is": "queue",
25      "queue": {
26        "exclusive": true
27      }
28    }
29  },
30  "tags": [{
31    "name": "user",
32    "description": "User-related messages"
33  }],
34  "externalDocs": {
35    "description": "Find more info here",
36    "url": "https://example.com"
37  }
38}
1address: 'users.{userId}'
2title: Users channel
3description: This channel is used to exchange messages about user events.
4messages:
5  userSignedUp:
6    $ref: '#/components/messages/userSignedUp'
7  userCompletedOrder:
8    $ref: '#/components/messages/userCompletedOrder'
9parameters:
10  userId:
11    $ref: '#/components/parameters/userId'
12servers:
13  - $ref: '#/servers/rabbitmqInProd'
14  - $ref: '#/servers/rabbitmqInStaging'
15bindings:
16  amqp:
17    is: queue
18    queue:
19      exclusive: true
20tags:
21  - name: user
22    description: User-related messages
23externalDocs:
24  description: 'Find more info here'
25  url: 'https://example.com'

Channel Address Expressions

Channel addresses MAY contain expressions that can be used to define dynamic values.

Expressions MUST be composed by a name enclosed in curly braces ({ and }). E.g., {userId}.

Messages Object

Describes a map of messages included in a channel.

Patterned Fields
Field PatternTypeDescription
{messageId}Message Object | Reference ObjectThe key represents the message identifier. The messageId value is case-sensitive. Tools and libraries MAY use the messageId value to uniquely identify a message, therefore, it is RECOMMENDED to follow common programming naming conventions.
Messages Object Example
1{
2  "userSignedUp": {
3    "$ref": "#/components/messages/userSignedUp"
4  },
5  "userCompletedOrder": {
6    "$ref": "#/components/messages/userCompletedOrder"
7  }
8}
1userSignedUp:
2  $ref: '#/components/messages/userSignedUp'
3userCompletedOrder:
4  $ref: '#/components/messages/userCompletedOrder'

Operations Object

Holds a dictionary with all the operations this application MUST implement.

If you're looking for a place to define operations that MAY or MAY NOT be implemented by the application, consider defining them in components/operations.

Patterned Fields
Field PatternTypeDescription
{operationId}Operation Object | Reference ObjectThe operation this application MUST implement. The field name (operationId) MUST be a string used to identify the operation in the document where it is defined, and its value is case-sensitive. Tools and libraries MAY use the operationId to uniquely identify an operation, therefore, it is RECOMMENDED to follow common programming naming conventions.
Operations Object Example
1{
2  "onUserSignUp": {
3    "title": "User sign up",
4    "summary": "Action to sign a user up.",
5    "description": "A longer description",
6    "channel": {
7      "$ref": "#/channels/userSignup"
8    },
9    "action": "send",
10    "tags": [
11      { "name": "user" },
12      { "name": "signup" },
13      { "name": "register" }
14    ],
15    "bindings": {
16      "amqp": {
17        "ack": false
18      }
19    },
20    "traits": [
21      { "$ref": "#/components/operationTraits/kafka" }
22    ]
23  }
24}
1onUserSignUp:
2  title: User sign up
3  summary: Action to sign a user up.
4  description: A longer description
5  channel:
6    $ref: '#/channels/userSignup'
7  action: send
8  tags:
9    - name: user
10    - name: signup
11    - name: register
12  bindings:
13    amqp:
14      ack: false
15  traits:
16    - $ref: '#/components/operationTraits/kafka'

Operation Object

Describes a specific operation.

Fixed Fields
Field NameTypeDescription
action"send" | "receive"Required. Use send when it's expected that the application will send a message to the given channel, and receive when the application should expect receiving messages from the given channel.
channelReference ObjectRequired. A $ref pointer to the definition of the channel in which this operation is performed. If the operation is located in the root Operations Object, it MUST point to a channel definition located in the root Channels Object, and MUST NOT point to a channel definition located in the Components Object or anywhere else. If the operation is located in the Components Object, it MAY point to a Channel Object in any location. Please note the channel property value MUST be a Reference Object and, therefore, MUST NOT contain a Channel Object. However, it is RECOMMENDED that parsers (or other software) dereference this property for a better development experience.
titlestringA human-friendly title for the operation.
summarystringA short summary of what the operation is about.
descriptionstringA verbose explanation of the operation. CommonMark syntax can be used for rich text representation.
security[Security Scheme Object | Reference Object]A declaration of which security schemes are associated with this operation. Only one of the security scheme objects MUST be satisfied to authorize an operation. In cases where Server Security also applies, it MUST also be satisfied.
tagsTags ObjectA list of tags for logical grouping and categorization of operations.
externalDocsExternal Documentation Object | Reference ObjectAdditional external documentation for this operation.
bindingsOperation Bindings Object | Reference ObjectA map where the keys describe the name of the protocol and the values describe protocol-specific definitions for the operation.
traits[Operation Trait Object | Reference Object ]A list of traits to apply to the operation object. Traits MUST be merged using traits merge mechanism. The resulting object MUST be a valid Operation Object.
messages[Reference Object]A list of $ref pointers pointing to the supported Message Objects that can be processed by this operation. It MUST contain a subset of the messages defined in the channel referenced in this operation, and MUST NOT point to a subset of message definitions located in the Messages Object in the Components Object or anywhere else. Every message processed by this operation MUST be valid against one, and only one, of the message objects referenced in this list. Please note the messages property value MUST be a list of Reference Objects and, therefore, MUST NOT contain Message Objects. However, it is RECOMMENDED that parsers (or other software) dereference this property for a better development experience.
replyOperation Reply Object | Reference ObjectThe definition of the reply in a request-reply operation.

This object MAY be extended with Specification Extensions.

Operation Object Example
1{
2  "title": "User sign up",
3  "summary": "Action to sign a user up.",
4  "description": "A longer description",
5  "channel": {
6    "$ref": "#/channels/userSignup"
7  },
8  "action": "send",
9  "security": [
10    {
11     "petstore_auth": [
12       "write:pets",
13       "read:pets"
14     ]
15    }
16  ],
17  "tags": [
18    { "name": "user" },
19    { "name": "signup" },
20    { "name": "register" }
21  ],
22  "bindings": {
23    "amqp": {
24      "ack": false
25    }
26  },
27  "traits": [
28    { "$ref": "#/components/operationTraits/kafka" }
29  ],
30  "messages": [
31    { "$ref": "/components/messages/userSignedUp" }
32  ],
33  "reply": {
34    "address": {
35      "location": "$message.header#/replyTo"
36    },
37    "channel": {
38      "$ref": "#/channels/userSignupReply"
39    },
40    "messages": [
41      { "$ref": "/components/messages/userSignedUpReply" }
42    ],
43  }
44}
1title: User sign up
2summary: Action to sign a user up.
3description: A longer description
4channel:
5  $ref: '#/channels/userSignup'
6action: send
7security:
8  - petstore_auth:
9    - write:pets
10    - read:pets
11tags:
12  - name: user
13  - name: signup
14  - name: register
15bindings:
16  amqp:
17    ack: false
18traits:
19  - $ref: "#/components/operationTraits/kafka"
20messages:
21  - $ref: '#/components/messages/userSignedUp'
22reply:
23  address:
24    location: '$message.header#/replyTo'
25  channel:
26    $ref: '#/channels/userSignupReply'
27  messages:
28    - $ref: '#/components/messages/userSignedUpReply'

Operation Trait Object

Describes a trait that MAY be applied to an Operation Object. This object MAY contain any property from the Operation Object, except the action, channel, messages and traits ones.

If you're looking to apply traits to a message, see the Message Trait Object.

Fixed Fields
Field NameTypeDescription
titlestringA human-friendly title for the operation.
summarystringA short summary of what the operation is about.
descriptionstringA verbose explanation of the operation. CommonMark syntax can be used for rich text representation.
security[Security Scheme Object | Reference Object]A declaration of which security schemes are associated with this operation. Only one of the security scheme objects MUST be satisfied to authorize an operation. In cases where Server Security also applies, it MUST also be satisfied.
tagsTags ObjectA list of tags for logical grouping and categorization of operations.
externalDocsExternal Documentation Object | Reference ObjectAdditional external documentation for this operation.
bindingsOperation Bindings Object | Reference ObjectA map where the keys describe the name of the protocol and the values describe protocol-specific definitions for the operation.

This object MAY be extended with Specification Extensions.

Operation Trait Object Example
1{
2  "bindings": {
3    "amqp": {
4      "ack": false
5    }
6  }
7}
1bindings:
2  amqp:
3    ack: false

Operation Reply Object

Describes the reply part that MAY be applied to an Operation Object. If an operation implements the request/reply pattern, the reply object represents the response message.

Fixed Fields
Field NameTypeDescription
addressOperation Reply Address Object | Reference ObjectDefinition of the address that implementations MUST use for the reply.
channelReference ObjectA $ref pointer to the definition of the channel in which this operation is performed. When address is specified, the address property of the channel referenced by this property MUST be either null or not defined. If the operation reply is located inside a root Operation Object, it MUST point to a channel definition located in the root Channels Object, and MUST NOT point to a channel definition located in the Components Object or anywhere else. If the operation reply is located inside an [Operation Object] in the Components Object or in the Replies Object in the Components Object, it MAY point to a Channel Object in any location. Please note the channel property value MUST be a Reference Object and, therefore, MUST NOT contain a Channel Object. However, it is RECOMMENDED that parsers (or other software) dereference this property for a better development experience.
messages[Reference Object]A list of $ref pointers pointing to the supported Message Objects that can be processed by this operation as reply. It MUST contain a subset of the messages defined in the channel referenced in this operation reply, and MUST NOT point to a subset of message definitions located in the Components Object or anywhere else. Every message processed by this operation MUST be valid against one, and only one, of the message objects referenced in this list. Please note the messages property value MUST be a list of Reference Objects and, therefore, MUST NOT contain Message Objects. However, it is RECOMMENDED that parsers (or other software) dereference this property for a better development experience.

This object MAY be extended with Specification Extensions.

Operation Reply Address Object

An object that specifies where an operation has to send the reply.

For specifying and computing the location of a reply address, a runtime expression is used.

Fixed Fields
Field NameTypeDescription
descriptionstringAn optional description of the address. CommonMark syntax can be used for rich text representation.
locationstringREQUIRED. A runtime expression that specifies the location of the reply address.

This object MAY be extended with Specification Extensions.

Examples
1{
2  "description": "Consumer inbox",
3  "location": "$message.header#/replyTo"
4}
1description: Consumer Inbox
2location: $message.header#/replyTo

Parameters Object

Describes a map of parameters included in a channel address.

This map MUST contain all the parameters used in the parent channel address.

Patterned Fields
Field PatternTypeDescription
^[A-Za-z0-9_\-]+$Parameter Object | Reference ObjectThe key represents the name of the parameter. It MUST match the parameter name used in the parent channel address.
Parameters Object Example
1{
2  "address": "user/{userId}/signedup",
3  "parameters": {
4    "userId": {
5      "description": "Id of the user."
6    }
7  }
8}
1address: user/{userId}/signedup
2parameters:
3  userId:
4    description: Id of the user.

Parameter Object

Describes a parameter included in a channel address.

Fixed Fields
Field NameTypeDescription
enum[string]An enumeration of string values to be used if the substitution options are from a limited set.
defaultstringThe default value to use for substitution, and to send, if an alternate value is not supplied.
descriptionstringAn optional description for the parameter. CommonMark syntax MAY be used for rich text representation.
examples[string]An array of examples of the parameter value.
locationstringA runtime expression that specifies the location of the parameter value.

This object MAY be extended with Specification Extensions.

Parameter Object Example
1{
2  "address": "user/{userId}/signedup",
3  "parameters": {
4    "userId": {
5      "description": "Id of the user.",
6      "location": "$message.payload#/user/id"
7    }
8  }
9}
1address: user/{userId}/signedup
2parameters:
3  userId:
4    description: Id of the user.
5    location: $message.payload#/user/id

Server Bindings Object

Map describing protocol-specific definitions for a server.

Fixed Fields
Field NameTypeDescription
httpHTTP Server BindingProtocol-specific information for an HTTP server.
wsWebSockets Server BindingProtocol-specific information for a WebSockets server.
kafkaKafka Server BindingProtocol-specific information for a Kafka server.
anypointmqAnypoint MQ Server BindingProtocol-specific information for an Anypoint MQ server.
amqpAMQP Server BindingProtocol-specific information for an AMQP 0-9-1 server.
amqp1AMQP 1.0 Server BindingProtocol-specific information for an AMQP 1.0 server.
mqttMQTT Server BindingProtocol-specific information for an MQTT server.
mqtt5MQTT 5 Server BindingProtocol-specific information for an MQTT 5 server.
natsNATS Server BindingProtocol-specific information for a NATS server.
jmsJMS Server BindingProtocol-specific information for a JMS server.
snsSNS Server BindingProtocol-specific information for an SNS server.
solaceSolace Server BindingProtocol-specific information for a Solace server.
sqsSQS Server BindingProtocol-specific information for an SQS server.
stompSTOMP Server BindingProtocol-specific information for a STOMP server.
redisRedis Server BindingProtocol-specific information for a Redis server.
mercureMercure Server BindingProtocol-specific information for a Mercure server.
ibmmqIBM MQ Server BindingProtocol-specific information for an IBM MQ server.
googlepubsubGoogle Cloud Pub/Sub Server BindingProtocol-specific information for a Google Cloud Pub/Sub server.
pulsarPulsar Server BindingProtocol-specific information for a Pulsar server.

This object MAY be extended with Specification Extensions.

Channel Bindings Object

Map describing protocol-specific definitions for a channel.

Fixed Fields
Field NameTypeDescription
httpHTTP Channel BindingProtocol-specific information for an HTTP channel.
wsWebSockets Channel BindingProtocol-specific information for a WebSockets channel.
kafkaKafka Channel BindingProtocol-specific information for a Kafka channel.
anypointmqAnypoint MQ Channel BindingProtocol-specific information for an Anypoint MQ channel.
amqpAMQP Channel BindingProtocol-specific information for an AMQP 0-9-1 channel.
amqp1AMQP 1.0 Channel BindingProtocol-specific information for an AMQP 1.0 channel.
mqttMQTT Channel BindingProtocol-specific information for an MQTT channel.
mqtt5MQTT 5 Channel BindingProtocol-specific information for an MQTT 5 channel.
natsNATS Channel BindingProtocol-specific information for a NATS channel.
jmsJMS Channel BindingProtocol-specific information for a JMS channel.
snsSNS Channel BindingProtocol-specific information for an SNS channel.
solaceSolace Channel BindingProtocol-specific information for a Solace channel.
sqsSQS Channel BindingProtocol-specific information for an SQS channel.
stompSTOMP Channel BindingProtocol-specific information for a STOMP channel.
redisRedis Channel BindingProtocol-specific information for a Redis channel.
mercureMercure Channel BindingProtocol-specific information for a Mercure channel.
ibmmqIBM MQ Channel BindingProtocol-specific information for an IBM MQ channel.
googlepubsubGoogle Cloud Pub/Sub Channel BindingProtocol-specific information for a Google Cloud Pub/Sub channel.
pulsarPulsar Channel BindingProtocol-specific information for a Pulsar channel.

This object MAY be extended with Specification Extensions.

Operation Bindings Object

Map describing protocol-specific definitions for an operation.

Fixed Fields
Field NameTypeDescription
httpHTTP Operation BindingProtocol-specific information for an HTTP operation.
wsWebSockets Operation BindingProtocol-specific information for a WebSockets operation.
kafkaKafka Operation BindingProtocol-specific information for a Kafka operation.
anypointmqAnypoint MQ Operation BindingProtocol-specific information for an Anypoint MQ operation.
amqpAMQP Operation BindingProtocol-specific information for an AMQP 0-9-1 operation.
amqp1AMQP 1.0 Operation BindingProtocol-specific information for an AMQP 1.0 operation.
mqttMQTT Operation BindingProtocol-specific information for an MQTT operation.
mqtt5MQTT 5 Operation BindingProtocol-specific information for an MQTT 5 operation.
natsNATS Operation BindingProtocol-specific information for a NATS operation.
jmsJMS Operation BindingProtocol-specific information for a JMS operation.
snsSNS Operation BindingProtocol-specific information for an SNS operation.
solaceSolace Operation BindingProtocol-specific information for a Solace operation.
sqsSQS Operation BindingProtocol-specific information for an SQS operation.
stompSTOMP Operation BindingProtocol-specific information for a STOMP operation.
redisRedis Operation BindingProtocol-specific information for a Redis operation.
mercureMercure Operation BindingProtocol-specific information for a Mercure operation.
googlepubsubGoogle Cloud Pub/Sub Operation BindingProtocol-specific information for a Google Cloud Pub/Sub operation.
ibmmqIBM MQ Operation BindingProtocol-specific information for an IBM MQ operation.
pulsarPulsar Operation BindingProtocol-specific information for a Pulsar operation.

This object MAY be extended with Specification Extensions.

Message Bindings Object

Map describing protocol-specific definitions for a message.

Fixed Fields
Field NameTypeDescription
httpHTTP Message BindingProtocol-specific information for an HTTP message, i.e., a request or a response.
wsWebSockets Message BindingProtocol-specific information for a WebSockets message.
kafkaKafka Message BindingProtocol-specific information for a Kafka message.
anypointmqAnypoint MQ Message BindingProtocol-specific information for an Anypoint MQ message.
amqpAMQP Message BindingProtocol-specific information for an AMQP 0-9-1 message.
amqp1AMQP 1.0 Message BindingProtocol-specific information for an AMQP 1.0 message.
mqttMQTT Message BindingProtocol-specific information for an MQTT message.
mqtt5MQTT 5 Message BindingProtocol-specific information for an MQTT 5 message.
natsNATS Message BindingProtocol-specific information for a NATS message.
jmsJMS Message BindingProtocol-specific information for a JMS message.
snsSNS Message BindingProtocol-specific information for an SNS message.
solaceSolace Server BindingProtocol-specific information for a Solace message.
sqsSQS Message BindingProtocol-specific information for an SQS message.
stompSTOMP Message BindingProtocol-specific information for a STOMP message.
redisRedis Message BindingProtocol-specific information for a Redis message.
mercureMercure Message BindingProtocol-specific information for a Mercure message.
ibmmqIBM MQ Message BindingProtocol-specific information for an IBM MQ message.
googlepubsubGoogle Cloud Pub/Sub Message BindingProtocol-specific information for a Google Cloud Pub/Sub message.
pulsarPulsar Message BindingProtocol-specific information for a Pulsar message.

This object MAY be extended with Specification Extensions.

Message Object

Describes a message received on a given channel and operation.

Fixed Fields
Field NameTypeDescription
headersMulti Format Schema Object | Schema Object | Reference ObjectSchema definition of the application headers. Schema MUST be a map of key-value pairs. It MUST NOT define the protocol headers. If this is a Schema Object, then the schemaFormat will be assumed to be "application/vnd.aai.asyncapi+json;version=asyncapi" where the version is equal to the AsyncAPI Version String.
payloadMulti Format Schema Object | Schema Object | Reference ObjectDefinition of the message payload. If this is a Schema Object, then the schemaFormat will be assumed to be "application/vnd.aai.asyncapi+json;version=asyncapi" where the version is equal to the AsyncAPI Version String.
correlationIdCorrelation ID Object | Reference ObjectDefinition of the correlation ID used for message tracing or matching.
contentTypestringThe content type to use when encoding/decoding a message's payload. The value MUST be a specific media type (e.g. application/json). When omitted, the value MUST be the one specified on the defaultContentType field.
namestringA machine-friendly name for the message.
titlestringA human-friendly title for the message.
summarystringA short summary of what the message is about.
descriptionstringA verbose explanation of the message. CommonMark syntax can be used for rich text representation.
tagsTags ObjectA list of tags for logical grouping and categorization of messages.
externalDocsExternal Documentation Object | Reference ObjectAdditional external documentation for this message.
bindingsMessage Bindings Object | Reference ObjectA map where the keys describe the name of the protocol and the values describe protocol-specific definitions for the message.
examples[Message Example Object]List of examples.
traits[Message Trait Object | Reference Object]A list of traits to apply to the message object. Traits MUST be merged using traits merge mechanism. The resulting object MUST be a valid Message Object.

This object MAY be extended with Specification Extensions.

Message Object Example
1{
2  "name": "UserSignup",
3  "title": "User signup",
4  "summary": "Action to sign a user up.",
5  "description": "A longer description",
6  "contentType": "application/json",
7  "tags": [
8    { "name": "user" },
9    { "name": "signup" },
10    { "name": "register" }
11  ],
12  "headers": {
13    "type": "object",
14    "properties": {
15      "correlationId": {
16        "description": "Correlation ID set by application",
17        "type": "string"
18      },
19      "applicationInstanceId": {
20        "description": "Unique identifier for a given instance of the publishing application",
21        "type": "string"
22      }
23    }
24  },
25  "payload": {
26    "type": "object",
27    "properties": {
28      "user": {
29        "$ref": "#/components/schemas/userCreate"
30      },
31      "signup": {
32        "$ref": "#/components/schemas/signup"
33      }
34    }
35  },
36  "correlationId": {
37    "description": "Default Correlation ID",
38    "location": "$message.header#/correlationId"
39  },
40  "traits": [
41    { "$ref": "#/components/messageTraits/commonHeaders" }
42  ],
43  "examples": [
44    {
45      "name": "SimpleSignup",
46      "summary": "A simple UserSignup example message",
47      "headers": {
48        "correlationId": "my-correlation-id",
49        "applicationInstanceId": "myInstanceId"
50      },
51      "payload": {
52        "user": {
53          "someUserKey": "someUserValue"
54        },
55        "signup": {
56          "someSignupKey": "someSignupValue"
57        }
58      }
59    }
60  ]
61}
1name: UserSignup
2title: User signup
3summary: Action to sign a user up.
4description: A longer description
5contentType: application/json
6tags:
7  - name: user
8  - name: signup
9  - name: register
10headers:
11  type: object
12  properties:
13    correlationId:
14      description: Correlation ID set by application
15      type: string
16    applicationInstanceId:
17      description: Unique identifier for a given instance of the publishing application
18      type: string
19payload:
20  type: object
21  properties:
22    user:
23      $ref: "#/components/schemas/userCreate"
24    signup:
25      $ref: "#/components/schemas/signup"
26correlationId:
27  description: Default Correlation ID
28  location: $message.header#/correlationId
29traits:
30  - $ref: "#/components/messageTraits/commonHeaders"
31examples:
32  - name: SimpleSignup
33    summary: A simple UserSignup example message
34    headers:
35      correlationId: my-correlation-id
36      applicationInstanceId: myInstanceId
37    payload:
38      user:
39        someUserKey: someUserValue
40      signup:
41        someSignupKey: someSignupValue

Example using Avro to define the payload:

1{
2  "name": "UserSignup",
3  "title": "User signup",
4  "summary": "Action to sign a user up.",
5  "description": "A longer description",
6  "tags": [
7    { "name": "user" },
8    { "name": "signup" },
9    { "name": "register" }
10  ],
11  "payload": {
12    "schemaFormat": "application/vnd.apache.avro+json;version=1.9.0",
13    "schema": {
14      "$ref": "path/to/user-create.avsc#/UserCreate"
15    }
16  }
17}
1name: UserSignup
2title: User signup
3summary: Action to sign a user up.
4description: A longer description
5tags:
6  - name: user
7  - name: signup
8  - name: register
9payload:
10  schemaFormat: 'application/vnd.apache.avro+yaml;version=1.9.0'
11  schema:
12    $ref: 'path/to/user-create.avsc/#UserCreate'

Message Trait Object

Describes a trait that MAY be applied to a Message Object. This object MAY contain any property from the Message Object, except payload and traits.

If you're looking to apply traits to an operation, see the Operation Trait Object.

Fixed Fields
Field NameTypeDescription
headersMulti Format Schema Object | Schema Object | Reference ObjectSchema definition of the application headers. Schema MUST be a map of key-value pairs. It MUST NOT define the protocol headers. If this is a Schema Object, then the schemaFormat will be assumed to be "application/vnd.aai.asyncapi+json;version=asyncapi" where the version is equal to the AsyncAPI Version String.
correlationIdCorrelation ID Object | Reference ObjectDefinition of the correlation ID used for message tracing or matching.
contentTypestringThe content type to use when encoding/decoding a message's payload. The value MUST be a specific media type (e.g. application/json). When omitted, the value MUST be the one specified on the defaultContentType field.
namestringA machine-friendly name for the message.
titlestringA human-friendly title for the message.
summarystringA short summary of what the message is about.
descriptionstringA verbose explanation of the message. CommonMark syntax can be used for rich text representation.
tagsTags ObjectA list of tags for logical grouping and categorization of messages.
externalDocsExternal Documentation Object | Reference ObjectAdditional external documentation for this message.
bindingsMessage Bindings Object | Reference ObjectA map where the keys describe the name of the protocol and the values describe protocol-specific definitions for the message.
examples[Message Example Object]List of examples.

This object MAY be extended with Specification Extensions.

Message Trait Object Example
1{
2  "contentType": "application/json"
3}
contentType: application/json

Message Example Object

Message Example Object represents an example of a Message Object and MUST contain either headers and/or payload fields.

Fixed Fields
Field NameTypeDescription
headersMap[string, any]The value of this field MUST validate against the Message Object's headers field.
payloadMap[string, any]The value of this field MUST validate against the Message Object's payload field.
namestringA machine-friendly name.
summarystringA short summary of what the example is about.

This object MAY be extended with Specification Extensions.

Message Example Object Example
1{
2  "name": "SimpleSignup",
3  "summary": "A simple UserSignup example message",
4  "headers": {
5    "correlationId": "my-correlation-id",
6    "applicationInstanceId": "myInstanceId"
7  },
8  "payload": {
9    "user": {
10      "someUserKey": "someUserValue"
11    },
12    "signup": {
13      "someSignupKey": "someSignupValue"
14    }
15  }
16}
1name: SimpleSignup
2summary: A simple UserSignup example message
3headers:
4  correlationId: my-correlation-id
5  applicationInstanceId: myInstanceId
6payload:
7  user:
8    someUserKey: someUserValue
9  signup:
10    someSignupKey: someSignupValue

Tags Object

A Tags object is a list of Tag Objects. An Tag Object in a list can be referenced by Reference Object.

Tag Object

Allows adding meta data to a single tag.

Fixed Fields
Field NameTypeDescription
namestringREQUIRED. The name of the tag.
descriptionstringA short description for the tag. CommonMark syntax can be used for rich text representation.
externalDocsExternal Documentation Object | Reference ObjectAdditional external documentation for this tag.

This object MAY be extended with Specification Extensions.

Tag Object Example
1{
2 "name": "user",
3 "description": "User-related messages"
4}
1name: user
2description: User-related messages

External Documentation Object

Allows referencing an external resource for extended documentation.

Fixed Fields
Field NameTypeDescription
descriptionstringA short description of the target documentation. CommonMark syntax can be used for rich text representation.
urlstringREQUIRED. The URL for the target documentation. This MUST be in the form of an absolute URL.

This object MAY be extended with Specification Extensions.

External Documentation Object Example
1{
2  "description": "Find more info here",
3  "url": "https://example.com"
4}
1description: Find more info here
2url: https://example.com

Reference Object

A simple object to allow referencing other components in the specification, internally and externally.

The Reference Object is defined by JSON Reference and follows the same structure, behavior and rules. A JSON Reference SHALL only be used to refer to a schema that is formatted in either JSON or YAML. In the case of a YAML-formatted Schema, the JSON Reference SHALL be applied to the JSON representation of that schema. The JSON representation SHALL be made by applying the conversion described here.

For this specification, reference resolution is done as defined by the JSON Reference specification and not by the JSON Schema specification.

Fixed Fields
Field NameTypeDescription
$refstringREQUIRED. The reference string.

This object cannot be extended with additional properties and any properties added SHALL be ignored.

Reference Object Example
1{
2  "$ref": "#/components/schemas/Pet"
3}
  $ref: '#/components/schemas/Pet'

Components Object

Holds a set of reusable objects for different aspects of the AsyncAPI specification. All objects defined within the components object will have no effect on the API unless they are explicitly referenced from properties outside the components object.

Fixed Fields
Field NameTypeDescription
schemasMap[string, Multi Format Schema Object | Schema Object | Reference Object]An object to hold reusable Schema Object. If this is a Schema Object, then the schemaFormat will be assumed to be "application/vnd.aai.asyncapi+json;version=asyncapi" where the version is equal to the AsyncAPI Version String.
serversMap[string, Server Object | Reference Object]An object to hold reusable Server Objects.
channelsMap[string, Channel Object | Reference Object]An object to hold reusable Channel Objects.
operationsMap[string, Operation Object | Reference Object]An object to hold reusable Operation Objects.
messagesMap[string, Message Object | Reference Object]An object to hold reusable Message Objects.
securitySchemesMap[string, Security Scheme Object | Reference Object]An object to hold reusable Security Scheme Objects.
serverVariablesMap[string, Server Variable Object | Reference Object]An object to hold reusable Server Variable Objects.
parametersMap[string, Parameter Object | Reference Object]An object to hold reusable Parameter Objects.
correlationIdsMap[string, Correlation ID Object | Reference Object]An object to hold reusable Correlation ID Objects.
repliesMap[string, Operation Reply Object | Reference Object]An object to hold reusable Operation Reply Objects.
replyAddressesMap[string, Operation Reply Address Object | Reference Object]An object to hold reusable Operation Reply Address Objects.
externalDocsMap[string, External Documentation Object | Reference Object]An object to hold reusable External Documentation Objects.
tagsMap[string, Tag Object | Reference Object]An object to hold reusable Tag Objects.
operationTraitsMap[string, Operation Trait Object | Reference Object]An object to hold reusable Operation Trait Objects.
messageTraitsMap[string, Message Trait Object | Reference Object]An object to hold reusable Message Trait Objects.
serverBindingsMap[string, Server Bindings Object | Reference Object]An object to hold reusable Server Bindings Objects.
channelBindingsMap[string, Channel Bindings Object | Reference Object]An object to hold reusable Channel Bindings Objects.
operationBindingsMap[string, Operation Bindings Object | Reference Object]An object to hold reusable Operation Bindings Objects.
messageBindingsMap[string, Message Bindings Object | Reference Object]An object to hold reusable Message Bindings Objects.

This object MAY be extended with Specification Extensions.

All the fixed fields declared above are objects that MUST use keys that match the regular expression: ^[a-zA-Z0-9\.\-_]+$.

Field Name Examples:

1User
2User_1
3User_Name
4user-name
5my.org.User
Components Object Example
1{
2  "components": {
3    "schemas": {
4      "Category": {
5        "type": "object",
6        "properties": {
7          "id": {
8            "type": "integer",
9            "format": "int64"
10          },
11          "name": {
12            "type": "string"
13          }
14        }
15      },
16      "Tag": {
17        "type": "object",
18        "properties": {
19          "id": {
20            "type": "integer",
21            "format": "int64"
22          },
23          "name": {
24            "type": "string"
25          }
26        }
27      },
28      "AvroExample": {
29        "schemaFormat": "application/vnd.apache.avro+json;version=1.9.0",
30        "schema": {
31          "$ref": "path/to/user-create.avsc#/UserCreate"
32        }
33      }
34    },
35    "servers": {
36      "development": {
37        "host": "{stage}.in.mycompany.com:{port}",
38        "description": "RabbitMQ broker",
39        "protocol": "amqp",
40        "protocolVersion": "0-9-1",
41        "variables": {
42          "stage": {
43            "$ref": "#/components/serverVariables/stage"
44          },
45          "port": {
46            "$ref": "#/components/serverVariables/port"
47          }
48        }
49      }
50    },
51    "serverVariables": {
52      "stage": {
53        "default": "demo",
54        "description": "This value is assigned by the service provider, in this example `mycompany.com`"
55      },
56      "port": {
57        "enum": ["5671", "5672"],
58        "default": "5672"
59      }
60    },
61    "channels": {
62      "user/signedup": {
63        "subscribe": {
64          "message": {
65            "$ref": "#/components/messages/userSignUp"
66          }
67        }
68      }
69    },
70    "messages": {
71      "userSignUp": {
72        "summary": "Action to sign a user up.",
73        "description": "Multiline description of what this action does.\nHere you have another line.\n",
74        "tags": [
75          {
76            "name": "user"
77          },
78          {
79            "name": "signup"
80          }
81        ],
82        "headers": {
83          "type": "object",
84          "properties": {
85            "applicationInstanceId": {
86              "description": "Unique identifier for a given instance of the publishing application",
87              "type": "string"
88            }
89          }
90        },
91        "payload": {
92          "type": "object",
93          "properties": {
94            "user": {
95              "$ref": "#/components/schemas/userCreate"
96            },
97            "signup": {
98              "$ref": "#/components/schemas/signup"
99            }
100          }
101        }
102      }
103    },
104    "parameters": {
105      "userId": {
106        "description": "Id of the user."
107      }
108    },
109    "correlationIds": {
110      "default": {
111        "description": "Default Correlation ID",
112        "location": "$message.header#/correlationId"
113      }
114    },
115    "messageTraits": {
116      "commonHeaders": {
117        "headers": {
118          "type": "object",
119          "properties": {
120            "my-app-header": {
121              "type": "integer",
122              "minimum": 0,
123              "maximum": 100
124            }
125          }
126        }
127      }
128    }
129  }
130}
1components:
2  schemas:
3    Category:
4      type: object
5      properties:
6        id:
7          type: integer
8          format: int64
9        name:
10          type: string
11    Tag:
12      type: object
13      properties:
14        id:
15          type: integer
16          format: int64
17        name:
18          type: string
19    AvroExample:
20      schemaFormat: application/vnd.apache.avro+json;version=1.9.0
21      schema:
22        $ref: 'path/to/user-create.avsc/#UserCreate'
23  servers:
24    development:
25      host: "{stage}.in.mycompany.com:{port}"
26      description: RabbitMQ broker
27      protocol: amqp
28      protocolVersion: 0-9-1
29      variables:
30        stage:
31          $ref: "#/components/serverVariables/stage"
32        port:
33          $ref: "#/components/serverVariables/port"
34  serverVariables:
35    stage:
36      default: demo
37      description: This value is assigned by the service provider, in this example `mycompany.com`
38    port:
39      enum: ["5671", "5672"]
40      default: "5672"
41  channels:
42    user/signedup:
43      subscribe:
44        message:
45          $ref: "#/components/messages/userSignUp"
46  messages:
47    userSignUp:
48      summary: Action to sign a user up.
49      description: |
50        Multiline description of what this action does.
51        Here you have another line.
52      tags:
53        - name: user
54        - name: signup
55      headers:
56        type: object
57        properties:
58          applicationInstanceId:
59            description: Unique identifier for a given instance of the publishing application
60            type: string
61      payload:
62        type: object
63        properties:
64          user:
65            $ref: "#/components/schemas/userCreate"
66          signup:
67            $ref: "#/components/schemas/signup"
68  parameters:
69    userId:
70      description: Id of the user.
71  correlationIds:
72    default:
73      description: Default Correlation ID
74      location: $message.header#/correlationId
75  messageTraits:
76    commonHeaders:
77      headers:
78        type: object
79        properties:
80          my-app-header:
81            type: integer
82            minimum: 0
83            maximum: 100

Multi Format Schema Object

The Multi Format Schema Object represents a schema definition. It differs from the Schema Object in that it supports multiple schema formats or languages (e.g., JSON Schema, Avro, etc.).

Fixed Fields
Field NameTypeDescription
schemaFormatstringRequired. A string containing the name of the schema format that is used to define the information. If schemaFormat is missing, it MUST default to application/vnd.aai.asyncapi+json;version={{asyncapi}} where {{asyncapi}} matches the AsyncAPI Version String. In such a case, this would make the Multi Format Schema Object equivalent to the Schema Object. When using Reference Object within the schema, the schemaFormat of the resource being referenced MUST match the schemaFormat of the schema that contains the initial reference. For example, if you reference Avro schema, then schemaFormat of referencing resource and the resource being reference MUST match.

Check out the supported schema formats table for more information. Custom values are allowed but their implementation is OPTIONAL. A custom value MUST NOT refer to one of the schema formats listed in the table.

When using Reference Objects within the schema, the schemaFormat of the referenced resource MUST match the schemaFormat of the schema containing the reference.
schemaanyRequired. Definition of the message payload. It can be of any type but defaults to Schema Object. It MUST match the schema format defined in schemaFormat, including the encoding type. E.g., Avro should be inlined as either a YAML or JSON object instead of as a string to be parsed as YAML or JSON. Non-JSON-based schemas (e.g., Protobuf or XSD) MUST be inlined as a string.

This object MAY be extended with Specification Extensions.

Schema formats table

The following table contains a set of values that every implementation MUST support.

NameAllowed valuesNotes
AsyncAPI 3.0.0 Schema Objectapplication/vnd.aai.asyncapi;version=3.0.0, application/vnd.aai.asyncapi+json;version=3.0.0, application/vnd.aai.asyncapi+yaml;version=3.0.0This is the default when a schemaFormat is not provided.
JSON Schema Draft 07application/schema+json;version=draft-07, application/schema+yaml;version=draft-07

The following table contains a set of values that every implementation is RECOMMENDED to support.

NameAllowed valuesNotes
Avro 1.9.0 schemaapplication/vnd.apache.avro;version=1.9.0, application/vnd.apache.avro+json;version=1.9.0, application/vnd.apache.avro+yaml;version=1.9.0
OpenAPI 3.0.0 Schema Objectapplication/vnd.oai.openapi;version=3.0.0, application/vnd.oai.openapi+json;version=3.0.0, application/vnd.oai.openapi+yaml;version=3.0.0
RAML 1.0 data typeapplication/raml+yaml;version=1.0
Protocol Buffersapplication/vnd.google.protobuf;version=2, application/vnd.google.protobuf;version=3
Multi Format Schema Object Examples
Multi Format Schema Object Example with Avro
1channels:
2  example:
3    messages:
4      myMessage:
5        payload:
6          schemaFormat: 'application/vnd.apache.avro;version=1.9.0'
7          schema:
8            type: record
9            name: User
10            namespace: com.company
11            doc: User information
12            fields:
13              - name: displayName
14                type: string
15              - name: age
16                type: int

Schema Object

The Schema Object allows the definition of input and output data types. These types can be objects, but also primitives and arrays. This object is a superset of the JSON Schema Specification Draft 07. The empty schema (which allows any instance to validate) MAY be represented by the boolean value true and a schema which allows no instance to validate MAY be represented by the boolean value false.

Further information about the properties can be found in JSON Schema Core and JSON Schema Validation. Unless stated otherwise, the property definitions follow the JSON Schema specification as referenced here. For other formats (e.g., Avro, RAML, etc) see Multi Format Schema Object.

Properties

The AsyncAPI Schema Object is a JSON Schema vocabulary which extends JSON Schema Core and Validation vocabularies. As such, any keyword available for those vocabularies is by definition available in AsyncAPI, and will work the exact same way, including but not limited to:

  • title
  • type
  • required
  • multipleOf
  • maximum
  • exclusiveMaximum
  • minimum
  • exclusiveMinimum
  • maxLength
  • minLength
  • pattern (This string SHOULD be a valid regular expression, according to the ECMA 262 regular expression dialect)
  • maxItems
  • minItems
  • uniqueItems
  • maxProperties
  • minProperties
  • enum
  • const
  • examples
  • if / then / else
  • readOnly
  • writeOnly
  • properties
  • patternProperties
  • additionalProperties
  • additionalItems
  • items
  • propertyNames
  • contains
  • allOf
  • oneOf
  • anyOf
  • not

The following properties are taken from the JSON Schema definition but their definitions were adjusted to the AsyncAPI Specification.

  • description - CommonMark syntax can be used for rich text representation.
  • format - See Data Type Formats for further details. While relying on JSON Schema's defined formats, the AsyncAPI Specification offers a few additional predefined formats.
  • default - Use it to specify that property has a predefined value if no other value is present. Unlike JSON Schema, the value MUST conform to the defined type for the Schema Object defined at the same level. For example, of type is string, then default can be "foo" but cannot be 1.

Alternatively, any time a Schema Object can be used, a Reference Object can be used in its place. This allows referencing definitions in place of defining them inline. It is appropriate to clarify that the $ref keyword MUST follow the behavior described by Reference Object instead of the one in JSON Schema definition.

In addition to the JSON Schema fields, the following AsyncAPI vocabulary fields MAY be used for further schema documentation:

Fixed Fields
Field NameTypeDescription
discriminatorstringAdds support for polymorphism. The discriminator is the schema property name that is used to differentiate between other schema that inherit this schema. The property name used MUST be defined at this schema and it MUST be in the required property list. When used, the value MUST be the name of this schema or any schema that inherits it. See Composition and Inheritance for more details.
externalDocsExternal Documentation Object | Reference ObjectAdditional external documentation for this schema.
deprecatedbooleanSpecifies that a schema is deprecated and SHOULD be transitioned out of usage. Default value is false.

This object MAY be extended with Specification Extensions.

Composition and Inheritance (Polymorphism)

The AsyncAPI Specification allows combining and extending model definitions using the allOf property of JSON Schema, in effect offering model composition. allOf takes in an array of object definitions that are validated independently but together compose a single object.

While composition offers model extensibility, it does not imply a hierarchy between the models. To support polymorphism, AsyncAPI Specification adds the support of the discriminator field. When used, the discriminator will be the name of the property used to decide which schema definition is used to validate the structure of the model. As such, the discriminator field MUST be a required field. There are two ways to define the value of a discriminator for an inheriting instance.

  • Use the schema's name.
  • Override the schema's name by overriding the property with a new value. If exists, this takes precedence over the schema's name.

As such, inline schema definitions, which do not have a given id, cannot be used in polymorphism.

Schema Object Examples
Primitive Sample
1{
2  "type": "string",
3  "format": "email"
4}
1type: string
2format: email
Simple Model
1{
2  "type": "object",
3  "required": [
4    "name"
5  ],
6  "properties": {
7    "name": {
8      "type": "string"
9    },
10    "address": {
11      "$ref": "#/components/schemas/Address"
12    },
13    "age": {
14      "type": "integer",
15      "format": "int32",
16      "minimum": 0
17    }
18  }
19}
1type: object
2required:
3- name
4properties:
5  name:
6    type: string
7  address:
8    $ref: '#/components/schemas/Address'
9  age:
10    type: integer
11    format: int32
12    minimum: 0
Model with Map/Dictionary Properties

For a simple string to string mapping:

1{
2  "type": "object",
3  "additionalProperties": {
4    "type": "string"
5  }
6}
1type: object
2additionalProperties:
3  type: string

For a string to model mapping:

1{
2  "type": "object",
3  "additionalProperties": {
4    "$ref": "#/components/schemas/ComplexModel"
5  }
6}
1type: object
2additionalProperties:
3  $ref: '#/components/schemas/ComplexModel'
Model with Example
1{
2  "type": "object",
3  "properties": {
4    "id": {
5      "type": "integer",
6      "format": "int64"
7    },
8    "name": {
9      "type": "string"
10    }
11  },
12  "required": [
13    "name"
14  ],
15  "examples": [
16    {
17      "name": "Puma",
18      "id": 1
19    }
20  ]
21}
1type: object
2properties:
3  id:
4    type: integer
5    format: int64
6  name:
7    type: string
8required:
9- name
10examples:
11- name: Puma
12  id: 1
Model with Boolean Schemas
1{
2  "type": "object",
3  "required": [
4    "anySchema"
5  ],
6  "properties": {
7    "anySchema": true,
8    "cannotBeDefined": false
9  }
10}
1type: object
2required:
3- anySchema
4properties:
5  anySchema: true
6  cannotBeDefined: false
Models with Composition
1{
2  "schemas": {
3    "ErrorModel": {
4      "type": "object",
5      "required": [
6        "message",
7        "code"
8      ],
9      "properties": {
10        "message": {
11          "type": "string"
12        },
13        "code": {
14          "type": "integer",
15          "minimum": 100,
16          "maximum": 600
17        }
18      }
19    },
20    "ExtendedErrorModel": {
21      "allOf": [
22        {
23          "$ref": "#/components/schemas/ErrorModel"
24        },
25        {
26          "type": "object",
27          "required": [
28            "rootCause"
29          ],
30          "properties": {
31            "rootCause": {
32              "type": "string"
33            }
34          }
35        }
36      ]
37    }
38  }
39}
1schemas:
2  ErrorModel:
3    type: object
4    required:
5    - message
6    - code
7    properties:
8      message:
9        type: string
10      code:
11        type: integer
12        minimum: 100
13        maximum: 600
14  ExtendedErrorModel:
15    allOf:
16    - $ref: '#/components/schemas/ErrorModel'
17    - type: object
18      required:
19      - rootCause
20      properties:
21        rootCause:
22          type: string
Models with Polymorphism Support
1{
2  "schemas": {
3    "Pet": {
4      "type": "object",
5      "discriminator": "petType",
6      "properties": {
7        "name": {
8          "type": "string"
9        },
10        "petType": {
11          "type": "string"
12        }
13      },
14      "required": [
15        "name",
16        "petType"
17      ]
18    },
19    "Cat": {
20      "description": "A representation of a cat. Note that `Cat` will be used as the discriminator value.",
21      "allOf": [
22        {
23          "$ref": "#/components/schemas/Pet"
24        },
25        {
26          "type": "object",
27          "properties": {
28            "huntingSkill": {
29              "type": "string",
30              "description": "The measured skill for hunting",
31              "enum": [
32                "clueless",
33                "lazy",
34                "adventurous",
35                "aggressive"
36              ]
37            }
38          },
39          "required": [
40            "huntingSkill"
41          ]
42        }
43      ]
44    },
45    "Dog": {
46      "description": "A representation of a dog. Note that `Dog` will be used as the discriminator value.",
47      "allOf": [
48        {
49          "$ref": "#/components/schemas/Pet"
50        },
51        {
52          "type": "object",
53          "properties": {
54            "packSize": {
55              "type": "integer",
56              "format": "int32",
57              "description": "the size of the pack the dog is from",
58              "minimum": 0
59            }
60          },
61          "required": [
62            "packSize"
63          ]
64        }
65      ]
66    },
67    "StickInsect": {
68      "description": "A representation of an Australian walking stick. Note that `StickBug` will be used as the discriminator value.",
69      "allOf": [
70        {
71          "$ref": "#/components/schemas/Pet"
72        },
73        {
74          "type": "object",
75          "properties": {
76            "petType": {
77              "const": "StickBug"
78            },
79            "color": {
80              "type": "string"
81            }
82          },
83          "required": [
84            "color"
85          ]
86        }
87      ]
88    }
89  }
90}
1schemas:
2  Pet:
3    type: object
4    discriminator: petType
5    properties:
6      name:
7        type: string
8      petType:
9        type: string
10    required:
11    - name
12    - petType
13  ## applies to instances with `petType: "Cat"`
14  ## because that is the schema name
15  Cat:
16    description: A representation of a cat
17    allOf:
18    - $ref: '#/components/schemas/Pet'
19    - type: object
20      properties:
21        huntingSkill:
22          type: string
23          description: The measured skill for hunting
24          enum:
25          - clueless
26          - lazy
27          - adventurous
28          - aggressive
29      required:
30      - huntingSkill
31  ## applies to instances with `petType: "Dog"`
32  ## because that is the schema name
33  Dog:
34    description: A representation of a dog
35    allOf:
36    - $ref: '#/components/schemas/Pet'
37    - type: object
38      properties:
39        packSize:
40          type: integer
41          format: int32
42          description: the size of the pack the dog is from
43          minimum: 0
44      required:
45      - packSize
46  ## applies to instances with `petType: "StickBug"`
47  ## because that is the required value of the discriminator field,
48  ## overriding the schema name
49  StickInsect:
50    description: A representation of an Australian walking stick
51    allOf:
52    - $ref: '#/components/schemas/Pet'
53    - type: object
54      properties:
55        petType:
56          const: StickBug
57        color:
58          type: string
59      required:
60      - color

Security Scheme Object

Defines a security scheme that can be used by the operations. Supported schemes are:

  • User/Password.
  • API key (either as user or as password).
  • X.509 certificate.
  • End-to-end encryption (either symmetric or asymmetric).
  • HTTP authentication.
  • HTTP API key.
  • OAuth2's common flows (Implicit, Resource Owner Protected Credentials, Client Credentials and Authorization Code) as defined in RFC6749.
  • OpenID Connect Discovery.
  • SASL (Simple Authentication and Security Layer) as defined in RFC4422.
Fixed Fields
Field NameTypeApplies ToDescription
typestringAnyREQUIRED. The type of the security scheme. Valid values are "userPassword", "apiKey", "X509", "symmetricEncryption", "asymmetricEncryption", "httpApiKey", "http", "oauth2", "openIdConnect", "plain", "scramSha256", "scramSha512", and "gssapi".
descriptionstringAnyA short description for security scheme. CommonMark syntax MAY be used for rich text representation.
namestringhttpApiKeyREQUIRED. The name of the header, query or cookie parameter to be used.
instringapiKey | httpApiKeyREQUIRED. The location of the API key. Valid values are "user" and "password" for apiKey and "query", "header" or "cookie" for httpApiKey.
schemestringhttpREQUIRED. The name of the HTTP Authorization scheme to be used in the Authorization header as defined in RFC7235.
bearerFormatstringhttp ("bearer")A hint to the client to identify how the bearer token is formatted. Bearer tokens are usually generated by an authorization server, so this information is primarily for documentation purposes.
flowsOAuth Flows Objectoauth2REQUIRED. An object containing configuration information for the flow types supported.
openIdConnectUrlstringopenIdConnectREQUIRED. OpenId Connect URL to discover OAuth2 configuration values. This MUST be in the form of an absolute URL.
scopes[string]oauth2 | openIdConnectList of the needed scope names. An empty array means no scopes are needed.

This object MAY be extended with Specification Extensions.

Security Scheme Object Example
User/Password Authentication Sample
1{
2  "type": "userPassword"
3}
type: userPassword
API Key Authentication Sample
1{
2  "type": "apiKey",
3  "in": "user"
4}
1type: apiKey
2in: user
X.509 Authentication Sample
1{
2  "type": "X509"
3}
type: X509
End-to-end Encryption Authentication Sample
1{
2  "type": "symmetricEncryption"
3}
type: symmetricEncryption
Basic Authentication Sample
1{
2  "type": "http",
3  "scheme": "basic"
4}
1type: http
2scheme: basic
API Key Sample
1{
2  "type": "httpApiKey",
3  "name": "api_key",
4  "in": "header"
5}
1type: httpApiKey
2name: api_key
3in: header
JWT Bearer Sample
1{
2  "type": "http",
3  "scheme": "bearer",
4  "bearerFormat": "JWT"
5}
1type: http
2scheme: bearer
3bearerFormat: JWT
Implicit OAuth2 Sample
1{
2  "type": "oauth2",
3  "flows": {
4    "implicit": {
5      "authorizationUrl": "https://example.com/api/oauth/dialog",
6      "availableScopes": {
7        "write:pets": "modify pets in your account",
8        "read:pets": "read your pets"
9      }
10    }
11  },
12  "scopes": [
13    "write:pets"
14  ]
15}
1type: oauth2
2flows:
3  implicit:
4    authorizationUrl: https://example.com/api/oauth/dialog
5    availableScopes:
6      write:pets: modify pets in your account
7      read:pets: read your pets
8scopes:
9  - 'write:pets'
SASL Sample
1{
2  "type": "scramSha512"
3}
type: scramSha512

OAuth Flows Object

Allows configuration of the supported OAuth Flows.

Fixed Fields
Field NameTypeDescription
implicitOAuth Flow ObjectConfiguration for the OAuth Implicit flow.
passwordOAuth Flow ObjectConfiguration for the OAuth Resource Owner Protected Credentials flow.
clientCredentialsOAuth Flow ObjectConfiguration for the OAuth Client Credentials flow.
authorizationCodeOAuth Flow ObjectConfiguration for the OAuth Authorization Code flow.

This object MAY be extended with Specification Extensions.

OAuth Flow Object

Configuration details for a supported OAuth Flow

Fixed Fields
Field NameTypeApplies ToDescription
authorizationUrlstringoauth2 ("implicit", "authorizationCode")REQUIRED. The authorization URL to be used for this flow. This MUST be in the form of an absolute URL.
tokenUrlstringoauth2 ("password", "clientCredentials", "authorizationCode")REQUIRED. The token URL to be used for this flow. This MUST be in the form of an absolute URL.
refreshUrlstringoauth2The URL to be used for obtaining refresh tokens. This MUST be in the form of an absolute URL.
availableScopesMap[string, string]oauth2REQUIRED. The available scopes for the OAuth2 security scheme. A map between the scope name and a short description for it.

This object MAY be extended with Specification Extensions.

OAuth Flow Object Examples
1{
2  "authorizationUrl": "https://example.com/api/oauth/dialog",
3  "tokenUrl": "https://example.com/api/oauth/token",
4  "availableScopes": {
5    "write:pets": "modify pets in your account",
6    "read:pets": "read your pets"
7  }
8}
1authorizationUrl: https://example.com/api/oauth/dialog
2tokenUrl: https://example.com/api/oauth/token
3availableScopes:
4  write:pets: modify pets in your account
5  read:pets: read your pets

Correlation ID Object

An object that specifies an identifier at design time that can used for message tracing and correlation.

For specifying and computing the location of a Correlation ID, a runtime expression is used.

Fixed Fields

Field NameTypeDescription
descriptionstringAn optional description of the identifier. CommonMark syntax can be used for rich text representation.
locationstringREQUIRED. A runtime expression that specifies the location of the correlation ID.

This object MAY be extended with Specification Extensions.

Examples
1{
2  "description": "Default Correlation ID",
3  "location": "$message.header#/correlationId"
4}
1description: Default Correlation ID
2location: $message.header#/correlationId

Runtime Expression

A runtime expression allows values to be defined based on information that will be available within the message. This mechanism is used by Correlation ID Object and Operation Reply Address Object.

The runtime expression is defined by the following ABNF syntax:

1      expression = ( "$message" "." source )
2      source = ( header-reference | payload-reference )
3      header-reference = "header" ["#" fragment]
4      payload-reference = "payload" ["#" fragment]
5      fragment = a JSON Pointer [RFC 6901](https://tools.ietf.org/html/rfc6901)

The table below provides examples of runtime expressions and examples of their use in a value:

Examples

Source LocationExample expressionNotes
Message Header Property$message.header#/MQMD/CorrelIdCorrelation ID is set using the CorrelId value from the MQMD header.
Message Payload Property$message.payload#/messageIdCorrelation ID is set using the messageId value from the message payload.

Runtime expressions preserve the type of the referenced value.

Traits Merge Mechanism

Traits MUST be merged with the target object using the JSON Merge Patch algorithm in the same order they are defined. A property on a trait MUST NOT override the same property on the target object.

Example

An object like the following:

1description: A longer description.
2traits:
3  - name: UserSignup
4    description: Description from trait.
5  - tags:
6      - name: user

Would look like the following after applying traits:

1name: UserSignup
2description: A longer description.
3tags:
4  - name: user

Specification Extensions

While the AsyncAPI Specification tries to accommodate most use cases, additional data can be added to extend the specification at certain points.

The extensions properties are implemented as patterned fields that are always prefixed by "x-".

Field PatternTypeDescription
^x-[\w\d\.\x2d_]+$AnyAllows extensions to the AsyncAPI Schema. The field name MUST begin with x-, for example, x-internal-id. The value can be null, a primitive, an array or an object. Can have any valid JSON format value.

The extensions may or may not be supported by the available tooling, but those may be extended as well to add requested support (if tools are internal or open-sourced).

Data Type Formats

Primitives have an optional modifier property: format. The AsyncAPI specification uses several known formats to more finely define the data type being used. However, the format property is an open string-valued property, and can have any value to support documentation needs. Formats such as "email", "uuid", etc., can be used even though they are not defined by this specification. Types that are not accompanied by a format property follow their definition from the JSON Schema. Tools that do not recognize a specific format MAY default back to the type alone, as if the format was not specified.

The formats defined by the AsyncAPI Specification are:

Common NametypeformatComments
integerintegerint32signed 32 bits
longintegerint64signed 64 bits
floatnumberfloat
doublenumberdouble
stringstring
bytestringbytebase64 encoded characters
binarystringbinaryany sequence of octets
booleanboolean
datestringdateAs defined by full-date - RFC3339
dateTimestringdate-timeAs defined by date-time - RFC3339
passwordstringpasswordUsed to hint UIs the input needs to be obscured.
Was this helpful?
Help us improve the docs by adding your contribution.
OR
Github:AsyncAPICreate Issue on GitHub