Disclaimer: This website requires Please enable JavaScript in your browser settings for the best experience.

HomeDev GuideRecipesAPI Reference
Dev GuideAPI ReferenceUser GuideGitHubNuGetDev CommunityOptimizely AcademySubmit a ticketLog In
Dev Guide

Metadata

Learn about the metadata fields available on content types when querying Optimizely CMS (SaaS) content through Optimizely Graph, including how to cast _metadata to specialized types.

Global contract types

A contract is an abstract type which other types can be composed of. Contracts can be user-defined but Optimizely Graph also comes with a set of predefined contracts referred to as global contracts. Global contracts define common fields across multiple products and systems which means there might be overlap of some of the fields between contracts and base types.

_Item

All types implement this contract. This contract defines the field _itemMetadata of type _Metadata.

The type _Metadata defines the following fields:

FieldTypeDescription
keyStringUnique identifier of document.
displayNameStringThe name of the document.
lastModifiedDateTimeWhen the document was last modified.
typeStringThe type of the document.

_AssetItem

All asset types, for example _Media, _Image, and _Video, implements this contract. This contract defines the field _assetMetadata of type _AssetMetadata.

The type _AssetMetadata defines the following fields:

FieldTypeDescription
fileSizeFloatThe size of the document's binary (see url field) in bytes.
mimeTypeStringThe MIME type of the document's binary (see url field).
urlStringThe URL to the document's binary.

_ImageItem

All image types, for example _Image, implement this contract. This contract defines the field _imageMetadata of type _ImageMetadata.

The type _ImageMetadata defines the following fields:

FieldTypeDescription
widthIntThe width of document's image (see url field in _AssetMetadata).
heightIntThe height of document's image (see url field in _AssetMetadata).

Base types

IContentMetadata

The common base type _Content, that all content types inherit, has the property _metadata of type IContentMetadata.

🚧

Important

Content can be displayed as stand-alone instances and as part of other content, for example inside content areas. Therefore _Content._metadata is of type IContentMetadata rather than ContentMetadata.

IContentMetadata can be cast (with fragments) to InstanceMetadata, ItemMetadata, and MediaMetadata, see below.

The type IContentMetadata defines the following fields:

FieldTypeDescription
keyStringUnique identifier of a content instance. The key currently uses a UUID-based format, but this may change, and you should treat the key as an opaque string.
localeStringThe locale is in the format 'language code-country', like 'en-US'. For invariant cultures, the country is omitted, like 'en'. Content that is not localizable has an empty string value.
fallbackForLocaleStringThe locale this instance is available in but hasn't been translated to yet.
versionStringThe version uses an integer-based format, but this may change, and you should treat the version as an opaque string. The version identifier is guaranteed to be unique across versions with the same key.
displayNameStringThe name of the content instance.
urlContentUrlThe URL for the content item. The URL consists of several parts depending on the type of content and the application definitions. See ContentUrl.
types[String]A list of types, where the first item is the content type, then base types, and finally all contracts. Example: ["StandardPage", "_Page", "_Content", "_Item"]. Note that this list changes when you define new contracts.
publishedDateTimeA datetime specified when the content instance was published. For drafts, published is null. Content with a future published date is excluded from public queries until that date is reached.
statusStringThe status of the content version. See content version status values.
changesetStringSpecifies whether this instance is part of a changeset. The value will be default when this instance is the common draft.
createdDateTimeWhen the first content version in the current locale was created.
lastModifiedDateTimeWhen the content version was last modified.
sortOrderIntThe sort order within the same container. See container in InstanceMetadata.
variationStringThe name of the content version if it's created as a variation. See create content variations.

InstanceMetadata

For stand-alone instances, _metadata can be cast to InstanceMetadata, which implements IContentMetadata but adds more fields. The following is an example of a query that casts to InstanceMetadata:

query RouteSegmentQuery {
  _Page {
    items {
      _metadata {
        displayName
        ... on InstanceMetadata {
          routeSegment
        }
      }
    }
  }
}

The type InstanceMetadata defines the following fields:

FieldTypeDescription
locales[String]The locales in which the content exists.
expiredDateTimeWhen the content instance expires. If the date is a time that has passed, the content will be filtered from public queries.
containerStringThe key of the content instance that contains this instance.
path[String]The hierarchy of containers.
ownerStringThe key of the content instance owning this instance if it's a content asset.
routeSegmentStringThe route segment for this content instance. This field is empty for components or blocks that are not routable.
lastModifiedByStringWho last updated the content version.
createdByStringWho created the first version in the current locale.

ItemMetadata

For instances embedded in content areas, _metadata can be cast to ItemMetadata, which implements IContentMetadata but adds more fields. The following is an example of a query that casts to ItemMetadata:

query ContentAreaQuery {
  _StandardPage {
    items {
      ContentAreaProperty {
        ... on TeaserBlock {
          _metadata {
            ... on ItemMetadata {
              displayOption
            }
          }
        }
      }
    }
  }
}

The type ItemMetadata defines the following fields:

FieldTypeDescription
displayOptionStringA string identifier representing the display option selected for this item in the content area (e.g., full, half, narrow).

MediaMetadata

For media content instances, _metadata can be cast to MediaMetadata, like the following:

query MimeTypeQuery {
  _Media {
    items {
      _metadata {
        displayName
        ... on MediaMetadata {
          mimeType
        }
      }
    }
  }
}

The type MediaMetadata defines the following fields:

FieldTypeDescription
thumbnailStringThe URL for a thumbnail of the media content instance.
mimeTypeStringThe mime type for the media content instance.
contentStringContains extracted content from the media instance. See Text extraction field.