Tag defines a named classification value that can be applied to Salesforce metadata records to categorize, describe, or classify them. Each Tag belongs to a TagSet, which defines its category. For example, a DataDomain TagSet could contain Financial, Operational, and Legal Tags.
A Tag defines an available classification value; it does not by itself identify which metadata records use that value. Keep the individual Tag distinct from its TagSet: the Tag is the value, while the TagSet supplies the category and file container.
Key Elements
| Element | What the Element Controls |
|---|---|
name |
Required. The Tag's unique name across the org, not just within its TagSet. It accepts only alphanumeric characters and underscores, must begin with a letter, and cannot contain spaces, end with an underscore, or contain consecutive underscores. |
label |
Required. The text that identifies the Tag in the Salesforce user interface. This is distinct from name. |
fullName |
The metadata full name inherited from the base Metadata type. |
options |
A collection of TagOption entries describing options associated with the Tag. Each entry requires a name and a boolean value, either true or false. |
properties |
A collection of TagProperty entries describing properties associated with the Tag. Each entry requires a name and a string value. |
Behavior and Constraints
The parent TagSet does not limit the scope of name uniqueness. A Tag's name must be unique throughout the org, even when Tags belong to different TagSets. The user-facing label is a separate required field; do not treat it as a substitute for name.
The optional description holds descriptive text about the Tag. The options and properties collections also describe the Tag itself. They are not assignments of the Tag to other metadata records, so those collections do not establish where the classification is used.
Deployment and Retrieval
Tag components are stored as children of TagSet in .tagset files. Preserve that parent-child structure when interpreting retrieved metadata: the file container is the TagSet, and each Tag is an individual classification value within it.
Tag does not support the wildcard character * in package.xml, the manifest that selects metadata components for deployment or retrieval. Do not rely on a wildcard entry to select Tags. Use listMetadata() to discover custom Tags and TagSets in the org.
Relationships
TagSet is the parent category and file container for Tag. The base type Metadata supplies the inherited fullName field. Within a Tag, TagOption and TagProperty are nested entry structures used by options and properties, respectively; they describe the classification value rather than its use on another metadata record.
Common Questions
Can I retrieve all Tags with a wildcard in package.xml?
No. Tag does not support * in package.xml. Use listMetadata() to discover custom Tags and TagSets rather than relying on wildcard selection.
Where are Tag components stored in retrieved metadata?
Tags are stored as children of TagSet in .tagset files. Interpret each Tag within its parent TagSet, which provides the category and file container.
Can two TagSets contain Tags with the same name?
No. A Tag's required name must be unique across the org, not merely within its parent TagSet.
Does deploying a Tag assign it to metadata records?
The Tag definition establishes an available classification value; it does not by itself identify which metadata records use it. Its options and properties describe the Tag, not assignments to other records.