UniteLabs
Guides

How to trigger a workflow?

This guide describes how to trigger a flow using the UniteLabs Platform, API via Postman and Python.

Overview

After creating a workflow, you might want to run the workflow. This can be done in multiple ways:

This guide walks you through the approaches to trigger a workflow, using:

Please select the desired option to see how to trigger a workflow could work:

Trigger a workflow via the
UniteLabs Web App

  1. Select a flow
    Choose the workflow you would like to run
  2. Run the flow
    Click the "Run" button. You'll see the output and logs appear in the dedicated pane, showing the execution of your workflow and its state changes.
    Screenshot: Run Workflow
  3. Review the flow run
    After the flow run is triggered, you will be able to review the flow run via the following tabs: Screenshot: Run Workflow

Trigger a workflow via the API testing tool 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

Trigger a workflow via a Python script

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())
    

The name parameter sets the name of the run that is created from this call. The parameters field contains the entrypoint variables as defined by the workflow. The workflow ID can be found in the URL of the workflow view: platform_workflows_workflowID.png

or the GET /workflows endpoint: platform_workflows_api_getworkflow.png

  1. Create the flow on the platform. For this example use this:
  from prefect import flow, get_run_logger
  
  @flow
  async def flow(test: str = "Hello World"):
      logger = get_run_logger()
      logger.info(test)
  1. Run the script:
    uv run python main.py
    

Copyright © 2025