Public API: Create New Workflow - pneumaticapp/pneumaticworkflow GitHub Wiki

Creating a new workflow

In Pneumatic new workflows are created from workflow templates and this pattern still applies when you want to launch a new workflow via API. The end point for launching a new workflow is:

POST https://api.pneumatic.app/templates/<ID>/run

The ID is the id of the template you want to launch a new workflow from.

The parameters that need to be passed in within the body of the request are as follows:

Param Required Description
name no The name of the new workflow, if none is provided, the 'current date - template name' default will be used
is_urgent no the default is false, the parameter specifies whether the new workflow is to be immediately marked as urgent
ancestor_task_id no Provide this parameter only if you want the new workflow to be embedded within an existing task
due_date_tsp no this sets the due date for the workflow as a timestamp
kickoff yes if the kickoff form has required fields This parameter is a json where the keys are the API names of the kickoff field

Let's now see what's launching a new workflow might look like in Python:

mport json
import requests

api_key = 'your_api_key'
headers = {
  'Authorization': f'Bearer {api_key}',
  'Content-Type': 'application/json'
}
template_id = 1
workflow_info = {
  "name":"workflow_name - optional",
  "due_date_tsp":"timestamp due date(optional)",
  "ancestor_task_id":"int|nill - the id of the parent task if launching as an embedded workflow",
  "is_urgent":"bool - set to true if the new workflow is to be marked as urgent",
  "kickoff": { // nullable
    "string-field-1": "Value 1",
    "text-field-2": "Value 2",
    "dropdown-field-3": "selection api_name",
    "checkbox-field-4":["selection api_name", ...],
    "radio-field-5": "selection api_name",
    "date-field-6": "a timestamp as a float",
    "file-field-7": ["attachment ID", ...],
    "url-field-8": "https://grave.com/",
    "user-field-9": 1 // user id
  }
}

json_data = json.dumps(workflow_info)
r = requests.post(
    f'https://api.pneumatic.app/templates/{template_id}/run',
    headers=headers,
    data=json_data,
)

In return you get the full lowdown on the new workflow that's just been launched:

{
  "id": "int",
  "name": "str",
  "description": "str",
  "is_active": "bool",
  "is_public": "bool",
  "public_url": "str | null",
  "public_url": "str | null",
  "public_success_url": "str | null",
  "is_embedded": "?bool,     // default: false"
  "embed_url": "str | null",
  "finalizable": "bool",
  "date_updated": "str", //" ISO 8601 format: YYYY-MM-DDThh:mm:ss[.SSS]"
  "updated_by": "int",
  "template_owners": ["int"],
  "tasks_count": "int",
  "performers_count": "int",
  "kickoff": {
    "id": "int",
    "description": "str",
    "fields": [
      {
        "id": "int",
        "order": "int",
        "name": "str",
        "type": "str",
        "is_required": "bool",
        "description": "str",
        "default": "str",
        "api_name": "str",
        "selections": [ // these are only passed in for radio button checkbox and dropdown fields
          {
            "id": "int",
            "value": "str"
          }
        ]
      }
    ]
  },
  "tasks": [
    {
      "id": "int",
      "number": "int",
      "name": "str",
      "description": "str",
       "delay": "str",       // null if the formal is not aset as: '[DD] [[hh:]mm:]ss'
      "require_completion_by_all": "bool",
      "raw_due_date": {
          "api_name": "str",
          "duration": "str",
          "duration_months": "int, default 0",
          "rule": "str",
          "source_id": "?str | null"
      },
      "raw_performers": [
        {
          "id": "int",
          "type": "user|field|workflow_starter",
          "source_id": "?str", // id the id of a user, group or the api name of the field or null
          "label": "str"       // this is a read only parameter: the user name, group name or field name
        },
      ],
      "checklists": ?[
        {
          "api_name": "str",
          "selecions": [
            {
              "api_name": "str",
              "value": "str"
            }
          ]
        }
      ]
      "fields": ?[
        {
          "id": "int",
            "order": "int",
            "name": "str",
            "type": "str",
            "is_required": "bool",
            "description": "str",
          "default": "str",
            "api_name": "str",
            "selections": [ // these are only passed in for radio button checkbox and dropdown fields
              {
                "id": "int",
                "value": "str"
              }
            ]
        }
      ],
      "conditions": ?[
        {
          "id": "int",
          "action": "str", // end_process, skip_task, start_task
          "order": "int",
          "api_name": "str",
          "rules": [
            {
              "id": "int",
              "api_name": "str",
              "predicates": [
                {
                  "id": "int",
                  "field_type": "str",
                  "value": "Optional[str]",
                  "api_name": "str",
                  "field": "str", // the api_name of the field being used
                  "operator": "str" // equals, not_equals,  exists, not_exists, contains, not_contains, more_than, less_than
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}