Stay organized with collections
Save and categorize content based on your preferences.
A schema registry is a repository for managing schemas used by your
Kafka producers and consumers.
This document shows you how to create a schema registry resource within
Managed Service for Apache Kafka using the
Google Cloud console, the Google Cloud CLI, or the Managed Kafka API.
Before you begin
Before you create a schema registry, complete the following:
This predefined role contains
the permissions required to create a schema registry. To see the exact permissions that are
required, expand the Required permissions section:
Required permissions
The following permissions are required to create a schema registry:
Grant this permission on the parent location:
managedkafka.schemaRegistries.create
For Schema registry name, enter a unique identifier for your registry.
The name must start with a letter, contain only letters (a-z, A-Z),
numbers (0-9), and underscores (_), and be 63 characters or less.
Select or enter a Region from the menu.
You must already have a single or multiple active Managed Service for Apache Kafka
clusters in the region specified. To check the regions of your clusters, see
the documentation about
listing your clusters.
SCHEMA_REGISTRY_ID (required): a unique identifier for your
new schema registry. This forms part of the registry's resource name. The
name must start with a letter, contain only letters (a-z, A-Z), numbers (0-9),
and underscores (_), and be 63 characters or less.
LOCATION (required): the Google Cloud region where the
schema registry is going to be created. This location must match the region
of the Managed Service for Apache Kafka cluster or clusters using this
registry. For supported locations, see
Managed Service for Apache Kafka locations.
To create a schema registry named test_schema_registry
in the us-central1 region, run the following command:
After the command completes successfully, the schema registry is created.
You can then configure Kafka clients to use its URL. To view the schema
registry URL, see
Schema registry page details.
REST
To create a schema registry instance using the REST API, perform the
following steps.
Create a JSON file request-body.json with the following structure:
{"schemaRegistryId":"SCHEMA_REGISTRY_ID"}
Replace the following:
SCHEMA_REGISTRY_ID (required): a unique identifier for your
new schema registry. This forms part of the registry's resource name. The
name must start with a letter, contain only letters (a-z, A-Z), numbers (0-9),
and underscores (_), and be 63 characters or less.
Run the POST request with the constructed URI, headers,
and body. If successful, the API returns a 200 OK status
code and a response body containing the JSON representation of the newly
created SchemaRegistry resource.
The
projects/testing-311516/locations/us-central1/schemaRegistries/test/contexts/.
represents the default context. Resources in the default context don't
require any context to be specified.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["# Create a schema registry\n\n| **Preview**\n|\n|\n| This product or feature is subject to the \"Pre-GA Offerings Terms\" in the General Service Terms section\n| of the [Service Specific Terms](/terms/service-terms#1).\n|\n| Pre-GA products and features are available \"as is\" and might have limited support.\n|\n| For more information, see the\n| [launch stage descriptions](/products#product-launch-stages).\n\nA schema registry is a repository for managing schemas used by your\nKafka producers and consumers.\n\nThis document shows you how to create a schema registry resource within\nManaged Service for Apache Kafka using the\nGoogle Cloud console, the Google Cloud CLI, or the Managed Kafka API.\n\nBefore you begin\n----------------\n\nBefore you create a schema registry, complete the following:\n\n- [Create a Managed Service for Apache Kafka cluster](/managed-service-for-apache-kafka/docs/create-cluster) in the same region where you are planning to create a schema registry.\n\n### Required roles and permissions\n\n\nTo get the permissions that\nyou need to create a schema registry,\n\nask your administrator to grant you the\n\n\n[Managed Kafka Schema Registry Editor](/iam/docs/roles-permissions/managedkafka#managedkafka.schemaRegistryEditor) (`roles/managedkafka.schemaRegistryEditor`)\nIAM role on your project.\n\n\nFor more information about granting roles, see [Manage access to projects, folders, and organizations](/iam/docs/granting-changing-revoking-access).\n\n\nThis predefined role contains\n\nthe permissions required to create a schema registry. To see the exact permissions that are\nrequired, expand the **Required permissions** section:\n\n\n#### Required permissions\n\nThe following permissions are required to create a schema registry:\n\n- Grant this permission on the parent location: ` ``managedkafka.schemaRegistries.create`\n\n\nYou might also be able to get\nthese permissions\nwith [custom roles](/iam/docs/creating-custom-roles) or\nother [predefined roles](/iam/docs/roles-overview#predefined).\n\nHigher-level roles like **Managed Kafka Schema Registry Admin** also lets you\ncreate and manage schema registries.\n\nFor more information about the predefined roles available for\nManaged Service for Apache Kafka, see the\n[Access control documentation](/managed-service-for-apache-kafka/docs/access-control#predefined-roles).\n\nCreate a schema registry\n------------------------\n\n### Console\n\n1. In the Google Cloud console, go to the **Schema registries** page.\n\n [Go to schema registries](https://console.cloud.google.com/managedkafka/schemaRegistries)\n\n The **Schema registries** page opens.\n2. On the **Schema registries** page, click **Create** .\n\n The **Create Schema registry** page opens.\n3. For **Schema registry name** , enter a unique identifier for your registry.\n\n The name must start with a letter, contain only letters (a-z, A-Z),\n numbers (0-9), and underscores (_), and be 63 characters or less.\n4. Select or enter a **Region** from the menu.\n\n You must already have a single or multiple active Managed Service for Apache Kafka\n clusters in the region specified. To check the regions of your clusters, see\n the documentation about\n [listing your clusters](/managed-service-for-apache-kafka/docs/list-clusters#list).\n\n For a list of supported locations, see\n [Managed Service for Apache Kafka locations](/managed-service-for-apache-kafka/docs/locations).\n5. Click **Create**.\n\n### gcloud\n\n1.\n [Install](/sdk/docs/install) the Google Cloud CLI.\n\n After installation,\n [initialize](/sdk/docs/initializing) the Google Cloud CLI by running the following command:\n\n ```bash\n gcloud init\n ```\n\n\n If you're using an external identity provider (IdP), you must first\n [sign in to the gcloud CLI with your federated identity](/iam/docs/workforce-log-in-gcloud).\n2. Use the [`gcloud beta managed-kafka schema-registries create`](/sdk/gcloud/reference/beta/managed-kafka/schema-registries/create) command to create a schema registry:\n\n \u003cbr /\u003e\n\n ```bash\n gcloud beta managed-kafka schema-registries create SCHEMA_REGISTRY_ID \\\n --location=LOCATION \\\n ```\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eSCHEMA_REGISTRY_ID\u003c/var\u003e (required): a unique identifier for your new schema registry. This forms part of the registry's resource name. The name must start with a letter, contain only letters (a-z, A-Z), numbers (0-9), and underscores (_), and be 63 characters or less.\n - \u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e (required): the Google Cloud region where the schema registry is going to be created. This location must match the region of the Managed Service for Apache Kafka cluster or clusters using this registry. For supported locations, see [Managed Service for Apache Kafka locations](/managed-service-for-apache-kafka/docs/locations).\n\n To create a schema registry named `test_schema_registry`\n in the `us-central1` region, run the following command: \n\n ```bash\n gcloud beta managed-kafka schema-registries create test_schema_registry \\\n --location=us-central1\n ```\n\n After the command completes successfully, the schema registry is created.\n You can then configure Kafka clients to use its URL. To view the schema\n registry URL, see\n [Schema registry page details](/managed-service-for-apache-kafka/docs/schema-registry/view-schema-registry#schema-registry-page-details).\n\n### REST\n\nTo create a schema registry instance using the REST API, perform the\nfollowing steps.\n\n1. Send a `POST` request similar to the following: \n\n```\nPOST https://managedkafka.googleapis.com/v1main/projects/PROJECT_ID/locations/LOCATION/schemaRegistries\nAuthorization: Bearer $(gcloud auth application-default print-access-token)\nContent-Type: application/json --data @response-body.json\n```\n2. Create a JSON file `request-body.json` with the following structure: \n\n```json\n{\n \"schemaRegistryId\": \"\u003cvar translate=\"no\"\u003eSCHEMA_REGISTRY_ID\u003c/var\u003e\"\n}\n```\n3. Replace the following:\n - \u003cvar translate=\"no\"\u003eSCHEMA_REGISTRY_ID\u003c/var\u003e (required): a unique identifier for your new schema registry. This forms part of the registry's resource name. The name must start with a letter, contain only letters (a-z, A-Z), numbers (0-9), and underscores (_), and be 63 characters or less.\n4. Run the `POST` request with the constructed URI, headers, and body. If successful, the API returns a `200 OK` status code and a response body containing the JSON representation of the newly created SchemaRegistry resource.\n5. The following is a sample successful response. \n\n```json\n{\n \"name\": \"projects/testing-311516/locations/us-central1/schemaRegistries/test\",\n \"contexts\": [\n \"projects/testing-311516/locations/us-central1/schemaRegistries/test/contexts/.\"\n ]\n}\n```\n6. The `projects/testing-311516/locations/us-central1/schemaRegistries/test/contexts/.` represents the default context. Resources in the default context don't require any context to be specified.\n7. For more information, see the [REST API documentation](/managed-service-for-apache-kafka/docs/reference/rest).\n\n\u003cbr /\u003e\n\n*Apache Kafka® is a registered\ntrademark of The Apache Software Foundation or its affiliates in the United\nStates and/or other countries.*\n\nWhat's next\n-----------\n\n- [List all schema registries](/managed-service-for-apache-kafka/docs/schema-registry/list-schema-registries)\n\n- [View a schema registry](/managed-service-for-apache-kafka/docs/schema-registry/view-schema-registry)\n\n- [Create a subject](/managed-service-for-apache-kafka/docs/schema-registry/create-subject-version-one)\n\n- [Delete a schema registry](/managed-service-for-apache-kafka/docs/schema-registry/delete-schema-registry)"]]