Skip to content

Public API: Get Workflow Fields

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

Getting Workflow Fields

In this context 'workflow fields' refers to the kickoff form fields and the output fields of every step in the workflow. The endpoint for getting their values is GET https://api.pneumatic.app/workflows/fields. It seems simple enough but in actuality getting these values can be somewhat tricky in the current version of Pneumatic's API.

The catch is that to get the field values of a specific workflow you need to pass in a bunch of parameters with your request, specifically:

Param Required Description
template_id yes the id of the template the workflow whose fields you're getting is based off of
status no the status of the workflow (running, suspended, done)
fields no a comma-separated list of the api_names of the fields you want to get the values of
limit no the page size (the default is 15)
offset no the page number (the default is 0)

Now the detail that the devil's hiding is here is the 'fields' parameter. Essentially, this endpoint will only return the values of the fields whose name you explicitly pass to it as a comma-separated list. And to add insult to injury, at this stage, you need to use the internal 'api names' of the fields. This is what they look like in the GUI:

Screenshot 2024-12-17 at 1 20 07 PM

The field's name in the GUI is deadline, but its internal api name is field-59383d and it's this latter cryptic name that needs to be passed in to this endpoint. Another snag with this endpoint is that it will get you the field values of all the workflows based on the template whose id you passed it as long as they match up with the status parameter (by default you get the fields of all the running workflows).

Anyways, here's some sample Python code:

import requests

api_key = 'your_api_key'
headers = {
  'Authorization': f'Bearer {api_key}',
}

r = requests.get(
    f'https://api.pneumatic.app/workflows/fields',
    headers=headers,
    params={
      'template_id': 1,
      'status': 'done',
      'fields': 'field-1,field-2,field-3',
      'limit': 15,
      'offset': 0
    }
)

What you get in response is a json string structured as follows:

{
  "count": int,
  "next": str?, // link to the next page
  "previous": str?, // link to the previous page
  "results":[
    {
      "id": str,
      "name": str,
      "status": str,
      "date_created": str, // format ISO 8601: YYYY-MM-DDThh:mm:ss[.SSS]
      "date_completed": str, // format ISO 8601: YYYY-MM-DDThh:mm:ss[.SSS]
      "fields": [
        {
          "id": int,
          "task_id": int | null,
          "kickoff_id": int | null,
          "type": str, // string|text|radio|checkbox|date|url|dropdown|file|user
          "api_name": str,
          "name": str,
          "value": str,
          "attachments": [
            {
              "id": int,
              "name": str,
              "url": str
            }
          ],
          "selections": [
            {
              "id": int,
              "api_name": str,
              "value": str,
              "is_selected": bool
            }
          ]
        }
      ]
    }
  ]
}

Notice how the results field in the response contains an array/list of workflow objects.

Historically, the intent of this endpoint was to give people the option to build their own table view where they can see the values of all the fields for a specific category of workflows (template).

There is an article in the Support Center on how you might export these values into a Google sheet, which might be worth checking out: https://www.pneumatic.app/articles/export-values-from-workflow-data-fields/