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

Onboard DAM to CMS (SaaS)

At present, you must contact Support to integrate DAM in CMS (SaaS) and grant access to an experimental preview 3 of the API. There are three types available for the DAM integration and these need to configured accordingly in a request to the API.

TypeKeySource KeySource Type
ImagesDamImageSourcecmpcmp_PublicImageAsset
VideosDamVideoSourcecmpcmp_PublicVideoAsset
FilesDamRawFileAssetcmpcmp_PublicRawAsset

Replace the parameters key, sourceKey and sourceType with the values in the previous table. The remainder of the request should remain intact.

📘

Note

This step is temporary and the CMS API in preview3 is experimental and is subject to change. Go to Settings > API Keys to create the credentials used to interact with the API. Create a key for this purpose and use the Client Id and Secret when authenticating.

Authenticate

curl --location '{{host}}/\_cms/preview3/oauth/token'  
--header 'Content-Type: application/json'  
--data  '  
{  
   "grant_type": "client_credentials",  
   "client_id": "{{clientid}}",  
   "client_secret": "{{clientsecret}}"  
}'

Create Content Source

curl --location '{{host}}/\_cms/preview3/experimental/contentsources'  
--header 'Content-Type: application/merge-patch+json'  
--header 'Authorization: Bearer {{your_access_token}}'  
--data '  
{  
      "key": "DamImageSource",  
      "displayName": "DAM Image",  
      "sourceKey": "cmp",  
      "sourceType": "cmp_PublicImageAsset",  
      "type": "graph",  
      "guidIdFormat": "digits",  
      "propertyMappings":[  
        {  
            "cmsKey": "Id",  
            "sourceKey": "Id"  
        },  
        {  
            "cmsKey": "Name",  
            "sourceKey": "Title"  
        },  
        {  
            "cmsKey": "Url",  
            "sourceKey": "Url"  
        }  
      ],  
      "contentBaseType": "image"  
}'

Delivery to the frontend

Optimizely Graph is the delivery channel for content in CMS SaaS and this is also true for DAM assets. Content is indexed into Optimizely Graph including the reference of the DAM assets identity. Optimizely Graph queries for CMS content include the DAM asset with its data in a shared result. You do not need additional lookups to retrieve DAM data because the data is included in the response.

Query example of CMS and DAM content

In Optimizely Graph, the following code shows how to query an Examplecontent type page that has three ContentReference properties, MainImage, Video and Pdf and return a joint result of CMS and DAM data. In the example is Video and Pdf ordinary ContentReference properties without item type specified. The ContentReference property MainImage on the other hand has item type specified as 'cmp_PublicImageAsset' and therefore that does not need to be projected/casted in query.

query PageWithAssetsQuery {
  Example(
    where: { _metadata: { key: { eq: "303ddcad1b7c4895a730abbb0730a677" } } }
  ) {
    items {
      _id
      Title
      MainImage {
        url {
          graph
        }
        item {
           Id
           Url
           Title
        }
      }
      Video {
        item {
          ... on cmp_PublicVideoAsset {
            Id
            Url
            Title
          }
        }
      }
      Pdf {
        item {
          ... on cmp_PublicRawFileAsset {
            Id
            Url
            Title
          }
        }
      }
    }
  }
}
{
  "data": {
    "Example": {
      "items": [
        {
          "_id": "303ddcad-1b7c-4895-a730-abbb0730a677_en_Published",
          "Title": "This CMS is the page title",
          "MainImage": {
            "url": {
              "graph": "graph://cmp/cmp_PublicImageAsset/9e12db58114f11f09358feebe22be741"
            },
            "item": {
              "Id": "c010ae43a6d648319b8e8dd97efe7948",
              "Url": "https://images1.cmp.optimizely.com/Zz1jMDEwYWU0My1hNmQ2LTQ4MzEtOWI4ZS04ZGQ5N2VmZTc5NDg=",
              "Title": "Example DAM image asset"
            }
          },
          "Video": {
            "item": {
              "Id": "e59ca3d8308740d5960e8f0ef2663a14",
              "Url": "https://fehcwm.files.cmp.optimizely.com/download/e59ca3d8308740d5960e8f0ef2663a14",
              "Title": "Example DAM video asset"
            }
          },
          "Other": {
            "item": {
              "Id": "5ace995264a94742a577f17ef76ea64d",
              "Url": "https://fehcwm.files.cmp.optimizely.com/download/5ace995264a94742a577f17ef76ea64d",
              "Title": "Example DAM Pdf asset"
            }
          }
        }
      ]
    }
  },
  "extensions": {
    "correlationId": "94d8440bb95b1a2c",
    "cost": 75,
    "costSummary": [
      "Example(75) = limit(20) + fields(3) + basicFilter(1)*2 + links(1)*50"
    ]
  }
}

Export and import across instances

Currently exporting content that uses DAM assets from one CMS instance and importing it into another is currently not supported.