---
title: Schema registry
description: 'Schema registries are resources that let you validate messages against
  the Confluent schema registry.

  '
url: "/event-gateway/entities/schema-registry/"
canonical_url: "/event-gateway/entities/schema-registry/"
content_type: reference
products:
- Event Gateway
tools:
- Konnect API
- Terraform
- kongctl
canonical: true
works_on:
- konnect


---

# Schema registry










## What is a schema registry?

Schema registries are resources that you can use in [Schema Validation policies](/event-gateway/policies/)
to validate messages against the [Confluent schema registry](https://docs.confluent.io/platform/current/schema-registry/index.html).

Event Gateway supports the following registry types:
* Avro
* JSON Schema

You can also set `schema_type` to `any` v1.3+ to accept records in any supported format, rather than a single fixed format.
With `any`, Event Gateway resolves the format of each record individually. Values that carry a schema reference, in the [Confluent wire format](https://docs.confluent.io/platform/current/schema-registry/fundamentals/serdes-develop/index.html#wire-format) or in a record header, are decoded using the registry. Any other value is parsed as JSON without a schema.

## Set up a schema registry





### Konnect API

  
To create a schema registry, call the Event Gateway API's [`/schema-registries`](/api/konnect/event-gateway/#/operations/create-event-gateway-schema-registry) endpoint.


```bash
curl -X POST https://{region}.api.konghq.com/v1/event-gateways/{eventGatewayId}/schema-registries \
    --header "accept: application/json" \
    --header "Content-Type: application/json" \
    --header "Authorization: Bearer $KONNECT_TOKEN" \
    --data '
    {
      "name": "my-schema-registry",
      "type": "confluent",
      "config": {
        "schema_type": "avro",
        "endpoint": "endpoint",
        "timeout_seconds": 10,
        "authentication": {
          "type": "basic",
          "username": "username",
          "password": "'$MY_PASSWORD'"
        }
      }
    }
    '
```





Make sure to replace the following placeholders with your own values:

* `region`: Geographic region where your Kong Konnect is hosted and operates.

* `KONNECT_TOKEN`: Your Personal Access Token (PAT) associated with your Konnect account.

* `virtualClusterId`: The `id` of the Virtual Cluster.

* `eventGatewayId`: The `id` of the Event Gateway.

* `eventGatewayListenerId`: The `id` of the Event Gateway Listener.




See the [Konnect Event Gateway API reference](/api/konnect/event-gateway/) to learn about region-specific URLs and personal access tokens.




### Terraform

  
##### **Prerequisite:** Configure your Personal Access Token

```hcl
terraform {
  required_providers {
    konnect-beta = {
      source  = "kong/konnect-beta"
    }
  }
}

provider "konnect-beta" {
  personal_access_token = "$KONNECT_TOKEN"
  server_url            = "https://us.api.konghq.com/"
}
```


Add the following to your Terraform configuration:




```hcl
resource "konnect_event_gateway_schema_registry" "my_schema_registry" {
  provider = konnect-beta
  type = "confluent"
  config = {
    schema_type = "avro"
    endpoint = "endpoint"
    timeout_seconds = 10

    authentication = {
      type = "basic"
      username = "username"
      password = "$MY_PASSWORD"
    }
  }



  gateway_id = konnect_event_gateway.my_event_gateway.id
}
```






### kongctl

  

The following creates a new schema registry called **my-schema-registry**.




```yaml
event_gateways:
  - ref: eventGatewayName
    name: eventGatewayName
    schema_registries:
    - ref: my-schema-registry
      name: my-schema-registry
      type: confluent
      config:
        schema_type: avro
        endpoint: endpoint
        timeout_seconds: 10
        authentication:
          type: basic
          username: username
          password: !env MY_PASSWORD
```
{: data-file="schema_registry.yaml" data-tool="kongctl" }





Make sure to replace the following placeholders with your own values:

* `eventGatewayName`: The `name` of your Event Gateway.






### UI

  


The following creates a new schema registry called **my-schema-registry** with basic configuration:

1. In Konnect, navigate to [Event Gateway](https://cloud.konghq.com/event-gateway/) in the sidebar.
1. Click an Event Gateway.
3. Click the **Resources** tab.
1. Click **New Schema Registry**.
1. In the **Name** field, enter `my-schema-registry`.
1. Configure your schema registry.
1. Click **Create**.













> **Note**: Event Gateway only requires **read-only** access to the schema registry to fetch schemas for validation.

## Schema

```json
{
  "description": "A schema registry that contains schemas.",
  "type": "object",
  "properties": {
    "name": {
      "description": "The unique name of the schema registry.",
      "type": "string",
      "maxLength": 255,
      "minLength": 1,
      "x-unicode-pattern": "^[\\p{L}\\p{N}][\\p{L}\\p{N} _\\-\\.:/+']*[\\p{L}\\p{N}]$"
    },
    "description": {
      "description": "A human-readable description of the virtual cluster.",
      "type": "string",
      "default": "",
      "maxLength": 512
    },
    "type": {
      "description": "The type of the schema registry.",
      "type": "string"
    },
    "config": {
      "description": "The configuration of the schema registry.",
      "type": "object"
    },
    "labels": {
      "$ref": "#/components/schemas/Labels"
    },
    "id": {
      "description": "The unique identifier of the schema registry.",
      "type": "string",
      "format": "uuid"
    },
    "created_at": {
      "$ref": "#/components/schemas/CreatedAt"
    },
    "updated_at": {
      "$ref": "#/components/schemas/UpdatedAt"
    }
  },
  "required": [
    "name",
    "type",
    "id",
    "created_at",
    "updated_at"
  ]
}
```



## Related Resources

- [Schema Validation - produce policy](/event-gateway/policies/schema-validation-produce/)

- [Schema Validation - consume policy](/event-gateway/policies/schema-validation-consume/)

