Create/update metadata schema

Create/modify custom metadata schema via the UI

To create custom metadata fields via the UI, go to the Schema tab. Click Create. Each metadata field must have a unique name and a type.

The max number of fields per organization is determined by account tier.

πŸ“˜

Metadata field limit

Know your account limits of maximum number of allowed metadata fields.

Once you create a field, you cannot change the type. You can modify the names of custom metadata schema by clicking the Edit button in the detail view of each schema. You cannot modify the names of reserved fields.

Create/modify custom metadata schema via SDK

import labelbox 
from labelbox.schema.data_row_metadata import DataRowMetadataKind

client = labelbox.Client(api_key="LABELBOX_API_KEY")
metadata_ontology = client.get_data_row_metadata_ontology()

# create a custom metadata schema (string, number, datetime, embedding)
metadata_schema = metadata_ontology.create_schema(name="metadata_name", kind=DataRowMetadataKind.string)
# You can create other metadata schema kinds, just change the kind to be one of: 
# DataRowMetadataKind.number, DataRowMetadataKind.datetime, DataRowMetadataKind.embedding

# get the schema id 
schema_id = metadata_schema.uid

# update a metadata schema's name
metadata_schema = metadata_ontology.update_schema(name="metadata_name", new_name="metadata_name_updated")

# delete a metadata schema by name
status = metadata_ontology.delete_schema(name=metadata_schema.name)

# Enum metadata schema is a bit different since it contains options.
# create an Enum metadata with options
enum_schema = metadata_ontology.create_schema(name="enum_metadata_name", kind=DataRowMetadataKind.enum,
                                       options=["option 1", "option 2"])

# update an Enum metadata schema's name, similar to other metadata schema types
enum_schema = metadata_ontology.update_schema(name="enum_metadata_name", new_name="enum_metadata_name_updated")

# update an Enum metadata schema option's name, this only applies to Enum metadata schema.
enum_schema = metadata_ontology.update_enum_option(name="enum_metadata_name_option_updated", option="option 1",
                                            new_option="option 3")

What’s Next