1. Sitecore Command Line Interface

Create a SitecoreAI project using the Sitecore CLI

You can create projects, environments, and deployments with the Sitecore CLI commands provided by the XM Cloud plugin. Using the Sitecore CLI instead of the Deploy app for creating the SitecoreAI project is a matter of preference if your project repository is hosted on GitHub, but it is necessary if your organization hosts source-code repositories on other platforms.

Note

XM Cloud is now SitecoreAI Some code examples, images, and UI labels may still use XM Cloud while engineering assets are being updated.

This walkthrough demonstrates using the Sitecore CLI to deploy a Sitecore solution to a SitecoreAI environment.

Note

Before you begin

This walkthrough describes how to:

  • Log in to SitecoreAI.
  • Create a project.
  • Create an environment for the project.
  • Deploy the solution to the environment.
Note

SitecoreAI supports decoupled deployments, where authoring and editing hosts run as separate environments. When working with decoupled deployments, you must create and manage multiple environment types and explicitly target the correct environment when deploying changes.

Decoupled deployments are enabled by default for new projects, but you can disable this option during project setup to use the legacy coupled deployment model instead. You can find the option to use the legacy coupled deployments during project creation in the Deploy app.

Optional: Obtain the initial source code

If you do not have a SitecoreAI-compatible solution and do not want to host the source code in a GitHub repository, you can obtain an initial solution by cloning a foundation template.

To obtain the initial source code for your project:

Tip

If you use GitHub to host your repositories, the fastest and easiest way to create a project is using the Deploy app. You can then follow the walkthrough to set up your local development environment.

Log in to SitecoreAI

To run CLI commands against the SaaS SitecoreAI platform, you must authorize your device and provide your SitecoreAI credentials. The login process described here performs the necessary device and user authorization and authentication.

You obtain your authentication credentials during the onboarding process.

To log in to SitecoreAI:

  1. In the project working directory, in a command-line window, run the cloud login command:

    shell
    dotnet sitecore cloud login

    The CLI immediately displays information about the [DeviceLogin] process and opens a new browser window.

  2. In the browser window, if the device code displayed in the window matches the User code value displayed in the CLI, click Confirm.

    Device authorization User Code screen
    Note

    If the device code and your command line code do not match, it indicates a severe error or potential security issue, and you must click Cancel. Attempt to log out and log in again.

  3. In the Welcome dialog, in the Email address field, provide the email address associated with your SitecoreAI user account. Click Continue.

  4. In the Password field, enter your user password. Click Continue.

On successful authentication, the page in the browser displays a success message, and the [DeviceLogin] process in the CLI exits.

Tip

You can implement a non-interactive login flow with an authentication/automation client in Deploy app. Use the resulting client credentials with the dotnet sitecore cloud login command. For ease of use, you can write the command with client credentials in an executable script file.

Create a SitecoreAI project

A project within represents a collection of one or more environments.

To create a SitecoreAI project :

  1. In the project working directory, in a command-line window, run the cloud project create command:

    shell
    dotnet sitecore cloud project create --name <project-name>

    For example, dotnet sitecore cloud project create --name MyXMCloudProject

  2. Copy the Project Id assigned to the project and store it for later use.

    Tip

    You can retrieve the project ID at any time by running the following command:

    dotnet sitecore cloud project list

Create an environment for the project

A SitecoreAI environment represents a SaaS Sitecore Content Management (CM) tenant along with all the services and supporting tenants for hosting a Sitecore solution. Every environment belongs to a project.

Note

Projects built before January 2026 were deployed using the legacy coupled deployment architecture. We recommend you to convert these projects to use the decoupled deployments architecture.

Decoupled architecture

When creating environments for decoupled deployments, the CLI requires an environment type to be specified for each environment created. Typically, you will need to create first an authoring environment (cm), followed by a linked editing host (eh). The exact parameter name to be used depends on your CLI version. Refer to the Sitecore CLI help output for the environment creation command to determine how to specify the environment type.

To create an authoring environment for a SitecoreAI project:

  1. In the project working directory, in a command-line window, run the cloud environment create command and enter the project ID:

    shell
    dotnet sitecore cloud environment create --name <name> --project-id <project-id> --cm-only --prod

    For example, dotnet sitecore cloud environment create --name staging --project-id 6btMioN1QDVjSUvQkklkVR --cm-only --prod

  2. Copy the Environment Id assigned to the environment and store it for later use.

    Tip

    You can retrieve the environment ID at any time by running the following command:

    dotnet sitecore cloud environment list --project-id

An editing host is a separate application instance used exclusively for authoring experiences such as Page builder or Design studio. In decoupled deployments, editing hosts are separate from the authoring environment and can be created and deployed independently.

To create the editing host linked to the cm environment:

  1. In the project working directory, in a command-line window, run the following command:

    dotnet sitecore cloud editinghost create -n website -cm $envId
    

    where envId is the authoring environment ID created previously.

Coupled architecture

To create an environment for a SitecoreAI project:

  1. In the project working directory, in a command-line window, run the cloud environment create command and enter the project ID:

    shell
    dotnet sitecore cloud environment create --name <name> --project-id <project-id>

    For example, dotnet sitecore cloud environment create --name staging --project-id 6btMioN1QDVjSUvQkklkVR

  2. Copy the Environment Id assigned to the environment and store it for later use.

    Tip

    You can retrieve the environment ID at any time by running the following command:

    dotnet sitecore cloud environment list --project-id

Deploy the solution to the SitecoreAI environment

The SitecoreAI deployment process deploys an image of your solution to a specified environment. It provisions and configures the necessary infrastructure. This section describes using the --upload CLI command.

To deploy your solution:

  1. In the project working directory, in a command-line window, run the cloud deployment create command and enter the environment ID:

    shell
    dotnet sitecore cloud deployment create --environment-id <environment-id> --upload

    The --upload parameter ensures the Server-side rendering engine endpoint URL and Server-side rendering engine application URL fields are populated with the necessary values. Without these settings, the rendering host will be empty and fail to work with Sitecore layout and page editors.

    The command creates a deployment that starts immediately and includes all the code in the current working directory.

    Tip

    You can retrieve the deployment ID by running the following command:

    dotnet sitecore cloud deployment list --environment-id

  2. When the deployment completes, the CLI prints a URL to the SitecoreAI CM instance. Open the link to view the instance.

  3. To navigate to the Sitecore Launchpad, in the browser address bar, append /sitecore to the root URL of the instance.

The default value for the --upload command parameter is the current working directory. When providing the argument, everything in the directory is packaged and deployed to SitecoreAI unless specified in a .gitignore file.

To use another folder, use the --upload parameter and provide the path to another directory with the --working-dir (-dir) parameter. For example:

shell
dotnet sitecore cloud deployment create --environment-id <id> --no-start --no-watch --upload --working-dir <path>

Additional steps

After deploying your solution to the SitecoreAI platform, you can continue to develop locally and then deploy customizations to the environment. You can also synchronize items between your local development environment and the SitecoreAI CM instance.

See also how to deploy the client/front-end application.

If you have suggestions for improving this article, let us know!