Category: Sitecore AI

Sitecore AI Content Migration – Create transfer and chunks from source environment

To understand the end to end flow for migrating the content between environments, please see this blog post – Link

Pre-requisite – Automation Client and JWT Token

Before starting you will need the JWT token for the request to be made to the Content Transfer API. You should be Sitecore Admin or owner.

To generate the Automation client and token see this blog post – Link

Step 1 – Create Transfer

Used in source environment

Request-

Http Method – POST

URL – https://your-xmc-instance.sitecorecloud.io/sitecore/api/content/transfer/v1/transfers

Headers

Authorization – Bearer token

Payload

{
  "Configuration": {
    "DataTrees": [
      {
        "ItemPath": "/sitecore/content/Home",
        "Scope": "ItemAndDescendants",
        "MergeStrategy": "OverrideExistingItem"
      }
    ],
    "Database": "master"
  },
  "TransferId": "1ec8122c-a25e-49b0-a0fb-bd47dfccdf8b"
}

Response

202 – Accepted

Note the Transfer ID – 1ec8122c-a25e-49b0-a0fb-bd47dfccdf8b

Transfer ID will be used in next API request.

Step 2 – Get Content Transfer

Used in source environment

Get content transfer status or wait for the transfer to be ready

Request

Http Method – GET

Url- https://your-xmc-instance.sitecorecloud.io/sitecore/api/content/transfer/v1/transfers/{transferId}/status

Example – https://your-xmc-instance.sitecorecloud.io/sitecore/api/content/transfer/v1/transfers/1ec8122c-a25e-49b0-a0fb-bd47dfccdf8b/status

Headers

Authorization – token

Payload– Not Applicable

Response

{
    "State": "Completed",
    "ChunkSetsMetadata": [
        {
            "ChunkSetId": "d71458d7-db08-4a74-a125-0d7d4eabf491",
            "ChunkCount": 1,
            "TotalItemCount": 2
        }
    ]
}

Note the chunkSetId – d71458d7-db08-4a74-a125-0d7d4eabf491

Step 3 – Retrieve a chunk

Used in source environment

Method- Get

Url – https://your-xmc-instance.sitecorecloud.io/sitecore/api/content/transfer/v1/transfers/{transferID}/chunksets/{chunksetID}/chunks/{chunkID}

Example – https://your-xmc-instance.sitecorecloud.io/sitecore/api/content/transfer/v1/transfers/1ec8122c-a25e-49b0-a0fb-bd47dfccdf8b/chunksets/d71458d7-db08-4a74-a125-0d7d4eabf491/chunks/0

Headers

Authorization – token

Payload – Not applicable

Response-

Save chunk –

Save response to file (response.bin)

Delete the transfer

Used in source environment

Method – Delete

Url – https://your-xmc-instance.sitecorecloud.io/sitecore/api/content/transfer/v1/transfers/{transferID}

Example- https://your-xmc-instance.sitecorecloud.io/sitecore/api/content/transfer/v1/transfers/1ec8122c-a25e-49b0-a0fb-bd47dfccdf8b

Headers

Authorization – token

Payload – Not applicable

Response

202 Accepted

Summary of API’s

HTTP MethodAPI EndpointPurpose
POST/sitecore/api/content/transfer/v1/transfersCreate a new content transfer.
GET/sitecore/api/content/transfer/v1/transfers/{transferId}/statusRetrieve the status of a specific transfer.
GET/sitecore/api/content/transfer/v1/transfers/{transferId}/chunksets/{chunksetId}/chunks/{chunkId}Download or retrieve a specific chunk from a chunk set.
DELETE/sitecore/api/content/transfer/v1/transfers/{transferId}Delete or cancel a specific transfer.

References

https://developers.sitecore.com/changelog/sitecoreai/01072026/content-transfer-api-and-item-transfer-api-now-available

https://doc.sitecore.com/sai/en/developers/sitecoreai/deploying-sitecoreai/migrating-content-between-sitecoreai-environments.html#alternatives-to-other-package-designer-tasks

https://api-docs.sitecore.com/sai/content-transfer-api

https://api-docs.sitecore.com/sai/item-transfer-api

A Modern Approach to Sitecore Content Migration Using the Content Transfer API and Item Transfer API

Effective 7 July 2026, the Package Designer is no longer available in Sitecore AI. As a result, creating and installing Sitecore packages through the Sitecore Client is no longer supported.

For many years, the Package Designer was one of the most widely used, simplest, and most reliable methods for transferring content between Sitecore environments. However, Sitecore has long provided an alternative through the Sitecore CLI, which supports content serialization and deployment in a more modern, automation-friendly manner.

With the removal of the Package Designer, organizations are encouraged to adopt the Sitecore CLI and the newer Content Transfer and Item Transfer APIs for moving content between Sitecore AI environments.

With the content transfer API uses chunked streaming there is no need to break large migrations into multiple smaller packages formelry we used to do this with the zip package. With the new approach a .raif file is created with the no manual file download or upload.

            SOURCE ENVIRONMENT
      +--------------------------------+
      |   Sitecore CM (Source)         |
      |                                |
      |  Content Transfer API          |
      +---------------+----------------+
                      |
            1. Create Transfer
                      |
                      â–¼
              Transfer Service
                      |
            2. Export Content
                      |
                      â–¼
             Chunk Set Created
                      |
            3. Download Chunks
                      |
                      â–¼
           -----------------------
       Content Transfer (Chunked Streaming)
           -----------------------
            4. Upload Chunks
                      |
                      â–¼
            DESTINATION ENVIRONMENT
      +--------------------------------+
      |  Content Transfer API          |
      +---------------+----------------+
                      |
           5. Complete Chunk Set
                      |
                      â–¼
            RAIF File Generated
                      |
           6. Verify Blob Exists
             GET /sources/blobs
                      |
                      â–¼
             Item Transfer API
                      |
           7. Start Import
                      |
                      â–¼
           Import Processing
                      |
                      â–¼
          Sitecore Master Database
                      |
                      â–¼
           Content Available

Creating authorization for automation client in Sitecore AI

This guide explains how to create and configure authorization for an automation client in Sitecore AI. It covers the prerequisites, steps to register or configure the client, generating the required credentials, assigning appropriate permissions, and validating authentication. By following this guide, you will enable automation tools, scripts, or external applications to securely authenticate with Sitecore AI APIs while adhering to security best practices and the principle of least privilege.

Create the Client credetntials

To generate the environment specific client credentitals select the project and the environment the Client ID and secret to be created for.

Client ID and secret is deplayed. Client secret cannot be shown again, so note this for future use.

Generating JWT token for automation client

Url – https://auth.sitecorecloud.io/oauth/token

client_id – Use your client id

client_secret – use your client secret

audience – https://api.sitecorecloud.io

Use following cuRL command to run the get the token for this client-

curl --location 'https://auth.sitecorecloud.io/oauth/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Cookie: __cf_bm=LMWhyHFoTdNlwF2MqFxH9AVUQ3FleNAC2Tc3dis4aE8-1784278799.3461177-1.0.1.1-dsinakNmEeHaipvn0cpRI9_Q9p7BQc6JpaI8UYtd24vUJibuJ5xg8GMigR12QLFPl4Sttk1A193_e4mqNdj_Y_23zXG5kHynOcDPJnkuTJu2e9Z.iRZnF5TDBaHSWHjw; did=s%3Av0%3Ae990257e-954d-4c0b-9885-648b225b8582.gnfIQeI146L5TXZF13lXJ%2FSKo%2BQ0L4PDj0xUdYVyqyo; did_compat=s%3Av0%3Ae990257e-954d-4c0b-9885-648b225b8582.gnfIQeI146L5TXZF13lXJ%2FSKo%2BQ0L4PDj0xUdYVyqyo' \
--data-urlencode 'grant_type=client_credentials' \
--data-urlencode 'scope=xmcloud.cm:admin' \
--data-urlencode 'client_id=YOUR_CLIENT_ID' \
--data-urlencode 'client_secret=YOUR_CLIENT_SECRET' \
--data-urlencode 'audience=https://api.sitecorecloud.io'

This should generate the JWT token for you to use this to perform automation-

Version issues with Sitecore Graphql Search Query

In this blog post we saw how to use Sitecore Grpahql Search query to filter the items.

But search query has issues with results getting same items with different version in Preview mode. This works fine for the published item (edge) as a single version of item is published.

I created a new version of the same item-

Using the same query

# Write your query or mutation here

query SearchQuery($pageSize: Int = 10, ) {
  search(
    where: {
      AND: [
        {
          name: "_path"
          value: "{B08684BB-3CB0-4DFE-A378-054E26ECC5AE}"
          operator: CONTAINS
        }
        { name: "ProductId", value: "bali-power-bank-3000mah" }
      ]
    }
    first: $pageSize
  ) {
    total
    results {
      id
      name
      version
      url {
        path
      }
	... on Product{
        productId{value}
        productFeature{value}
      }
    }
  }
}

See the output results in same item with versions available in Sitecore-

{
  "data": {
    "search": {
      "total": 2,
      "results": [
        {
          "id": "8716FE4AD58345589AB04369C39F5CC0",
          "name": "bali-power-bank-3000mah",
          "version": 2,
          "url": {
            "path": "/Data/Commerce-Data/Product-Data/bali-power-bank-3000mah"
          },
          "productId": {
            "value": "bali-power-bank-3000mah"
          },
          "productFeature": {
            "value": "UPDATE - official-camera - Product Feature. JIGA power bank is a high-quality battery pack, with all-day powerThe power bank can charge your phone at least 3-5 times,the perfect partner for gamers, camping and business trips."
          }
        },
        {
          "id": "8716FE4AD58345589AB04369C39F5CC0",
          "name": "bali-power-bank-3000mah",
          "version": 1,
          "url": {
            "path": "/Data/Commerce-Data/Product-Data/bali-power-bank-3000mah"
          },
          "productId": {
            "value": "bali-power-bank-3000mah"
          },
          "productFeature": {
            "value": "official-camera - Product Feature. JIGA power bank is a high-quality battery pack, with all-day powerThe power bank can charge your phone at least 3-5 times,the perfect partner for gamers, camping and business trips."
          }
        }
      ]
    }
  }
}

See the highlighted fields in result. Same ID, multiple result set with different versions. Unfortunately, there is no option here to get the latest version. Sitecore has clarified this and raised a bug for same as of October 2025. this might be resolved in future. The related public reference number is DEVEX-2992.

How to solve this issue- This needs to be handled in headless app.

Headless app needs to filter this for each item and should pick only latest version from the result set for the same item.

function GetLatestVersion(products: ProductResult[]) 
{ 
  if (products.length === 0) 
  { return null; } 
  const latestVersions = Object.values( products.reduce<Record<string,        ProductResult>>((acc, item) => { 
  const existing = acc[item.id]; 
  if (!existing || item.version > existing.version) 
  { 
    acc[item.id] = item; 
  } 
  return acc; 
}, 
{})); 
 return latestVersions; 
}

This should only provide the latest version of item.

Loading

XMCloud Graphql Search query

To search items in Sitecore you can use Graphql search query. It uses where conditions which can have AND and OR operators on any fields in an item.

See below examples for using search query.

I have following list of items in Sitecore-

I want to search by ProductId. This item has only one version.

Use below search query-

query SearchQuery($pageSize: Int = 10, ) {
  search(
    where: {
      AND: [
        {
          name: "_path"
          value: "{B08684BB-3CB0-4DFE-A378-054E26ECC5AE}"
          operator: CONTAINS
        }
        { name: "ProductId", value: "bali-power-bank-3000mah" }
      ]
    }
    first: $pageSize
  ) {
    total
    results {
      id
      name
      version
      url {
        path
      }
      ... on Product{
        productId{value}
        productFeature{value}
      }
    }
  }
}

We used the where condition with the AND operator.

AND operator has _path and ProductId for searching a secific product or a list of products matching the search criteria.

Here the value of _path is the folder/path where you want to make the query. It is always good to provide the path to increase the performance of search.

ProductId is the field in item to search on. You can also apply more filters here, for example template you want to search.

Output of the above query-

{
  "data": {
    "search": {
      "total": 1,
      "results": [
        {
          "id": "8716FE4AD58345589AB04369C39F5CC0",
          "name": "bali-power-bank-3000mah",
          "version": 1,
          "url": {
            "path": "/Data/Commerce-Data/Product-Data/bali-power-bank-3000mah"
          },
          "productId": {
            "value": "bali-power-bank-3000mah"
          },
          "productFeature": {
            "value": "official-camera - Product Feature. JIGA power bank is a high-quality battery pack, with all-day powerThe power bank can charge your phone at least 3-5 times,the perfect partner for gamers, camping and business trips."
          }
        }
      ]
    }
  }
}

Loading

Setup XM Cloud Site to host on Vercel

In this blog post we will Link the XM Cloud to Vercel. The XM Cloud site will be hosted in Vercel by Seting up the host

In this blog post we saw how to setup the Vercel Project manually but this whole process can be automated by Creating and linking the host.

Configure Hosting Connection

Login to XM Cloud and navigate to Connections –> Hosting tab

Click on Create connection –> Vercel

Login to Vercel and add Integration

Select the account to connect. In my case its personal account

Select the all projects to integrate, dont selecy any specific project or you will get error. See errors section-

Confirm and Add Integration-

A new Hosting connection is created with the name-

Setup Hosting

Navigate to Projects ==> Environments ==> Sites Tab

Link Vercel Site (Connection been already created)

You can create Hosting connection from here too.

Click “Create and link”

Now you can see the Site is linked to host i.e. Vercel.

Once the Site is linked you should be able to see the project in Vercel

Login to vercel and see the newly created project and deployment in-progress.

In few minutes the deployment should be completed

Click on the domains and should see the Site-

Errors-

Vercel installation will require ‘All Projects’ access. Please change the access on the Vercel installation

Resolution

Delete any exisitng Hosting Connection and re-create the hosting with Integration to be allowed to all projects.

Loading

Use Experience Edge GraphQL to access XM Cloud hosted site

GraphQL delivery API is used to access the published site content. Experience Edge for Experience Manager (XM) is an API-based service from Sitecore that gives you globally replicated, scalable access to your XM Cloud items, layout, and media. You can use the standard publish tools in XM Cloud , but instead of rendering content from a self-hosted Content Delivery environment, Experience Edge provides you a Sitecore-hosted GraphQL API. 

To access the XM Cloud hosted published site content using Expereince Edge follow these steps-

Login to XM Cloud. Navigate to Projects ==> Environments ==>Details tab.

Launch IDE for Live GraphQL

The URL for GraphQL IDE –

https://edge.sitecorecloud.io/api/graphql/ide

GraphQL edge endpoint is –

https://edge.sitecorecloud.io/api/graphql/v1

Let stry a simple query to get siteinfo-

If you see this error- JSON.parse: unexpected character at line 1 column 1 of the JSON data

This means a header with GraphQL token is not provided or incorrect.

Generate Delivery API token-

Add X_GQL-TOKEN in header with newly generated token vlaue

You should now be able to access only the published Site content using Experience Edge.

If you are not able to see the items, you might have not published the ietms

Publish items to edge

Loading

Create Vercel project to host XM Cloud Site

Sitecore XM Cloud Vercel connector helps to host Website to Vercel

Before using this connector you have to create Project and Environment.

Prerequisite

Before we ould start configuring Project in Vercel we need following info-

JSS APP Name- can be found and should be same as configured in package.json in sxastarter folder

In this case it is sxastarter

GRAPHQL ENDPOINT

GraphQL endpoint for published Sitecore items i.e. Delivery/Live endpoint is –

https://edge.sitecorecloud.io/api/graphql/v1

Sitecore API Key

This should be the GraphQL Delivery token i.e. GQL token-

There are different ways to generate GQL Token. One of the way is generate from portal. Login to XM Cloud and navigate to Projects ==> Environments ==> Details tab

Click on Generate Delivery API Key (Note this key as this won’t be avilable again and needs to be re-generated again if lost)

Note this API key as this is required later whilst configuring the Vercel hosting.

Publish Site

Publish the site to Edge before starting to configure Project in Vercel, since we are configuring GraphQL Delivery API token items in Sitecore needs to be published

Create a Project in Vercel

Login to Vercel and Create Project-

Since I have logged in using GitHub account it displays the repositories in Github the project will be based on-

Import the repository-

Configure Project

Once the project is created configure the project by selecting the Framework and repo folder FE code exists-

Choose the Nextjs Framework

Choose the sxastarter folder from the repo i.e. /src/sxastarter

Add following environment variables extracted earlier-

JSS_APP_NAME – sxastarter

GRAPH_QL_ENDPOINT – https://edge.sitecorecloud.io/api/graphql/v1

SITECORE_API_KEY – Delivery API Key generated from portal.

Should have this confiogured in the Vercel Project-

Deploy the Project

Deployment complete-

Visit the Site and should get the same view as configued in local environment and Experience Editor-

Thats all for how to create a Vercel Project and deploy site.

Errors-

If you see error-

The field 'item' does not exist on the type 'query'

Resolution-

Publish the site

Loading

Sitecore Headless SXA – Create, apply and restrict a custom style to renderings

In this blog post I will show how to apply a custom style to a rendering.

Requirement-

I have a requirement to add extra spacing between the components.

There is already a indent-top style which provides this space (20px) but neesd 100px space.

And the same can see in Experience Editor-

Same can also see in css file in sxastarter project-

Create a custom style (indent-large-top)

Create custom style in Sitecore-

Create a new style (Indent Large Top) in Sitecore under Presentations => Styles ==> Spacing

/sitecore/content/scxmcloud/sxastarter/Presentation/Styles/Spacing

Provide the value of the Style-

Create a style in FE project with the same value-

There are various ways you should be able to do this. I am adding 5 times more space to the existing indent-top style.

_indent.scss

// $middle-margin is defined in _margins.scss
.indent-large-top {
  margin-top: calc($middle-margin * 5);
}

Apply a custom style to rendering

Select the component or container you want to apply style and choose option “Indent Large Top” in Spacing section

Now the space between the 2 component is increased and is 100px as per the requirement.

New style applied to container-

Apply style to specific renderings

As above when the style was created it was applied to all renderings.

If you want to restrict the style to be applied to only certain renderings you can do so by setting Allowed renderings field in new created Style item.

For “Indent Large Top” only SectionContainer will be able to see the new Spacing Style.

In Experience Editor you wont see the “Indent Large Top” for other renderings e.g.- for container rendering-

While for Section Container rendering the new style is available-

References-

https://doc.sitecore.com/xp/en/developers/sxa/103/sitecore-experience-accelerator/add-a-style-for-a-rendering.html

Loading

How to set background image using Next js in Sitecore XM Cloud

This is a very common scenario where a background image needs to be set to certain components. Banner’s on any page on your website is a very common place to have a background image.

This blog assumes you have setup the Foundation Head setup or have your own Nextjs project setup implemented using the Sitecore NextJS SDK.

Note: This is not specific to XM Cloud but for any Headless implementation

Foundation Head already has an example on setting the background image using params. In this blog post will explore how this works and where in Sitecore the image can be applied. Will see how this can applied using using OOTB _Background Image item.

To apply image background using rendering parameters to the container see this blog here

Applying background image using rendering field to the components

Background image can be applied to components inheriting the existing __Background Image item to the custom component template.

Create a template for your component. Here I am creating a Banner component-

Inherit _Background Image from /sitecore/templates/Foundation/Experience Accelerator/Presentation/_Background Image

_Background Image has “Background Image” and “Stretch mode” field.

Note that there is a space between the field names, although not recommended but this comes OOTB.

Create a “Banner” JSON Rendering and provide the “Parameters Template”, “Datasource Location” and “Datasource Template” as per your requirement and add this rendering to the “Available Renderings”

Create a Nextjs component in sxastarter project

Note below how the “Background Image” field is set. This is due to the same in field name. Not recommended but this is OOTB.

Experience Editor-

Add a container component in Main placeholder-

Add a newly created component (Banner) in Container placeholder-

Create or select associated content

Once the component is added you should see the button to Add Background Image ( ths is added when the template inherits from _Background Image template.

Select the Background Image and Save-

You should now able to see the background image to component-

Rendering Host-

Reference-

https://doc.sitecore.com/xmc/en/users/xm-cloud/add-a-background-image.html