Publish and validate content for testing purposes using the Sitecore CLI

In XM Cloud, to make your final content available to front-end applications, you must first publish it to Experience Edge. Content authors usually do this by using the XM Cloud user interface. However, developers sometimes need to publish content using the Sitecore Command Line Interface (CLI), such as in these example use-cases:

  • You are modelling content (for example, adding a new input field) that includes Standard Values with default content (a pre-populated string).

  • You're using the CLI to automate content creation, such as pulling in product information from a Product Inventory Management system (PIM), and publishing that content.

  • You're debugging and troubleshooting various publishing scenarios.

This topic assumes you have the necessary publishing infrastructure, which is automatically created when you deploy your solution to an XM Cloud environment. This infrastructure includes:

  • An Edge tenant.

  • The Edge connector.

  • The Edge publishing target.

This walkthrough describes how to:

  • Publish content using the CLI

  • Validate the published content

Publish content using the CLI

In this walkthrough, you use CLI to publish content from your XM Cloud CM instance.


To use the CLI for operations on the XM Cloud CM instance, you must connect the CLI to the XM Cloud environment.

To publish content using the CLI:

  1. In the project working directory, in a command-line window, log in to XM Cloud using the CLI by running the command:

    dotnet sitecore cloud login

    Follow the steps in the user interface to log in and authorize your device.

  2. Connect the CLI to the environment:

  3. Publish content by running the following command:

    dotnet sitecore publish --pt Edge -n <environment-name>

Validate the published content

After publishing content to Edge, you must verify the content is as you expect and that you can retrieve it from Edge.

To validate the published content:

  1. Generate an Edge API key.

  2. Document the Edge API key. You must use it when working with the client JSS application.

  3. In the GraphQL Playground, validate content retrieval from Edge by running a query for the published content for your site. You must provide the site name. For example:

    query {
      layout(language: "en", routePath: "/", site: "<your-site-name>") {
        item {
      site {
        siteInfoCollection {
          routes(first: 10, language: "en") {
            results {
              route {

Do you have some feedback for us?

If you have suggestions for improving this article,