Scheduled flows run on a timer. That works well for most cases. But some situations demand more control.
What if a downstream system signals it is ready for data at an unexpected time? What if a business event fires at midnight and the next scheduled run is six hours away? What if a CI/CD pipeline needs to seed a dataset before a deployment gate passes? In all these cases, waiting for the scheduler is not an option.
The MuleSoft Anypoint Platform exposes REST APIs that let us trigger a scheduled flow on demand. We do not need to redeploy the app. We do not need to change the scheduler configuration. We send a single HTTP request and the flow runs immediately.
This tutorial covers exactly that. We will build a simple test app in Anypoint Studio, deploy it to CloudHub 2.0, and then use the Platform API to trigger its scheduler programmatically.
What We Will Build
| Step | What We Do |
|---|---|
| 1 | Create a test app in Anypoint Studio |
| 2 | Deploy it to CloudHub 2.0 |
| 3 | Authenticate with a Connected App |
| 4 | Retrieve the deployment ID |
| 5 | Retrieve the scheduler ID and flow name |
| 6 | Trigger the scheduled flow |
| 7 | Verify the result in the application logs |
Prerequisites
- Anypoint Studio installed (7.x or later)
- Access to an Anypoint Platform organization with a CloudHub 2.0 environment
- A Connected App already configured with the following scopes:
Runtime Manager>Read ApplicationsRuntime Manager>Manage Application Data
- A REST client (we use Postman in this tutorial, but any client works)
- Your
orgIdandenvIdfrom Anypoint Platform
Note: This tutorial targets CloudHub 2.0. The same Platform API endpoints also work for Runtime Fabric (RTF) deployments.
Part 1 — Create the Test App in Anypoint Studio
Step 1.1 — Create a New Mule Project
We'll open Anypoint Studio and create a new Mule project. We'll name it scheduler-trigger-demo.
Step 1.2 — Build the Flow
We'll drag the following components into the canvas:
- Scheduler — this is the flow source
- Logger — this writes a message to the log
The flow will look like this in the XML view:
<flow name="scheduledFlow">
<scheduler doc:name="Scheduler">
<scheduling-strategy>
<fixed-frequency frequency="1" timeUnit="MINUTES"/>
</scheduling-strategy>
</scheduler>
<logger
level="INFO"
doc:name="Logger"
message="The flow has been triggered"/>
</flow>
We'll configure the Scheduler component to fire once every minute. This frequency makes it easy to observe in the logs during testing.
The Logger component will write the message The flow has been triggered at INFO level.
Step 1.3 — Deploy to CloudHub 2.0
We'll right-click the project in Studio and select Anypoint Platform > Deploy to CloudHub.
In the deployment dialog, we'll select:
- Deployment target: CloudHub 2.0
- Environment: the target environment (for example,
Sandbox) - Runtime version: the latest supported version
- Replica size and count: the minimum values for a test app
We'll click Deploy Application and wait for the status to reach Running.
Part 2 — Use the Platform API
All Platform API requests target the following base URL:
https://anypoint.mulesoft.com
If your Control Plane is in EU your base URL will be https://eu1.anypoint.mulesoft.com
We will need the following values throughout this section:
| Variable | Description |
|---|---|
{{orgId}} |
The organization ID from Anypoint Platform |
{{envId}} |
The environment ID (for example, Sandbox) |
{{accessToken}} |
The OAuth 2.0 token we obtain in Step 2.1 |
{{deploymentId}} |
Retrieved in Step 2.2 |
{{schedulerId}} |
Retrieved in Step 2.3 |
{{flowName}} |
Retrieved in Step 2.3 |
Step 2.1 — Authenticate with the Connected App
We'll send the following request to obtain an access token.
Request
POST https://anypoint.mulesoft.com/accounts/api/v2/oauth2/token
Content-Type: application/json
Body
grant_type=client_credentials
&client_id={{connectedAppClientId}}
&client_secret={{connectedAppClientSecret}}
cURL
If you use cURL, copy and paste the following command replacing your values
curl 'https://anypoint.mulesoft.com/accounts/api/v2/oauth2/token' \
--header 'Content-Type: application/json' \
--data '{
"client_id" : "<your_connected_app_client_id",
"client_secret" : "<your_connected_app_client_secret>",
"grant_type" : "client_credentials"
}'
Response (example)
{
"access_token": "eyJhbGciOiJSUzI1NiJ9...",
"token_type": "bearer",
"expires_in": 3600
}
We'll copy the access_token value. We'll use it as a Bearer token in all subsequent requests.
Step 2.2 — Get the List of Deployments
We'll send this request to retrieve all deployments in our environment. We need this to find the deploymentId of our app.
Request
GET https://anypoint.mulesoft.com/amc/application-manager/api/v2/organizations/{{orgId}}/environments/{{envId}}/deployments
Authorization: Bearer {{accessToken}}
Response (example — truncated)
{
"items": [
{...},
{
"id": "bba3d38a-9bf1-4b77-831f-f1ac7acc4569",
"name": "scheduler-trigger-demo",
"creationDate": 1776671253728,
"lastModifiedDate": 1776671341912,
"target": {
"provider": "MC",
"targetId": "94c9ea6b-e2d0-41d5-ab77-f2c19f9d4323"
},
"status": "APPLIED",
"application": {
"status": "RUNNING"
},
"currentRuntimeVersion": "4.11.3:4e-java17",
"lastSuccessfulRuntimeVersion": "4.11.3:4e-java17"
},
{...}
]
}
We'll look through the items array and find the entry where name matches scheduler-trigger-demo. We'll copy the id field. That is our {{deploymentId}}.
Step 2.3 — Get the List of Schedulers
We'll use the deploymentId from the previous step to retrieve all schedulers registered in our app.
Request
GET https://anypoint.mulesoft.com/amc/application-manager/api/v2/organizations/{{orgId}}/environments/{{envId}}/deployments/{{deploymentId}}/schedulers
Authorization: Bearer {{accessToken}}
Response (example)
{
"items": [
{
"flowName": "scheduledFlow",
"enabled": true,
"type": "FixedFrequencyScheduler",
"startDelay": "0",
"frequency": "1",
"timeUnit": "MINUTES"
}
],
"total": 1
}
We'll note the value from this response:
flowName— this is the flow we want to trigger (in this example:scheduledFlow)
Step 2.4 — Trigger the Scheduled Flow
We'll now fire the POST request that triggers the flow immediately.
Request
POST https://anypoint.mulesoft.com/amc/application-manager/api/v2/organizations/{{orgId}}/environments/{{envId}}/deployments/{{deploymentId}}/schedulers/{{flowName}}/run
Authorization: Bearer {{accessToken}}
Content-Type: application/json
Body
{}
A successful response returns HTTP 204 No Content with no body, or a minimal acknowledgment payload. No error in the response means the platform accepted the trigger request.
Part 3 — Verify in the Application Logs
We'll navigate to Runtime Manager > Applications in Anypoint Platform. We'll click on scheduler-trigger-demo and open the Logs tab.
We'll look for a log entry that contains the message:
The flow has been triggered
The entry will appear at INFO level with a timestamp that matches the moment we sent the POST request. If we see it, the trigger worked.
Tip: The log entry from the manual trigger and the entry from the automatic scheduler fire look identical. The only difference is the timestamp. Use that to confirm the on-demand execution.
Summary
Here is what we did in this tutorial:
- Built a Mule app with a Scheduler and a Logger in Anypoint Studio
- Deployed the app to CloudHub 2.0
- Authenticated against the Anypoint Platform API using a Connected App
- Retrieved the
deploymentIdfrom the deployments list - Retrieved the
schedulerIdandflowNamefrom the schedulers list - Sent a POST request to trigger the flow immediately
- Confirmed the execution in the application logs
This pattern works the same way for RTF deployments. The API endpoints are identical. Only the infrastructure target changes.
We can extend this approach to build event-driven orchestration, custom operations dashboards, or automated test harnesses — all without touching the deployed application.

