Confluent Cloud Schema Registry REST API Usage Examples
Use the Schema Registry REST API to register, list, look up, and delete schemas and subjects, and to view them by version, by ID, and more. For the full API reference, see Schemas (V1) and Subjects (V1).
Setup and suggestions
To make the API calls in these usage examples to the Schemas (V1) and Subjects (V1) APIs, you need the following:
The Schema Registry API endpoint URL for the Confluent Cloud environment you want to use. The examples call it
<SCHEMA-REGISTRY-ENDPOINT>or$SCHEMA_REGISTRY_ENDPOINT. To find it, do one of the following:In the Cloud Console, go to an environment, select a cluster, click Schema Registry in the navigation menu, and click the Endpoints tab.
In the Confluent CLI, select the environment with
confluent env listandconfluent env use <environment-ID>, and then runconfluent schema-registry cluster describe. For more commands, see the Confluent CLI command reference.
If you use an API key, you need an API key and secret for Schema Registry in the environment you want to use. To create one, see Create an API key for Confluent Cloud Schema Registry. Schema subjects live in per-environment Schema Registry clusters. Choose the environment that contains the Kafka clusters you want to use.
If you use OAuth, provide your access token for authorization in the format described in Use OAuth/OIDC to Authenticate to Confluent Cloud. For an OAuth example, see OAuth for Confluent Cloud Schema Registry REST API.
Enclose the URL and search parameters in single or double quotes for search calls that include a question mark (
?) or ampersand (&). The quotes keep the shell from interpreting them. The examples show this syntax.Optional: The Confluent Cloud Schema Registry APIs support schema contexts. Contexts are part of schema linking and can also group schemas in other scenarios.
Optional: Store your API key and secret and the Schema Registry URL in local shell environment variables to make testing easier. For example, to store your API key and secret:
MYCOOLKEYS=xyz:abc
Check the value with
echo $MYCOOLKEYS, and then use it for authorization in subsequent commands:curl --silent -u $MYCOOLKEYS -X POST -H "Content-Type: application/json" ....Optional: For readable output, use the
--silentflag with curl and pipe the output through jq .. Without--silentandjq, the output content is the same but isn’t formatted for reading. For examples of these options, see the Stream Catalog REST API Usage and Examples on Confluent Cloud documentation.Optional: To compare API results with the Confluent Cloud Console, log in to Confluent Cloud.
OAuth for Confluent Cloud Schema Registry REST API
The Confluent Cloud Schema Registry REST API supports OAuth, an open-standard authorization protocol for secure access. To learn more about OAuth, see Use OAuth/OIDC to Authenticate to Confluent Cloud and Configure Schema Registry Java clients.
The following example uses OAuth to get a list of subjects from Confluent Cloud Schema Registry:
curl --request GET '<SCHEMA-REGISTRY-ENDPOINT>/subjects/' \
--header 'Confluent-Identity-Pool-Id: <POOL-ID>' \
--header 'target-sr-cluster: <CLUSTER-ID>' \
--header 'Authorization: Bearer $TOKEN'
The Confluent-Identity-Pool-Id header is optional. If omitted, Confluent Cloud
automatically maps one or more OAuth identity pools based on the filters that
evaluate to true given the token’s claim values. For more information about
auto pool mapping, see Use auto pool mapping with OAuth identity pools.
The target-sr-cluster header is required, except when you connect to the
private endpoint over AWS PrivateLink. The private endpoint hostname starts
with lsrc- and identifies the cluster. You can omit the header for those
requests.
The rest of the examples use an API key and secret. To use OAuth instead, remove
-u <API-KEY>:<API-SECRET>, and add the headers from the example in
OAuth for Confluent Cloud Schema Registry REST API.
Schemas (V1) API usage examples
Get schema by ID
curl --silent -u $SR_APIKEY:$SR_APISECRET --request GET \
--url "$SCHEMA_REGISTRY_ENDPOINT/schemas/ids/<schema-ID>?subject=SOME_STRING_VALUE&format=SOME_STRING_VALUE&fetchMaxId=<true|false>"
Note
The subject query parameter acts as a search hint rather than a
filter. It identifies the first context to search when locating the schema
by ID, which helps in multi-context environments. It doesn’t restrict the
result to that subject.
For example, the following call gets the schema my-flights, which is associated with the schema ID 100015:
curl --silent -u $SR_APIKEY:$SR_APISECRET --request GET --url $SCHEMA_REGISTRY_ENDPOINT/schemas/ids/100015?subject=flights&format=Avro&fetchMaxId=true | jq .
The resulting output is a wrapper object with a schema field containing the schema as a JSON string:
{"schema":"{\"type\":\"record\",\"name\":\"sampleRecord\",\"namespace\":\"com.mycorp.mynamespace\",\"doc\":\"Sample schema to help you get started.\",\"fields\":[{\"name\":\"my_field1\",\"type\":\"int\",\"doc\":\"The int type is a 32-bit signed integer.\"},{\"name\":\"my_field2\",\"type\":\"double\",\"doc\":\"The double type is a double precision (64-bit) IEEE 754 floating-point number.\"},{\"name\":\"my_field3\",\"type\":\"string\",\"doc\":\"The string is a unicode character sequence.\"}]}"}
Tip
This endpoint can return additional metadata properties such as deleted.
See Use the APIs to determine if a schema is deleted for details.
Get schema string by ID
GET /schemas/ids/{schema-ID}/schema
curl --silent -u $SR_APIKEY:$SR_APISECRET --request GET \
--url "$SCHEMA_REGISTRY_ENDPOINT/schemas/ids/<schema-ID>/schema?subject=SOME_STRING_VALUE&format=SOME_STRING_VALUE"
Note
The subject query parameter acts as a search hint rather than a
filter. It identifies the first context to search when locating the schema
by ID, which helps in multi-context environments. It doesn’t restrict the
result to that subject.
For example, to get the schema string associated with the ID 100018:
curl --silent -u $SR_APIKEY:$SR_APISECRET --request GET --url $SCHEMA_REGISTRY_ENDPOINT/schemas/ids/100018/schema | jq .
The output is the raw schema object directly:
{"type":"record","name":"Employee","namespace":"Example","fields":[{"name":"Name","type":"string"},{"name":"Age","type":"int"},{"name":"Country","type":"string","default":""}]}
List supported schema types
curl --silent -u $SR_APIKEY:$SR_APISECRET --request GET --url $SCHEMA_REGISTRY_ENDPOINT/schemas/types | jq .
Example output:
"JSON",
"PROTOBUF",
"AVRO"
Tip
Without jq, the output resembles ["JSON","PROTOBUF","AVRO"].
List schemas
curl --silent -u $SR_APIKEY:$SR_APISECRET --request GET \
--url "$SCHEMA_REGISTRY_ENDPOINT/schemas?subjectPrefix=<SOME_STRING_VALUE>&deleted=<true|false>&latestOnly=<true|false>&offset=<SOME_INTEGER_VALUE>&limit=<SOME_INTEGER_VALUE>"
For example, to list all versions of schemas whose subject starts with my
and show the subject and schema for each:
curl --silent -u $SR_APIKEY:$SR_APISECRET --request GET --url $SCHEMA_REGISTRY_ENDPOINT/schemas?subjectPrefix=my | jq .
Example partial output:
{
"subject": "my-cool-subject",
"version": 2,
"id": 100018,
"schema": "{\"type\":\"record\",\"name\":\"Employee\",\"namespace\":\"Example\",\"fields\":[{\"name\":\"Name\",\"type\":\"string\"},{\"name\":\"Age\",\"type\":\"int\"},{\"name\":\"Country\",\"type\":\"string\",\"default\":\"\"}]}",
"ts": 1696522845123,
"deleted": false
},
{
"subject": "my-cooler-subject",
"version": 2,
"id": 100020,
"schema": "{\"type\":\"record\",\"name\":\"Employees\",\"namespace\":\"my.examples\",\"fields\":[{\"name\":\"Name\",\"type\":\"string\"},{\"name\":\"Age\",\"type\":\"int\"},{\"name\":\"region\",\"type\":\"string\",\"default\":\"\"}]}",
"ts": 1696522845124,
"deleted": false
},
{
"subject": "my-cooler-subject",
"version": 3,
"id": 100021,
"schema": "{\"type\":\"record\",\"name\":\"Employees\",\"namespace\":\"my.examples\",\"fields\":[{\"name\":\"Name\",\"type\":\"string\"},{\"name\":\"Age\",\"type\":\"int\"},{\"name\":\"region\",\"type\":\"string\",\"default\":\"\"},{\"name\":\"Team\",\"type\":\"string\",\"default\":\"\"}]}",
"ts": 1696522845125,
"deleted": false
},
...
Tip
This endpoint returns ts (timestamp) and deleted fields for each schema in the response.
List subjects associated to a schema ID
GET /schemas/ids/{schema-ID}/subjects
curl --silent -u $SR_APIKEY:$SR_APISECRET --request GET --url $SCHEMA_REGISTRY_ENDPOINT/schemas/ids/<schema-ID>/subjects
For example, to list the subject associated with ID 100018:
curl --silent -u $SR_APIKEY:$SR_APISECRET --request GET --url $SCHEMA_REGISTRY_ENDPOINT/schemas/ids/100018/subjects
The output is:
["my-cool-subject"]
List subject-versions associated to schema ID
GET /schemas/ids/{schema-ID}/versions
curl --silent -u $SR_APIKEY:$SR_APISECRET --request GET \
--url "$SCHEMA_REGISTRY_ENDPOINT/schemas/ids/<schema-ID>/versions?subject=SOME_STRING_VALUE&deleted=<true|false>"
For example, the following call retrieves the subject-version associated with schema ID 100008:
curl --silent -u $SR_APIKEY:$SR_APISECRET --request GET --url \
$SCHEMA_REGISTRY_ENDPOINT/schemas/ids/100008/versions?subject=stock | jq .
The output shows that version 2 of stocks-value is associated with the given ID:
{
"subject": "stocks-value",
"version": 2
}
Get schema by GUID
Retrieves the schema identified by the GUID. Schema Registry uses GUIDs when you include schema IDs in Kafka headers for data governance.
curl --silent -u $SR_APIKEY:$SR_APISECRET --request GET \
--url "$SCHEMA_REGISTRY_ENDPOINT/schemas/guids/<guid>"
For example, to get the schema associated with a specific GUID:
curl --silent -u $SR_APIKEY:$SR_APISECRET --request GET \
--url $SCHEMA_REGISTRY_ENDPOINT/schemas/guids/a1b2c3d4-e5f6-7890-abcd-ef1234567890 | jq .
The resulting output contains the schema information:
{
"subject": "my-subject-value",
"version": 1,
"id": 100015,
"schema": "{\"type\":\"record\",\"name\":\"MyRecord\",\"fields\":[{\"name\":\"field1\",\"type\":\"string\"}]}"
}
Get IDs by GUID
Retrieves the schema IDs for a GUID. Use this endpoint when you work with schema IDs in Kafka headers.
curl --silent -u $SR_APIKEY:$SR_APISECRET --request GET \
--url "$SCHEMA_REGISTRY_ENDPOINT/schemas/guids/<guid>/ids"
For example, to get the IDs associated with a specific GUID:
curl --silent -u $SR_APIKEY:$SR_APISECRET --request GET \
--url $SCHEMA_REGISTRY_ENDPOINT/schemas/guids/a1b2c3d4-e5f6-7890-abcd-ef1234567890/ids | jq .
The output returns the schema IDs:
[100015]
Subjects (V1) API usage examples
List all subjects
curl --silent -u $SR_APIKEY:$SR_APISECRET --request GET --url $SCHEMA_REGISTRY_ENDPOINT/subjects | jq .
Example output, showing a list of subjects in the registry:
"hamburgers",
"my-cool-subject",
"stocks_sell-value",
"Team",
"hamburger-test",
"accounts-value",
"stocks-value",
"stocks_under_100-value",
"employees-value",
"flights-value",
"my-widget-value",
"stocks_buy-value",
"my-flights-value",
"my-cooler-subject",
"my-new-widget-value",
"Hotdogs",
"my-value"
List subjects matching a given prefix
For example, list all versions of subjects whose names start with my:
curl --silent -u $SR_APIKEY:$SR_APISECRET --request GET --url $SCHEMA_REGISTRY_ENDPOINT/schemas?subjectPrefix=my | jq .
Example partial output:
{
"subject": "my-cool-subject",
"version": 2,
"id": 100018,
"schema": "{\"type\":\"record\",\"name\":\"Employee\",\"namespace\":\"Example\",\"fields\":[{\"name\":\"Name\",\"type\":\"string\"},{\"name\":\"Age\",\"type\":\"int\"},{\"name\":\"Country\",\"type\":\"string\",\"default\":\"\"}]}"
},
{
"subject": "my-cooler-subject",
"version": 2,
"id": 100020,
"schema": "{\"type\":\"record\",\"name\":\"Employees\",\"namespace\":\"my.examples\",\"fields\":[{\"name\":\"Name\",\"type\":\"string\"},{\"name\":\"Age\",\"type\":\"int\"},{\"name\":\"region\",\"type\":\"string\",\"default\":\"\"}]}"
},
{
"subject": "my-cooler-subject",
"version": 3,
"id": 100021,
"schema": "{\"type\":\"record\",\"name\":\"Employees\",\"namespace\":\"my.examples\",\"fields\":[{\"name\":\"Name\",\"type\":\"string\"},{\"name\":\"Age\",\"type\":\"int\"},{\"name\":\"region\",\"type\":\"string\",\"default\":\"\"},{\"name\":\"Team\",\"type\":\"string\",\"default\":\"\"}]}"
},
...
Get schema by version
GET /subjects/{subject}/versions/{version}
curl --silent -u $SR_APIKEY:$SR_APISECRET --request GET \
--url $SCHEMA_REGISTRY_ENDPOINT/subjects/<subject>/versions/<version>?deleted=<true|false>
For example, to get version 2 of schema “my-cool-subject”:
curl --silent -u $SR_APIKEY:$SR_APISECRET --request GET $SCHEMA_REGISTRY_ENDPOINT/subjects/my-cool-subject/versions/2
The output resembles the following, with the requested schema version:
{"subject":"my-cool-subject","version":2,"id":100018,"schema":"{\"type\":\"record\",\"name\":\"Employee\",\"namespace\":\"Example\",\"fields\":[{\"name\":\"Name\",\"type\":\"string\"},{\"name\":\"Age\",\"type\":\"int\"},{\"name\":\"Country\",\"type\":\"string\",\"default\":\"\"}]}"}
To retrieve a deleted schema version, use the following call, which
retrieves version 1 of my-cool-subject:
curl --silent -u $SR_APIKEY:$SR_APISECRET --request GET $SCHEMA_REGISTRY_ENDPOINT/subjects/my-cool-subject/versions/1?deleted=true
The output contains the deleted schema version:
{"subject":"my-cool-subject","version":1,"id":100004,"schema":"{\"type\":\"record\",\"name\":\"Employee\",\"namespace\":\"Example\",\"fields\":[{\"name\":\"Name\",\"type\":\"string\"},{\"name\":\"Age\",\"type\":\"int\"}]}"}
Tip
This endpoint can return additional metadata properties such as deleted.
See Use the APIs to determine if a schema is deleted for details.
Get the latest version of a schema with its schema ID
GET /subjects/{subject}/versions/{version}
curl --silent -u $SR_APIKEY:$SR_APISECRET --request GET \
--url $SCHEMA_REGISTRY_ENDPOINT/subjects/<subject>/versions/<version>?deleted=<true|false>
For example, to get the latest version of the schema for the “stocks” topic:
curl -u $SR_APIKEY:$SR_APISECRET --request GET --url $SCHEMA_REGISTRY_ENDPOINT/subjects/stocks-value/versions/latest
The output resembles the following:
{"subject":"stocks-value","version":2,"id":100008,"schema":"{\"type\":\"record\",\"name\":\"StockTrade\",\"namespace\":\"ksql\",\"doc\":\"Defines a hypothetical stock trade using some known test stock symbols.\",\"fields\":[{\"name\":\"side\",\"type\":\"string\",\"doc\":\"A simulated trade side (buy or sell or short)\"},{\"name\":\"quantity\",\"type\":\"int\",\"doc\":\"A simulated random quantity of the trade\"},{\"name\":\"symbol\",\"type\":\"string\",\"doc\":\"Simulated stock symbols\"},{\"name\":\"price\",\"type\":\"int\",\"doc\":\"A simulated random trade price in pennies\"},{\"name\":\"account\",\"type\":\"string\",\"doc\":\"Simulated accounts assigned to the trade\"},{\"name\":\"userid\",\"type\":\"string\",\"doc\":\"The simulated user who executed the trade\"}],\"connect.parameters\":{\"io.confluent.connect.avro.record.doc\":\"Defines a hypothetical stock trade using some known test stock symbols.\",\"io.confluent.connect.avro.field.doc.side\":\"A simulated trade side (buy or sell or short)\",\"io.confluent.connect.avro.field.doc.quantity\":\"A simulated random quantity of the trade\",\"io.confluent.connect.avro.field.doc.symbol\":\"Simulated stock symbols\",\"io.confluent.connect.avro.field.doc.price\":\"A simulated random trade price in pennies\",\"io.confluent.connect.avro.field.doc.account\":\"Simulated accounts assigned to the trade\",\"io.confluent.connect.avro.field.doc.userid\":\"The simulated user who executed the trade\"},\"connect.name\":\"ksql.StockTrade\"}"}
List schemas referencing a schema
GET /subjects/{subject}/versions/{version}/referencedby
curl -u <API-KEY>:<API-SECRET> --request GET \
--url <SCHEMA-REGISTRY-ENDPOINT>/subjects/<subject>/versions/<version>/referencedby
For example, the following call returns the schema IDs for schemas that reference version 1 of the employees-value schema:
curl --silent -u $SR_APIKEY:$SR_APISECRET --request GET --url $SCHEMA_REGISTRY_ENDPOINT/subjects/employees-value/versions/1/referencedby
The output is 100027, the schema ID for the widget-value schema:
[100027]
The most direct way to get the subjects associated with a schema ID is to list subjects associated to a schema ID with the following API call:
curl --silent -u $SR_APIKEY:$SR_APISECRET --request GET --url $SCHEMA_REGISTRY_ENDPOINT/schemas/ids/<schema-ID>/subjects
You could also list all schemas, but you would then have to search them all for the ID.
For example, to retrieve the subject associated with the given schema ID of 100027:
curl --silent -u $SR_APIKEY:$SR_APISECRET --request GET --url $SCHEMA_REGISTRY_ENDPOINT/schemas/ids/100027/subjects
The output is:
["my-widget-value"]
The my-widget-value subject references employees-value.
If you followed the example with these schemas and subject names, or with your own, verify the reference in the Confluent Cloud Console:
Log in to the Confluent Cloud Console at https://confluent.cloud/.
In the right side panel, click Environments > View & Manage Schemas, and then click the schema that you configured to reference another. In this example, the schema is
my-widget-value.Click Evolve Schema in the upper right. The schemas that the current schema references appear under Schema References:
Tip
To learn how to create schema references from the Confluent Cloud Console, see Work with schema references.
To learn more about schema references for each supported format, see Schema references.
Get schema string by version
GET /subjects/{subject}/versions/{version}/schema
curl --silent -u $SR_APIKEY:$SR_APISECRET --request GET \
--url "$SCHEMA_REGISTRY_ENDPOINT/subjects/<subject>/versions/<version>/schema?deleted=<true|false>"
For example, this call returns version 1 of the my-cool-subject schema,
which was deleted:
curl --silent -u $SR_APIKEY:$SR_APISECRET --request GET \
--url $SCHEMA_REGISTRY_ENDPOINT/subjects/my-cool-subject/versions/1/schema?deleted=true | jq .
Example output:
{"type":"record","name":"Employees","namespace":"my.examples","fields":[{"name":"Name","type":"string"},{"name":"Age","type":"int"}]}
List versions under subject
GET /subjects/{subject}/versions
curl -u $SR_APIKEY:$SR_APISECRET --request GET \
--url <SCHEMA-REGISTRY-ENDPOINT>/subjects/<subject>/versions?deleted=<true|false>
For example, this call lists all versions for “my-cool-subject”:
curl --silent -u $SR_APIKEY:$SR_APISECRET --request GET --url $SCHEMA_REGISTRY_ENDPOINT/subjects/my-cool-subject/versions
Example output showing all existing versions:
[2,3,4]
This call lists all versions for my-cool-subject, including deleted
versions:
curl --silent -u $SR_APIKEY:$SR_APISECRET --request GET --url $SCHEMA_REGISTRY_ENDPOINT/subjects/my-cool-subject/versions?deleted=true
Example output showing all versions, including soft-deleted versions:
[1,2,3,4]
Register schema under a subject
POST /subjects/{subject}/versions
To register a schema, send a POST request with the following parameters:
The
--dataflag provides the path to the file. You must include the@sign before the path with no spaces in between.Subject name under which to register the schema
To make a schema the latest version, even if it already exists, pass
version: -1 in the request body. This option is useful in
infrastructure-as-code (IaC) scenarios where a specific schema version must
become the latest. For example, with schema versions v1, v2, and v3, you can
make v1 the latest version again by re-registering v1 with version: -1.
When you use this parameter, Schema Registry adds a confluent:version key to the
schema’s metadata section.
curl -u <API-KEY>:<API-SECRET> -X POST -H "Content-Type: application/json" \
--data @/Users/me/my.json <SCHEMA-REGISTRY-ENDPOINT>/subjects/<subject>/versions
The following example file shows what to pass in the POST request.
{
"version": 0,
"id": 0,
"schemaType": "string",
"references": [
{
"name": "io.confluent.kafka.example.User",
"subject": "User",
"version": 1
}
],
"schema": "string"
}
Tip
This endpoint can return additional metadata properties such as deleted.
See Use the APIs to determine if a schema is deleted for details.
Lookup schema under subject
To look up a schema, specify a POST request with the following parameters:
The
--dataflag provides the path to the file. You must include the@sign before the path with no spaces in between.Subject name under which the schema is registered
curl -u <API-KEY>:<API-SECRET> -X POST -H "Content-Type: application/json" \
--data @/Users/me/my.json <SCHEMA-REGISTRY-ENDPOINT>/subjects/<subject>
The following example file shows what to pass in the POST request.
{
"version": 0,
"id": 0,
"schemaType": "string",
"references": [
{
"name": "io.confluent.kafka.example.User",
"subject": "User",
"version": 1
}
],
"schema": "string"
}
Tip
This endpoint can return additional metadata properties such as deleted.
See Use the APIs to determine if a schema is deleted for details.
Delete a subject
This example deletes all versions of the subject “my-value”:
curl --silent -u $SR_APIKEY:$SR_APISECRET --request DELETE --url $SCHEMA_REGISTRY_ENDPOINT/subjects/my-value | jq .
Example result showing versions 1 and 2 were deleted:
1,
2
Delete version 1 of the schema registered under a subject
DELETE /subjects/{subject}/versions/{version}
This example deletes version 1 of the my-cool-subject subject.
curl --silent -u $SR_APIKEY:$SR_APISECRET --request DELETE --url $SCHEMA_REGISTRY_ENDPOINT/subjects/my-cool-subject/versions/1 | jq .
Example result shows the version that was deleted:
1
Recover a soft-deleted schema
You can recover a soft-deleted schema as described in Recover a soft-deleted schema.
The following example retrieves all deleted schema subjects:
curl --silent -u $SR_APIKEY:$SR_APISECRET -X GET $SCHEMA_REGISTRY_ENDPOINT/subjects?deleted=true | jq .
This example re-registers a schema under the subject “my-cool-subject”:
curl --silent -u $SR_APIKEY:$SR_APISECRET -X POST -H "Content-Type: application/vnd.schemaregistry.v1+json" \ --data '{"schema": "{\"type\":\"record\",\"name\":\"Employee\",\"namespace\":\"Example\",\"fields\":[{\"name\":\"Name\",\"type\":\"string\"},{\"name\":\"Age\",\"type\":\"int\"},{\"name\":\"Country\",\"type\":\"string\",\"default\":\"\"}]}"}' \ $SCHEMA_REGISTRY_ENDPOINT/subjects/my-cool-subject/versions | jq .The result is a schema ID:
"id": 100017
Tip
The new schema that you provide to re-register the schema must be compatible with earlier versions. Otherwise, you get an error indicating a data mismatch.
Delete the most recently registered schema subject under a given subject
The following example deletes the latest version registered under the subject
widget-value, which starts with four versions:
curl --silent -u $SR_APIKEY:$SR_APISECRET --request DELETE --url $SCHEMA_REGISTRY_ENDPOINT/subjects/widget-value/versions/latest | jq .
Example result shows the version that was deleted:
4
Hard delete a schema
To hard delete a schema and
free up schema storage space on Confluent Cloud,
first soft delete all versions of the schema. Then hard delete all versions with
the ?permanent=true flag appended:
The following example performs a soft delete of all versions registered under the subject
widget-value:curl --silent -u $SR_APIKEY:$SR_APISECRET --request DELETE --url $SCHEMA_REGISTRY_ENDPOINT/subjects/widget-value | jq .
The result lists versions 1, 2, and 3 because you already soft deleted version 4 in the previous example:
1, 2, 3
The subject is now soft deleted. It doesn’t appear in the Confluent Cloud Console or in API subject lists, but it still takes up space in the registry.
The following example performs a hard delete of the subject
widget-value:curl --silent -u $SR_APIKEY:$SR_APISECRET --request DELETE --url $SCHEMA_REGISTRY_ENDPOINT/subjects/widget-value?permanent=true | jq .
The output shows that all versions are permanently deleted:
1, 2, 3, 4
Schema compatibility (V1) API usage examples
Use the following API calls to get and set global and subject-level compatibility. To learn about the compatibility types available on Confluent Cloud Schema Registry, see Schema Evolution and Compatibility.
Get the global compatibility level
curl --silent -u $SR_APIKEY:$SR_APISECRET --request GET --url $SCHEMA_REGISTRY_ENDPOINT/config/ | jq .
Example result:
"compatibilityLevel": "BACKWARD"
Update the global compatibility level
curl --silent -u $SR_APIKEY:$SR_APISECRET --request PUT -H "Content-Type: application/vnd.schemaregistry.v1+json" \
--data '{"compatibility": "<level>"}' --url $SCHEMA_REGISTRY_ENDPOINT/config/
For example, to update the global compatibility level to “BACKWARD_TRANSITIVE”:
curl --silent -u $SR_APIKEY:$SR_APISECRET --request PUT -H "Content-Type: application/vnd.schemaregistry.v1+json" \
--data '{"compatibility": "BACKWARD_TRANSITIVE"}' --url $SCHEMA_REGISTRY_ENDPOINT/config/ | jq .
Example result:
"compatibilityLevel": "BACKWARD_TRANSITIVE"
If you re-run the call to Get the global compatibility level, the response
contains "compatibilityLevel": "BACKWARD_TRANSITIVE".
Get the compatibility level on a subject
curl --silent -u $SR_APIKEY:$SR_APISECRET --request GET --url $SCHEMA_REGISTRY_ENDPOINT/config/my-cool-subject | jq .
Example output:
"error_code": 40408,
"message": "Subject 'my-cool-subject' does not have subject-level compatibility configured"
Update the subject compatibility level
curl --silent -u $SR_APIKEY:$SR_APISECRET --request PUT -H "Content-Type: application/vnd.schemaregistry.v1+json" \
--data '{"compatibility": "<level>"}' --url $SCHEMA_REGISTRY_ENDPOINT/config/<subject>
For example, to update the compatibility level for my-cool-subject to “FULL”:
curl --silent -u $SR_APIKEY:$SR_APISECRET --request PUT -H "Content-Type: application/vnd.schemaregistry.v1+json" \
--data '{"compatibility": "FULL"}' --url $SCHEMA_REGISTRY_ENDPOINT/config/my-cool-subject | jq .
Example result:
"compatibility": "FULL"
If you re-run the call to Get the compatibility level on a subject, the response
contains "compatibility": "FULL".