API Run

How to run async calls for long-running workflows

API Authorization Setup

To perform API calls, you first need to set up authorization. Follow these steps:

  1. Go to the API keys page, where you'll find the Region code and your Project ID.

  2. To generate your API key, click on "Create new secret key" with the role "Admin" and then click on "Generate API key." Copy the values shown in the modal.

Authorization Token

Authorization tokens are formed by combining the Project ID and API Key. Here's a Python snippet to create the authorization token:

project_id = "YOUR_PROJECT_ID"  # Can be found on the API Keys page
api_key = "YOUR_API_KEY"  # Can be found on the API Keys page
authorization_token = f"{project_id}:{api_key}"
region = "YOUR_REGION"  # Can be found on the API Keys page
base_url = f"https://api-{region}.stack.agenticflow.ai/latest"
headers = {
    "Authorization": authorization_token,
}

Workflow ID

You can find the ID of a workflow in various ways. The easiest method is to use the URL. For example, when on the workflow's Use tab, the component before use/app and after the project ID is the workflow ID. The URL structure is as follows:

https://app.agenticflow.ai/{region}/{project_id}/{workflow_id}/use/app

Example:

workflow_id = "YOUR_WORKFLOW_ID"

Make Async Call for Long-Running Workflow

To trigger a task and check its progress, use the following code:

Last updated