UniteLabs
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

Refer to the official Postman documentation on OAuth2.0 authentication for detailed guidance and advanced options.

  1. Create a new request in Postman.
  2. Go to the Authorization tab and select OAuth 2.0 as the Auth Type.
  3. 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
  4. Click Get New Access Token. how-to-trigger-flow-via-api_requestaccess.png
  5. Click Use Token on the overlay. how-to-trigger-flow-via-api_usetoken.png
  6. Test the token:
    Send a GET request to:
    https://api.unitelabs.io/<tenant-id>/v1/workflows/<workflow-id>how-to-trigger-flow-via-api_testtoken.png
  7. 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!"
      }
    }
    

    how-to-trigger-flow-via-api_flowtrigger.png

Using Python

The triggering of a workflow via API is even simpler via Python:

  1. Initialize a new Python project:
    uv init unitelabs-trigger
    cd unitelabs-trigger
    
  2. Install the UniteLabs SDK:
    uv add unitelabs-sdk --index https://gitlab.com/api/v4/groups/1009252/-/packages/pypi/simple
    
  3. 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())
    
  4. Run the script:
    uv run python main.py
    

Copyright © 2025