UDI Identifiers
UDIs are an identifier format in Umbraco. Learn how they are structured, how to query content with them, and how to convert between UDIs and GUIDs.
A Unique Document Identifier (UDI) is a string that identifies an Umbraco entity. An example of a UDI is umb://document/4fed18d8c5e34d5e88cfff3a5b457bf2.
Most Umbraco APIs identify entities by their GUID key. The backoffice and the Management API both work with plain GUIDs. UDIs are more commonly used as a storage and integration format.
Format
A UDI consists of three parts:
Scheme
umb://
Marks the value as an Umbraco identifier.
Entity type
document
The type of entity the identifier points to. Other examples are media, member, and data-type.
Identifier
4fed18d8c5e34d5e88cfff3a5b457bf2
The unique identifier of the entity.
GUID and string UDIs
The identifier part is either a GUID or a string. Which one is used depends on the entity type.
A GuidUdi has a GUID as its identifier. The GUID is written without dashes. Most entity types use this format, such as document, media, and member.
umb://document/4fed18d8c5e34d5e88cfff3a5b457bf2A StringUdi has a string as its identifier, such as a file path or a culture code. A few entity types use this format, such as stylesheet, script, and language.
umb://stylesheet/style.css
umb://language/en-USWhere you encounter UDIs
You do not usually create a UDI yourself. It shows up in stored property values that reference another entity:
The Content Picker and Multi Node Tree Picker property editors store their raw database value as a UDI. For multiple selections, the value is a comma-separated list of UDIs. If you read the stored value, for example with
IContent.GetValue<string>(), you get the UDI string.
Use UdiParser.TryParse() to read the value. See Convert between UDIs and GUIDs.
Query content with a UDI
IPublishedContentQuery accepts UDIs directly through the Content(Udi) and Media(Udi) overloads. You do not need to convert a UDI to a GUID first.
The following example resolves a UDI in a view:
UmbracoHelper exposes the same overloads. In a view that inherits UmbracoViewPage, you can call Umbraco.Content(udi) instead.
Convert between UDIs and GUIDs
Use UdiParser.TryParse() to read a UDI. Parsing is safer than manipulating the string, as it validates both the entity type and the identifier. The Guid property gives you the key used by the GUID-first APIs:
To build a UDI from an entity type and a GUID key, use Udi.Create():
These types are all in the Umbraco.Cms.Core namespace.
Last updated
Was this helpful?