---
schema_version: "1"
id: 017b832b299042ff037e761eb9692fbee336786665fd8d9448920835af2e0e9f
title: Using Avro Schemas with APIkit for AsyncAPI
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/apikit/latest/apikit-asyncapi-avro-support.md
canonical_url: https://docs.mulesoft.com/apikit/latest/apikit-asyncapi-avro-support
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 485b54ff2548eab69a8b1598f878fa70e614eb87538f8ea7c6d1382f2c009db8
description: MuleSoft Documentation Site
release: 4.x
latest: true
---
---
product: APIkit
version: 4.x
is-latest-version: true
---

# Using Avro Schemas with APIkit for AsyncAPI

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

APIkit for AsyncAPI accepts [Avro](https://avro.apache.org/) in AsyncAPI message definitions so you
serialize payloads and validate them in Mule. Declare schemas inline in the spec or reference
external Avro documents; Studio can expose message shape during design, and
[DataSense](https://docs.mulesoft.com/studio/datasense-concept) assists with Avro-backed message metadata.

## Schema Definitions

The Avro spec defines its format by giving the value of `schemaFormat` as
`application/vnd.apache.avro`.

The Avro spec supports describing the schema inline or referencing an external document that
describes the schema in the Avro format:

- Inline definition

  publish: summary: inform details about person operationId: lightMeasured message: schemaFormat:
  'application/vnd.apache.avro;version=1.9.0' payload: name: lightMeasured type: record fields: -
  name: lumens type: int example: 134 - name: sentAt type: string logicalType: timestamp-millis 10
  example: 1985-04-12T23:20:50.52Z

- Reference to an Avro fragment

  channels: smartylighting.streetlights.1.0.event.{streetlightId}.monitor: publish: message:
  schemaFormat: application/vnd.apache.avro;version=1.9.0 payload: $ref:
  /exchange\_modules/83589b9b-6630-4c28-985d-174ee9172661/lumenschema/1.0.0/lumens.json'

The `lumens.json` file provides the specification in the Avro schema.

{ "type": "record", "name": "lightMeasured", "fields": \[ {"name": "lumens", "type": "int"},
{"name": "sentAt", "type": {"type": "string", "logicalType": "timestamp-millis"}} \] }

APIkit for AsyncAPI supports async APIs that have Avro messages defined inline. APIkit for AsyncAPI
doesn’t support API specs that refer to Avro fragments.

## Avro Message Encoding and Validation

Avro messages are encoded in either binary or text (JSON) format. The specification provides the
value of `contentType` OR `defaultContentType`.

APIkit for AsyncAPI validates messages encoded in text (JSON) but doesn’t validate binary-encoded
messages.
