Moogsoft Docs

createWorkflow

A Graze API POST request that creates a new workflow in the Workflow Engine. The new workflow is automatically active. To move it, use reorderWorkflows.

Back to Graze API Endpoint Reference.Graze API Endpoint Reference

Request arguments

Endpoint createWorkflow takes the following request arguments:

Name

Type

Required

Description

auth_token

String

Yes

A valid auth_token returned from the authenticate request. See the authenticate endpoint for more information.authenticate

moolet_name

String

Yes

Name of the Workflow Engine Moolet that the new workflow belongs to.

workflow_name

String

Yes

Name of the new workflow. Must be unique.

description

String

No

Description of the new workflow.

entry_filter

JSON

No

Filter to determine which events, alerts or Situations can enter the workflow. You can use an SQL-like query. See Filter Search Data for more information on creating SQL-like filters. Leave empty for the workflow to accept all events, alerts or Situations.Filter Search Data

sweep_up_filter

JSON

No

Filter to intake any additional events, alerts or Situations from the database. You can use an SQL-like query. See Filter Search Data for more information on creating SQL-like filters.Filter Search Data

first_match_only

Boolean

Yes

If enabled, events, alerts, and Situations only pass through actions on the first time they enter this workflow.

operations

JSON List

Yes

List of properties relating to each operation:

Name

Type

Required

Description

type

String

Yes

Type of operation. Options are: 'action', 'decision' and 'delay'.

operation_name

String

Yes, for 'action' and 'decision' types.

Name of the operation.

function_name

String

Yes, for 'action' and 'decision' types.

Name of the function.

forwarding_behavior

String

No

function_args

JSON Object

No

Arguments for the function.

duration

Integer

Yes, for 'delay' type.

Length of time before the message goes to the next operation.

reset

Boolean

Yes, for 'delay' type.

Determines whether the timer resets after each occurrence. Not available if you have set a workflow to first_match_only.

The timer is reset only if an occurrence with the same ID is received (alert_id or situation_id) within the current 'delay' timeframe.

Response

Endpoint createWorkflow returns the following response:

Successful requests return a JSON object containing the following:

Type

Description

JSON Object

A JSON object containing the ID of the newly created workflow.

Examples

The following examples demonstrate typical use of endpoint createWorkflow:

Request example

Example cURL request to create a new workflow with a setCustomInfoValue action:setCustomInfoValue

curl -X POST -u graze:graze -k \
     -v "https://localhost/graze/v1/createWorkflow" \
     -H "Content-Type: application/json; charset=UTF-8" \
     --data ' {
        "first_match_only": false,
        "operations": [
            {
                "duration": 0,
                "reset": false,
                "type": "delay"
            },
            {
                "operation_name": "set support team value in custom info",
                "function_name": "setCustomInfoValue",
                "forwarding_behavior": "always forward",
                "function_args": {
                    "value": "NOC",
                    "key": "support_team"
                },
                "type": "action"
            }
 
        ],
        "moolet_name": "Alert Workflows",
        "workflow_name": "Alert Workflow Example",
        "entry_filter": {},
        "active": true,
        "description": "Alert Workflow API Example",
        "sweep_up_filter": {}
        }'
Response example

Example response returning the new workflow ID:

{"id":12}