API Keys

API Keys for Workflow Execution

You can run your workflows remotely and use the results directly in your project code. To enable external execution, you must generate an API key for authentication purposes.

Key Considerations:

  • The API key is linked exclusively to your account. Avoid sharing it to prevent unauthorized access to your workflows.

  • If you no longer want the API key to be valid, you can delete it to revoke its access to all associated queries.

API key Example

Steps to Run a Workflow Externally

  • Step 1: Configure Your Workflow

    • Ensure your workflow is correctly set up with appropriate inputs, outputs, and nodes.

  • Step 2: Generate an API Key

    • Navigate to the Workflow API Keys tab.

    • Generate a new API key.

Note: Save the API key securely, as it will only be displayed once for security purposes.

  • Step 3: Access the Workflow for API Integration

    • Open the workflow you wish to run externally.

    • Locate the API Access example, which will look like this:

curl -X POST 'https://api.miiflow.ai/api/v1/agent_run' \
  -H 'Authorization: Bearer [YOUR_API_KEY]' \
  -H 'Content-Type: application/json' \
  -d '{
    "agent_id": "agent_xxxYYYzzz",
    "input": [JSON String]
  }'
  • Step 4: Replace the Placeholder

    • Replace [YOUR_API_KEY] with the API key generated in Step 2.

    • Modify [JSON String] in the input field to match the parameters defined in your workflow's Trigger Node.

  • Step 5: Execute the API Request

    • Copy and execute the updated API request command in your external environment where the workflow needs to run.

Note: The same API key can be used across different workflows, enabling seamless integration.

Code Example in Python

import requests

# Define the API endpoint and headers
url = "https://api.miiflow.ai/api/v1/agent_run"
headers = {
    "Authorization": "Bearer [YOUR_API_KEY]",
    "Content-Type": "application/json"
}

# Define the payload
data = {
    "agent_id": "agent_xxxYYYzzz",
    "input": {
        "input_parameter_1": 1,
        "input_parameter_1": 2,
        "input_parameter_1": 3
    }
}

# Make the POST request
response = requests.post(url, headers=headers, json=data)

# Print the response
print("Status Code:", response.status_code)
print("Response Body:", response.json())

Last updated