-
Notifications
You must be signed in to change notification settings - Fork 11
Public API: Create Template
The end point for creating a new template is:
POST https://api.pneumatic.app/templates
To create a new template via the API you essentially need to send Pneumatic the entire json for your template.
In Python this exercise will look as follows:
import json
import requests
api_key = 'your_api_key'
headers = {
'Authorization': f'Bearer {api_key}',
'Content-Type': 'application/json'
}
template_info = {
"name": "template name",
"description": "template descrition optiona",
"template_owners": "[int]",
"is_active": "bool optional, default false",
"is_public": "bool optional, default false",
"public_url": "str | null",
"public_success_url": "string optional, defualt null",
"is_embedded": "bool optional default false",
"embed_url": "str | null",
"finalizable":"bool optional, default false",
"kickoff": {
"description": "string optional",
"fields": [
{
"api_name": "string optional",
"order": "int",
"name": "int",
"type": "int",
"is_required": "bool optional default false",
"description": "string optional",
"default:": "string optional"
"selections": [ #only passed in if there are radio button/checkbox fields
{
"value": "string"
}
]
}
]
},
"tasks": [
{
"number": "int",
"name": "string",
"description": "string optional",
"require_completion_by_all": "bool",
"delay": "string or null: [DD] [[hh:]mm:]ss",
"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 - user or group id or the api_name or null"
"label": "str - user/group/field name, read only"
},
],
"checklists": [
{
"api_name": "string optional",
"selecions": [
{
"api_name": "string optional",
"value": "string"
}
]
}
],
"fields": [#fields are optional
{
"api_name": "string optional",
"order": "int",
"name": "string",
"type": "string,
"is_required": "bool optional, default - false",
"description": "string optiona",
"default": "string optional",
"selections": [ #only passed in for radio buttons, checkboxes and dropdown lists
{
"value": "string"
}
]
}
],
"conditions": [#an optional parameter
{
"action": "string end_process, skip_task, start_task",
"order": "int",
"api_name": "string",
"rules": [
{
"api_name": "string",
"predicates": [
{
"field_type": "string",
"value": "string optional",
"api_name": "string optional",
"field": "string - api name",
"operator": "string equals, not_equals, exists, not_exists, contains, not_contains, more_than, less_than"
}
]
}
]
}
]
}
]
}
json_data = json.dumps(template_info)
r = requests.post(
f'https://api.pneumatic.app/templates',
headers=headers,
data=json_data,
)
The code above offers basic information on what kind of data you need to supply for every kind of template feature such as output fields, descriptions, tasks etc.
It's not the sort of thing you'd do under normal circumstances, like who would want to write out an entire template in json and then send it to Pneumatic, right? The obvious use case here is when you want to copy a template from one account to another: a simple script utilizing the API would get the template you want to copy from one account and then submit it to the target account, after, optionally, doing some manipulations with the source template's json.