GET http://hello-world-greeting.sandy-kim.us-e2.cloudhub.io/api/greeting
Step 5. Deploy the API to CloudHub
Now that you’ve created and tested the Mule app that contains your new API from within Studio, you can deploy it to the API to CloudHub. First, you will create an API proxy, which then enables you to test the API from Exchange. You will then set up a rate-limiting policy to protect your API from a denial-of-service attack.
Step 5.1: Deploy API to CloudHub
To deploy this API in the form of a Mule app:
-
From Studio, in the Mule Design perspective, right-click the
hello-worldproject in Package Explorer, and then select Anypoint Platform > Deploy to CloudHub. -
If prompted, enter your Anypoint Platform username and password and click Sign in.

-
You must be in your account’s sandbox to deploy the API. If you see Design instead of Sandbox:
-
Click Design to launch the Switch Environment dialog.
-
Click Sandbox.
-
Click Switch.
-
-
Enter
hello-world-greeting-firstname-lastname; every app and API name must be unique across CloudHub. This example useshello-world-greeting-sandy-kim. -
Verify that Deployment Target is
CloudHub. -
Don’t change any of the other default values.
-
Click Deploy Application. After a brief pause, a window displays the status of the deployment.
-
Click Open in Browser to see the status displayed in Runtime Manager.

When the project is successfully deployed, Runtime Manager displays the status Started.
-
To test the API deployment, send a request from Advanced Rest Client:
-
Click Started to display the App url.
-
Copy the value:
hello-world-greeting.sandy-kim.us-e2.cloudhub.iofor this example. -
In Advanced Rest Client, send a request to the base URI that you just copied. Be sure to add the API endpoint
/greeting: -
If you see
200 OKand the greeting you specified,Today the greeting is Hello., then you have successfully deployed the API you created.
-
Now you need to create an API proxy application for this API, to restrict access and keep the service protected. You will add a rate-limiting policy, which you can do while the API is running.
Step 5.2: Create an API Proxy Application
To add a rate limit policy to your deployed API, you must first add your API to API Manager, and create an API proxy.
-
Log in to Anypoint Platform.
-
Click API Manager.
-
Switch to the sandbox environment.
-
Click Manage API > Manage API from Exchange.
-
Enter
helloand selecthello-worldfrom the drop-down. Note that you are working with the API, not the deployed app namedhello-world-greeting. -
Verify the following values are selected:
-
Asset type: RAML/OAS
-
API version: v1
-
Asset version: 1.0.1
-
Managing type: Endpoint with Proxy
-
Proxy deployment target: CloudHub
-
Mule version: Check the checkbox for Mule 4
-
Implementation URI:
http://hello-world-greeting-sandy-kim.us-e2.cloudhub.io/api. This is the same value as the App url from Step 1, with/apiappended. -
You can ignore TLS context since your API simply returns a hard-coded value.
-
Path:
/ -
Ignore Advanced options.
-
-
Click Save.
API Manager shows you a status page for your new proxy.

Now that your API is managed in API Manager, you can create a proxy in the next step.
Step 5.3. Configure the API Proxy
To create a proxy for the API:
-
If you aren’t on the API Manager
hello-worldAPI settings page from the previous step, navigate there: -
Click API Manager.
-
Click hello-world to open the drop-down.
-
Click v1 to display the proxy settings page.
-
In the top section:
-
Click Add a label.
-
Enter No policy and press Return to save the label.
-
-
In the Deployment Configuration section:
-
Select Runtime version: 4.2.2 or a later version if available.
-
For Proxy application name, which is the name displayed in Runtime Manager, enter hello-world-greeting-proxy, but append your last name or other unique string to ensure the proxy name is unique. The deploy button won’t be enabled until you enter a valid value here.
-
Select Update application if exists.
-
-
Click Deploy. A progress window displays.
-
When deployment is complete, close the progress dialog to return to the settings page.
Now you have an implementation URL that you don’t want to share with the world, and a proxy URL that is safe to share with the world after you configure it.

To configure the proxy:
-
In the Proxy section, right-click the link after Proxy URL and copy the link.
-
At the top of the page, click Add consumer endpoint.
-
Paste in the link you just copied, and press Return to save the link.
Now you can test the proxy endpoint from Exchange:
-
Click View API in Exchange.

-
Click API instances. You can see the Mocking Service version and the new proxy you just created in the Sandbox environment, labeled "no policy."
-
Click /greeting to open, then click GET.
-
Click Mocking Service to open the drop-down menu.
-
Select Sandbox: No policy instance.
-
Click Send. The response should be
200 OKwith the greetingToday the greeting is Hello.
Finish configuring the proxy:
-
Click API instances to return to the list of API instances in Exchange.
-
Select your API.
-
Click Private and then choose Public.
Step 5.4: Add a Rate Limit Policy
To add a rate limit policy:
-
Return to API Manager.
-
Click hello-world.
-
Click v1.
-
In the navigation, select Policies.
-
Click Apply New Policy.
-
Don’t change the default All Mule Versions.
-
Scroll to locate Rate limiting (not Rate limiting - SLA based).
-
Click Rate limiting, select 1.3.5 or a later version if available, and click Configure Policy at the bottom of the dialog box.
-
In the Apply Rate limiting policy page, set the limit values:
-
# of Reqs:
3 -
Time Period:
1 -
Time Unit: Minute
-
-
Select Expose Headers.
-
Select Method & Resource conditions: Apply configurations to all API methods & resources.
-
Click Apply.
The new policy is displayed on the Policies home page.
Change the API instance label so it reflects the fact that you now have a policy on the proxy:
-
Click Settings.
-
Click the edit pencil next to Label and change the value to
Rate-limiting policy.
Test the new policy:
In Advanced Rest Client, send GET requests to the API proxy http://hello-world-greeting-proxy.us-e2.cloudhub.io/greeting (the consumer endpoint plus /greeting) multiple times, until you receive the response 429 Too Many Requests.
What’s Next
Now that your API is deployed as a Mule app to Mule in CloudHub, you can manage it using Anypoint Platform tools.
Developer Deep Dive
MuleSoft provides many deployment options, described in Deploy Mule Applications.



