Public API: Subscribe to an Event - pneumaticapp/pneumaticworkflow GitHub Wiki

Subscribing to an Event

Pneumatic currently has the following events you can subscribe to:

event type description
workflow_completed the event gets triggered when any workflow in your Pneumatic account gets completed
workflow_started the event gets triggered at the start of any workflow in your Pneumatic account
task_complted_v2 the event is triggered whenever a task (any task) is completed in your Pneumatic account
task_returned the event gets triggered whenever a task is returned in your Pneumatic account

The endpoint for subscribing to an event is POST https://api.pneumatic.app/webhooks/events/event_name/subscribe

As you can see the event type(name) should be passed in as part of the endpoint url, while the url you want to subscribe to the event is passed in as part of the payload.

Python example:

import requests

api_key = 'your_api_key'
headers = {
  'Authorization': f'Bearer {api_key}'
}
end_point = 'https://api.pneumatic.app/webhooks/events/event_name/subscribe'
payload = {
  'url': subscription_url
}

r = requests.post(end_point, headers=headers, data = payload)

An empty json body is returned in the event of a successful subscription, so basically you can just check whether the response's ok status is true.

It must be borne in mind that currently only one url can listen to a specific type of event at a time, so whenever this POST request is executed it overwrites whatever url was in the event subscription previously