---
schema_version: "1"
id: 068267dcc5b9b037bd102e3bae6b3000ba41b3a77817cb981c71d0583564e506
title: Step 5. Deploy the API to CloudHub 2.0
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/general/api-led-deploy.md
canonical_url: https://docs.mulesoft.com/general/api-led-deploy
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 353fd211158c00c5e68d01124174e03f7e3d26dfb3636d126aa0e5c67c6bad8b
description: MuleSoft Documentation Site
latest: true
---
---
product: Getting Started
keywords: cloudhub 2.0, api deployment, runtime manager, api-led connectivity, mulesoft deploy, cloudhub deployment, api verification
---

# Step 5. Deploy the API to CloudHub 2.0

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

Deploy your tested API to CloudHub 2.0 to make it accessible from anywhere. You update the project
version, configure deployment settings, and deploy directly from Anypoint Code Builder. After
deployment, verify the API is running by sending a request to its public CloudHub URL.

## Step 5.1: Prepare for Deployment

CloudHub 2.0 requires a release version (not a snapshot). When you scaffolded the project, Anypoint
Code Builder created a `pom.xml` with `-SNAPSHOT` in the version (Maven’s convention for
work-in-progress code). Remove it before deploying.

1.  In Anypoint Code Builder, open `pom.xml` in your project.

2.  Find the `<version>` element and remove `-SNAPSHOT`:

    ```xml
    <groupId>com.mycompany</groupId>
    <artifactId>hello-world-impl</artifactId>
    <version>1.0.0</version>
    <packaging>mule-application</packaging>
    ```

3.  Save the file.

## Step 5.2: Deploy to CloudHub 2.0

1.  Open `hello-world-api.xml` in the editor.

2.  Click ![](/mulesoft/current/en-us/general/_images/icon-deploy.png) (**Deploy to CloudHub**).

    Alternatively, open the Command Palette and select `MuleSoft: Deploy to CloudHub`.

3.  If prompted, click **Allow** to sign in to Anypoint Platform, then select a business group.

4.  When prompted via the VS Code command palette, select **CloudHub 2.0** as the deployment target,
    then select the region to deploy the application to.

5.  At the prompt, select the environment to deploy to.

6.  If the project doesn’t already have a `deploy_ch2.json` file, Anypoint Code Builder indicates
    that a deployment configuration file has been created and opens it for you to review:

    ```json
    {
      "runtime": "4.x.x", (1)
      "applicationName": "hello-world-impl-vh", (2)
      "replicas": 1, (3)
      "replicaSize": "0.1", (4)
      "deploymentModel": "rolling", (5)
      "autoStart": true, (6)
      "ObjectStoreV2": true (7)
    }
    ```

    <table><tbody><tr><td><i data-value="1"></i><b>1</b></td><td>The Mule runtime version to use for the deployment.</td></tr><tr><td><i data-value="2"></i><b>2</b></td><td>Defines part of the URL for accessing your application on CloudHub. This must be unique across all applications deployed to CloudHub 2.0. Update this to include your initials or another unique identifier.</td></tr><tr><td><i data-value="3"></i><b>3</b></td><td>Number of application instances to run. Use 1 for this tutorial; increase for production workloads.</td></tr><tr><td><i data-value="4"></i><b>4</b></td><td>The vCore allocation per replica. 0.1 vCores provides 0.5 GB of memory.</td></tr><tr><td><i data-value="5"></i><b>5</b></td><td>The deployment strategy. Use <code>rolling</code> for zero-downtime updates, or <code>recreate</code> for a full restart.</td></tr><tr><td><i data-value="6"></i><b>6</b></td><td>Starts the application automatically after deployment.</td></tr><tr><td><i data-value="7"></i><b>7</b></td><td>Enables Anypoint Object Store v2 for storing application state.<div><p>Anypoint Code Builder packages the application and deploys it to CloudHub 2.0.</p></div><div><p>The VS Code status bar shows the progress of the deployment.</p></div><div><p>The Output panel opens with <strong>Mule Maven Output</strong> selected.</p></div><div><p>After a couple of minutes, you’ll see <code>Deployment successful</code>.</p></div></td></tr></tbody></table>

7.  Click **Open in Runtime Manager**.

    Your browser opens to Runtime Manager in Anypoint Platform, showing your application.

## Step 5.3: Verify in Runtime Manager

1.  Wait for the status to change from **Deploying** to **Running**.

    ![The application status is Running in Runtime Manager](/mulesoft/current/en-us/general/_images/api-tutorial-app-running-runtime-manager.png)

    > [!NOTE] The first deployment typically takes 5–10 minutes. You can monitor progress in the
    > Output panel (**Mule Maven Output**) in Anypoint Code Builder. As long as the status shows
    > **Deploying** and not an error, the deployment is working.

2.  After the app is running, copy the application URL from Runtime Manager.

    > [!IMPORTANT] The application URL is the base hostname only. Your API endpoint is at the
    > `/api/greeting` path. Don’t send requests to the root URL (`/`) as it returns a 404.

3.  Open Postman and send a request to the full API path:

    ```text
    https://hello-world-impl-jsmith.<space-domain>.cloudhub.io/api/greeting?name=World
    ```

    Replace `hello-world-impl-jsmith.<space-domain>` with the hostname from Runtime Manager.

4.  Verify you receive your greeting:

    ```json
    {
      "message": "Hello, World!"
    }
    ```

Congratulations! Your API is live in the cloud!

## What You Learned

You prepared your project for release and deployed it to CloudHub 2.0 using the built-in deploy
command in Anypoint Code Builder. After deployment, you confirmed the application was running in
Runtime Manager and verified the live endpoint with Postman.

## Troubleshoot Deployment Issues

If your deployment fails with an error message similar to:

Failed to deploy to CloudHub 2.0: PUBLISH 409: ASSET\_PRE\_CONDITIONS\_FAILED. Cannot create a new
asset with the provided groupId, assetId, version, state. An asset already exists with this version
and published lifecycle state.

This means that the version specified in your `pom.xml` is already published to Exchange. Exchange
doesn’t allow you to overwrite published versions.

To resolve this issue:

1.  Open your `pom.xml` file in the project.

2.  Increment the `<version>` element:

    ```xml
    <version>1.0.1</version>
    ```

    > [!TIP] Each time you deploy, you must use a unique version number.

3.  Save the file.

4.  Retry the deployment.

## Developer Deep Dive

Explore advanced CloudHub 2.0 capabilities:

- [CloudHub 2.0 Architecture](https://docs.mulesoft.com/cloudhub-2/ch2-architecture)

- [Shared Spaces](https://docs.mulesoft.com/cloudhub-2/ch2-shared-space-about)

- [Updating Apps Deployed to CloudHub 2.0](https://docs.mulesoft.com/cloudhub-2/ch2-update-apps)

- [Deploying Apps to Private Spaces](https://docs.mulesoft.com/cloudhub-2/ch2-deploy-private-space)

- [Securing Omni Gateway Instances with Policies](https://docs.mulesoft.com/gateway/latest/gateway-secure-apis)

## What’s Next

Now that your API is deployed, learn how to monitor it and view logs in Runtime Manager.

[Step 4. Test the API](https://docs.mulesoft.com/general/api-led-test) [Step 6. Monitor and Manage](https://docs.mulesoft.com/general/api-led-operate)
