Trigger a Workflow

< All Topics

Overview

Triggering a workflow through the BLAM API requires the triggering user to know two pieces of information:

  • BlueprintId of the workflow to trigger
  • Input BlidgetDataType of the Blueprint

The input data type is dependant on the first BLidget contained within the workflow.  In this way, a workflow can be configured to accept almost any input type.  By default, the BLAM API defines 7 standard input types:

  • 0 – None
    { }
  • 1 – Custom
    { ExampleString: “string of text”, ExampleNumber: 1, ExampleArray: [ 1, 2, 3 ] }
  • 2 – Assets
    { AssetIds: [ 1, 2, 3 ] }
  • 3 – AssetVersions
    { AssetVersionIds: [ 1, 2, 3 ] }
  • 4 – AssetFiles
    { AssetFileIds: [ 1, 2, 3 ] }
  • 5 – FileStores
    { FileStoreIds: [ 1, 2, 3 ] }
  • 6 – TextList
    { TextList : [ “string of text 1”, “string of text 2” ] }

All BlidgetDataTypes apart from None and Custom accept input data in a pre-defined BLAM JSON object format.  Custom is a special input type that accepts any JSON object which is then parsed by the input BLidget at workflow run time.  None is unique in that it accepts no input and triggers the workflow with no input data.

Listing available Blueprints

You can list the available Blueprints through the BLAM API by a GET request to /api/workflows/blueprints. Providing an additional parameter InputType to the BLAM API along with the specified BlidgetDataType will filter the returned Blueprints by the specified type:

curl -H "Authorization: Bearer ${TOKEN}" https://yourblam.bluelucy.com/api/workflows/blueprints?InputType=Custom

Example Reponse

[
    {
        "id": 1,
        "name": "Ingest: Register Watchfolder Files"
    }
]

Triggering the Workflow

Triggering the workflow involves sending a POST request to BLAM API at /api/workflows/blueprints/{id}/runs where {id} is the Id number of the workflow blueprint. The POST body should contain the correct formatted JSON object for the blueprint input type. If the workflow is successfully triggered, then the BLAM API returns the workflow run Id which can then be used to check the workflow status for completion.

curl -H "Authorization: Bearer ${TOKEN}" -X POST https://yourblam.bluelucy.com/api/workflows/blueprints/1/runs -H "Content-Type: application/json" --data "{ \"Files\": [ { \"FileName\": \"/dmz/inputfile.mxf\" } ] }"

Example Response

{ "id": 101 }

Polling for Workflow Completion

The status of a workflow can be checked by a GET request to /api/workflows/runs/{id} where {id} is the Id number of the workflow run returned when triggering the workflow.

curl -H "Authorization: Bearer ${TOKEN}" https://yourblam.bluelucy.com/api/workflows/runs/101

Example Response

{
    "id": 101,
    "name": "Manual",
    "status": "Complete",
    "errors": 0,
    "dateTriggered": "2020-07-17T17:29:41.352394",
    "dateFinished": "2020-07-17T17:30:05.8490927",
    "blueprintId": 1,
    "triggeringUserId": 1,
    "input": {
        "data": "{\"Files\":[{\"FileName\":\"/dmz/inputfile.mxf\"}]}"
    },
    "nodes": [ ... ]
}