Guides
How to trigger a flow via API?
This guide describes how to trigger a flow using the UniteLabs API via Postman and Python.
Overview
This guide walks you through two approaches to trigger a flow via the UniteLabs API:
- Using Postman
- Using a Python script
Using Postman
Refer to the official Postman documentation on OAuth2.0 authentication for detailed guidance and advanced options.
- Create a new request in Postman.
- Go to the Authorization tab and select OAuth 2.0 as the Auth Type.
- Scroll to Configure New Token and enter the following:
- Token Name:
UniteLabs
- Grant Type:
Client Credentials
- Access Token URL:
https://auth.unitelabs.io/realms/<tenant-id>/protocol/openid-connect/token
- Client ID:
- Client Secret:
- Scope:
openid
- Client Authentication:
Send as Basic Auth header
- Token Name:
- Click Get New Access Token.
- Click Use Token on the overlay.
- Test the token:
Send a GET request to:https://api.unitelabs.io/<tenant-id>/v1/workflows/<workflow-id>
- Trigger the flow:
Send a POST request to:https://api.unitelabs.io/<tenant-id>/v1/workflows/<workflow-id>/runs
with the following JSON body:{ "name": "My flow run", "parameters": { "test": "Hello, World!" } }
Using Python
The triggering of a workflow via API is even simpler via Python:
- Initialize a new Python project:
uv init unitelabs-trigger cd unitelabs-trigger
- Install the UniteLabs SDK:
uv add unitelabs-sdk --index https://gitlab.com/api/v4/groups/1009252/-/packages/pypi/simple
- Edit
main.py
with the following content:import asyncio from unitelabs.sdk import Client async def main(): async with Client( base_url="https://api.unitelabs.io/<tenant-id>", auth_url="https://auth.unitelabs.io/realms/<tenant-id>/protocol/openid-connect", client_id="<your client id>", client_secret="<your client secret>", ) as client: response = await client.post( url="/workflows/<workflow-id>/runs", json={"name": "Run from python", "parameters": {"test": "Hello, World!"}}, ) print(response) if __name__ == "__main__": asyncio.run(main())
- Run the script:
uv run python main.py