Skip to main content

createWorkflow

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

Back to 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. Alternatively, basic authenticate headers can be used in place of this parameter. See the authenticate endpoint for more information and usage examples.

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 Object

No

An SQL-like filter to determine which events, alerts or Situations can enter the workflow. Leave empty for the workflow to accept all events, alerts or Situations.

See Filter Search Data for more information on creating SQL-like filters.

sweep_up_filter

JSON Object

No

An SQL-like filter to intake any additional events, alerts or Situations from the database.

See Filter Search Data for more information on creating SQL-like filters.

sweep_up_filter_time_limit

Integer

No

A relative time window (in seconds) for further restricting the alerts/Situations in the sweep_up_filter parameter. Default is 0 (no time limit).

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:

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": "state = 9",
        "active": true,
        "description": "Alert Workflow API Example",
        "sweep_up_filter": "((agent = \"Test\") AND (significance = 0)) OR (severity = 0)"
        }'

Response example

Example response returning the new workflow ID:

{"id":12}