Skip to content

Public API: Create New Workflow

Isaiah Fisher edited this page Dec 10, 2024 · 1 revision

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": "date in the DD/MM/YYYY format",
    "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 workflow id and a list of the ids of the first task performers:

{
  "workflow_id": 1,
  "first_task_performers":[int]
}