DELETE /v1/topics/{id}
from metadata.generated.schema.entity.services.connections.metadata.openMetadataConnection import (
AuthProvider,
OpenMetadataConnection,
)
from metadata.generated.schema.security.client.openMetadataJWTClientConfig import (
OpenMetadataJWTClientConfig,
)
from metadata.ingestion.ometa.ometa_api import OpenMetadata
from metadata.generated.schema.entity.data.topic import Topic
metadata = OpenMetadata(
OpenMetadataConnection(
hostPort="https://your-company.open-metadata.org/api",
authProvider=AuthProvider.openmetadata,
securityConfig=OpenMetadataJWTClientConfig(jwtToken="your-jwt-token"),
)
)
# Soft delete by ID
metadata.delete(entity=Topic, entity_id="0a021819-982e-4ee4-a5a2-4af30eaa3016")
# Hard delete
metadata.delete(
entity=Topic,
entity_id="0a021819-982e-4ee4-a5a2-4af30eaa3016",
hard_delete=True
)
# Delete by name
topic = metadata.get_by_name(entity=Topic, fqn="sample_kafka.address_book")
metadata.delete(entity=Topic, entity_id=topic.id)
# Delete by name with options
topic = metadata.get_by_name(entity=Topic, fqn="sample_kafka.address_book")
metadata.delete(entity=Topic, entity_id=topic.id, hard_delete=True)
# Restore a soft-deleted topic
metadata.restore(entity=Topic, entity_id="0a021819-982e-4ee4-a5a2-4af30eaa3016")
import java.util.Map;
import org.openmetadata.schema.entity.data.Topic;
// client is an initialized OpenMetadataClient.
// Soft delete
client.topics().delete("0a021819-982e-4ee4-a5a2-4af30eaa3016");
// Hard delete
client.topics().delete("0a021819-982e-4ee4-a5a2-4af30eaa3016", Map.of("hardDelete", "true"));
// Delete by name (look up the ID first)
Topic topic = client.topics().getByName("sample_kafka.address_book");
client.topics().delete(topic.getId());
// Restore
client.topics().restore("0a021819-982e-4ee4-a5a2-4af30eaa3016");
# Soft delete by ID
curl -X DELETE "{base_url}/api/v1/topics/0a021819-982e-4ee4-a5a2-4af30eaa3016" \
-H "Authorization: Bearer {access_token}"
# Hard delete
curl -X DELETE "{base_url}/api/v1/topics/0a021819-982e-4ee4-a5a2-4af30eaa3016?hardDelete=true" \
-H "Authorization: Bearer {access_token}"
# Delete by name
curl -X DELETE "{base_url}/api/v1/topics/name/sample_kafka.address_book" \
-H "Authorization: Bearer {access_token}"
# Restore soft-deleted topic
curl -X PUT "{base_url}/api/v1/topics/restore" \
-H "Authorization: Bearer {access_token}" \
-H "Content-Type: application/json" \
-d '{"id": "0a021819-982e-4ee4-a5a2-4af30eaa3016"}'
{
"id": "0a021819-982e-4ee4-a5a2-4af30eaa3016",
"name": "address_book",
"fullyQualifiedName": "sample_kafka.address_book",
"description": "All Protobuf record related events gets captured in this topic",
"version": 0.2,
"updatedAt": 1769982663546,
"updatedBy": "admin",
"service": {
"id": "469ef25e-9bdf-4d5f-8553-eb0ce8581f30",
"type": "messagingService",
"name": "sample_kafka",
"fullyQualifiedName": "sample_kafka"
},
"serviceType": "Kafka",
"messageSchema": {
"schemaText": "syntax = \"proto2\";\npackage tutorial;\nmessage Person { ... }",
"schemaType": "Protobuf"
},
"partitions": 1,
"cleanupPolicies": ["delete"],
"replicationFactor": 1,
"deleted": true,
"owners": [],
"tags": [],
"domains": []
}
Delete a Topic
Delete a topic by ID or name, with soft/hard delete options
DELETE
/
v1
/
topics
/
{id}
DELETE /v1/topics/{id}
from metadata.generated.schema.entity.services.connections.metadata.openMetadataConnection import (
AuthProvider,
OpenMetadataConnection,
)
from metadata.generated.schema.security.client.openMetadataJWTClientConfig import (
OpenMetadataJWTClientConfig,
)
from metadata.ingestion.ometa.ometa_api import OpenMetadata
from metadata.generated.schema.entity.data.topic import Topic
metadata = OpenMetadata(
OpenMetadataConnection(
hostPort="https://your-company.open-metadata.org/api",
authProvider=AuthProvider.openmetadata,
securityConfig=OpenMetadataJWTClientConfig(jwtToken="your-jwt-token"),
)
)
# Soft delete by ID
metadata.delete(entity=Topic, entity_id="0a021819-982e-4ee4-a5a2-4af30eaa3016")
# Hard delete
metadata.delete(
entity=Topic,
entity_id="0a021819-982e-4ee4-a5a2-4af30eaa3016",
hard_delete=True
)
# Delete by name
topic = metadata.get_by_name(entity=Topic, fqn="sample_kafka.address_book")
metadata.delete(entity=Topic, entity_id=topic.id)
# Delete by name with options
topic = metadata.get_by_name(entity=Topic, fqn="sample_kafka.address_book")
metadata.delete(entity=Topic, entity_id=topic.id, hard_delete=True)
# Restore a soft-deleted topic
metadata.restore(entity=Topic, entity_id="0a021819-982e-4ee4-a5a2-4af30eaa3016")
import java.util.Map;
import org.openmetadata.schema.entity.data.Topic;
// client is an initialized OpenMetadataClient.
// Soft delete
client.topics().delete("0a021819-982e-4ee4-a5a2-4af30eaa3016");
// Hard delete
client.topics().delete("0a021819-982e-4ee4-a5a2-4af30eaa3016", Map.of("hardDelete", "true"));
// Delete by name (look up the ID first)
Topic topic = client.topics().getByName("sample_kafka.address_book");
client.topics().delete(topic.getId());
// Restore
client.topics().restore("0a021819-982e-4ee4-a5a2-4af30eaa3016");
# Soft delete by ID
curl -X DELETE "{base_url}/api/v1/topics/0a021819-982e-4ee4-a5a2-4af30eaa3016" \
-H "Authorization: Bearer {access_token}"
# Hard delete
curl -X DELETE "{base_url}/api/v1/topics/0a021819-982e-4ee4-a5a2-4af30eaa3016?hardDelete=true" \
-H "Authorization: Bearer {access_token}"
# Delete by name
curl -X DELETE "{base_url}/api/v1/topics/name/sample_kafka.address_book" \
-H "Authorization: Bearer {access_token}"
# Restore soft-deleted topic
curl -X PUT "{base_url}/api/v1/topics/restore" \
-H "Authorization: Bearer {access_token}" \
-H "Content-Type: application/json" \
-d '{"id": "0a021819-982e-4ee4-a5a2-4af30eaa3016"}'
{
"id": "0a021819-982e-4ee4-a5a2-4af30eaa3016",
"name": "address_book",
"fullyQualifiedName": "sample_kafka.address_book",
"description": "All Protobuf record related events gets captured in this topic",
"version": 0.2,
"updatedAt": 1769982663546,
"updatedBy": "admin",
"service": {
"id": "469ef25e-9bdf-4d5f-8553-eb0ce8581f30",
"type": "messagingService",
"name": "sample_kafka",
"fullyQualifiedName": "sample_kafka"
},
"serviceType": "Kafka",
"messageSchema": {
"schemaText": "syntax = \"proto2\";\npackage tutorial;\nmessage Person { ... }",
"schemaType": "Protobuf"
},
"partitions": 1,
"cleanupPolicies": ["delete"],
"replicationFactor": 1,
"deleted": true,
"owners": [],
"tags": [],
"domains": []
}
Delete a Topic
Delete a topic by ID or fully qualified name. Supports soft delete (default), hard delete, and restore operations.Delete by ID
string
required
UUID of the topic to delete.
boolean
default:"false"
Recursively delete child entities.
boolean
default:"false"
Permanently delete the topic. If
false, the topic is soft-deleted and can be restored.Delete by Name
UseDELETE /v1/topics/name/{fqn} to delete by fully qualified name.
string
required
Fully qualified name of the topic, for example
sample_kafka.address_book.boolean
default:"false"
Recursively delete child entities.
boolean
default:"false"
Permanently delete the topic.
Restore a Soft-Deleted Topic
UsePUT /v1/topics/restore to restore a soft-deleted topic.
string
required
UUID of the soft-deleted topic to restore.
DELETE /v1/topics/{id}
from metadata.generated.schema.entity.services.connections.metadata.openMetadataConnection import (
AuthProvider,
OpenMetadataConnection,
)
from metadata.generated.schema.security.client.openMetadataJWTClientConfig import (
OpenMetadataJWTClientConfig,
)
from metadata.ingestion.ometa.ometa_api import OpenMetadata
from metadata.generated.schema.entity.data.topic import Topic
metadata = OpenMetadata(
OpenMetadataConnection(
hostPort="https://your-company.open-metadata.org/api",
authProvider=AuthProvider.openmetadata,
securityConfig=OpenMetadataJWTClientConfig(jwtToken="your-jwt-token"),
)
)
# Soft delete by ID
metadata.delete(entity=Topic, entity_id="0a021819-982e-4ee4-a5a2-4af30eaa3016")
# Hard delete
metadata.delete(
entity=Topic,
entity_id="0a021819-982e-4ee4-a5a2-4af30eaa3016",
hard_delete=True
)
# Delete by name
topic = metadata.get_by_name(entity=Topic, fqn="sample_kafka.address_book")
metadata.delete(entity=Topic, entity_id=topic.id)
# Delete by name with options
topic = metadata.get_by_name(entity=Topic, fqn="sample_kafka.address_book")
metadata.delete(entity=Topic, entity_id=topic.id, hard_delete=True)
# Restore a soft-deleted topic
metadata.restore(entity=Topic, entity_id="0a021819-982e-4ee4-a5a2-4af30eaa3016")
import java.util.Map;
import org.openmetadata.schema.entity.data.Topic;
// client is an initialized OpenMetadataClient.
// Soft delete
client.topics().delete("0a021819-982e-4ee4-a5a2-4af30eaa3016");
// Hard delete
client.topics().delete("0a021819-982e-4ee4-a5a2-4af30eaa3016", Map.of("hardDelete", "true"));
// Delete by name (look up the ID first)
Topic topic = client.topics().getByName("sample_kafka.address_book");
client.topics().delete(topic.getId());
// Restore
client.topics().restore("0a021819-982e-4ee4-a5a2-4af30eaa3016");
# Soft delete by ID
curl -X DELETE "{base_url}/api/v1/topics/0a021819-982e-4ee4-a5a2-4af30eaa3016" \
-H "Authorization: Bearer {access_token}"
# Hard delete
curl -X DELETE "{base_url}/api/v1/topics/0a021819-982e-4ee4-a5a2-4af30eaa3016?hardDelete=true" \
-H "Authorization: Bearer {access_token}"
# Delete by name
curl -X DELETE "{base_url}/api/v1/topics/name/sample_kafka.address_book" \
-H "Authorization: Bearer {access_token}"
# Restore soft-deleted topic
curl -X PUT "{base_url}/api/v1/topics/restore" \
-H "Authorization: Bearer {access_token}" \
-H "Content-Type: application/json" \
-d '{"id": "0a021819-982e-4ee4-a5a2-4af30eaa3016"}'
{
"id": "0a021819-982e-4ee4-a5a2-4af30eaa3016",
"name": "address_book",
"fullyQualifiedName": "sample_kafka.address_book",
"description": "All Protobuf record related events gets captured in this topic",
"version": 0.2,
"updatedAt": 1769982663546,
"updatedBy": "admin",
"service": {
"id": "469ef25e-9bdf-4d5f-8553-eb0ce8581f30",
"type": "messagingService",
"name": "sample_kafka",
"fullyQualifiedName": "sample_kafka"
},
"serviceType": "Kafka",
"messageSchema": {
"schemaText": "syntax = \"proto2\";\npackage tutorial;\nmessage Person { ... }",
"schemaType": "Protobuf"
},
"partitions": 1,
"cleanupPolicies": ["delete"],
"replicationFactor": 1,
"deleted": true,
"owners": [],
"tags": [],
"domains": []
}
Returns
Soft delete returns the topic object withdeleted: true. Hard delete returns no content (204). Restore returns the restored topic object.
Error Handling
| Code | Error Type | Description |
|---|---|---|
401 | UNAUTHORIZED | Invalid or missing authentication token |
403 | FORBIDDEN | User lacks permission to delete this topic |
404 | NOT_FOUND | Topic with given ID or FQN does not exist |
Was this page helpful?