Run standalone workflows with the API
You can run a standalone workflow using the Workflow API. Standalone workflows can be run using RESTful HTTP POST requests in JSON format.
Run a standalone workflow using the Workflow API
To run a standalone workflow using the API:
Navigate to Correlate & Automate > Workflow Engine, then click either the Alert Workflows or the Incident Workflows tab.
Select your workflow from the list and open it.
Under Workflow API, click Show:
Copy the Workflow Endpoint URL. You can run the workflow from anywhere using the endpoint.
You will need to provide an Incident Management API key in the request header, as well as the following attributes in the payload of the POST request. To learn about creating a new API key, see Create an API key:
ids
: The IDs of the alerts or incidents that the workflow will process. This field is required.workflow_id
: The ID of the workflow that you want to run. You can find the ID of the current workflow in the example payload provided in the UI.workflow_context
: Declare workflow context variables and values that will be made available to the workflow during execution.For example,
{ retail: "card-type" }
corresponds to the following workflow context variable:workflowContext.retail = "card-type"
Below is an example of a cURL request invoking a single standalone workflow run request for incidents:
curl "https://api.dev.moogsoft.cloud/v1/incident-workflows/standalone" \ -H "Content-Type: application/json" \ -H 'apiKey: 12345abcde67890fghij12345klmnop67890qrstuv' \ -d '{ "ids": [101] "workflow_id": 99da2aa0f1dd3b1e348bbbb, "workflow_context": { "retail": "card-type" } }'
Compose and send your API request using the copied endpoint.
Standalone workflow API example
Suppose that you want to automate the closure of alerts, but only if the alert has been assigned to someone and has a severity of "Clear." You can use a Workflow API call to run a standalone alert workflow that checks these conditions and closes the alert:
Create a new standalone alert workflow:
Navigate to Correlate & Automate > Workflow Engine, then click the Alert Workflows tab.
Click the Standalone Workflows tab.
Click Add Workflow and provide a name for the workflow. Optionally, provide a description.
Enter the following for the workflow trigger filter:
assignee != NULL AND severity = Clear
Click Add Action, select the Set Status action and then click Add Selected Action.
Set the Status to "Closed."
Save and Enable the workflow.
Get the workflow endpoint URL:
In the page for your standalone alert workflow, under Workflow API, click Show.
Copy the Workflow Endpoint. You can run the workflow from anywhere using the endpoint.
You will need to provide an Incident Management API key in the request header, as well as the following attributes in the payload of the POST request. To learn about creating a new API key, see Create an API key.
Compose and send your API request using the copied endpoint, providing all required fields. Make sure your requests are RESTful HTTP POST requests formatted in JSON.
Without a standalone workflow, you would need to perform multiple API calls to check each condition and close the alert.