Skip to content

HTTP Message Binding v0.3.0

The HTTP message binding is used to define the details of an HTTP message, including its headers and, for responses, the expected status code.

Overview

This binding applies to an AsyncAPI message object. It can be used to describe the headers of an outgoing webhook request or the headers and status code of an HTTP response in a request/reply pattern.

Message Properties

PropertyTypeRequiredDescription
bindingVersionstringNoBinding version (defaults to 0.3.0).
headersSchema ObjectNoA schema defining the HTTP headers.
statusCodenumberNoThe HTTP status code. Only relevant for response messages.

Property Details

headers

This is a Schema Object that defines the structure of the HTTP headers. The schema must be of type: object, and its properties represent the individual headers. You can specify types, required headers, and other constraints.

statusCode

This defines the HTTP response status code (e.g., 200, 201, 404). This property is only relevant for messages that are part of an operation.reply. For any other message, this value is ignored. It allows you to document the expected outcome of a successful request.

Examples

Webhook Message with Headers

This describes the message for a webhook. It specifies that the Content-Type header is required.

yaml
messages:
  userSignupEvent:
    payload:
      # ... payload definition
    bindings:
      http:
        bindingVersion: '0.3.0'
        headers:
          type: object
          required:
            - 'Content-Type'
          properties:
            Content-Type:
              type: string
              enum: ['application/json']

API Response Message

This describes the successful response for an API call. It specifies a 200 OK status code and includes a schema for the response headers, such as a rate-limiting header.

yaml
messages:
  userResponse:
    payload:
      # ... response payload definition
    bindings:
      http:
        bindingVersion: '0.3.0'
        statusCode: 200
        headers:
          type: object
          properties:
            X-Rate-Limit-Remaining:
              type: integer

Changelog

Version 0.3.0

  • Added the statusCode property to define response codes.

Version 0.2.0 and older

  • Only included the headers property.