<@ULVA73B9P> is possible to run a flow from http r...
# ask-marvin
a
@Marvin is possible to run a flow from http request from another server using prefect cloud in the free tier?
m
thought for 59.7 seconds
k
yes!
1
m
Yes, it's absolutely possible to trigger flow runs via HTTP requests from another server using Prefect Cloud's free tier. Here's how you can do it: 1. First, you'll need to generate an API key from your Prefect Cloud account. 2. Then, you can trigger flow runs by making HTTP POST requests to Prefect Cloud's REST API endpoint. Here's a basic example using Python's requests library:
Copy code
python
import requests

PREFECT_API_KEY = "your-api-key"
PREFECT_API_URL = "<https://api.prefect.cloud/api/accounts/{account_id}/workspaces/{workspace_id}/flow_runs>"

headers = {
    "Authorization": f"Bearer {PREFECT_API_KEY}",
    "Content-Type": "application/json"
}

payload = {
    "deployment_id": "your-deployment-id",
    # Optional parameters
    "state": {
        "type": "SCHEDULED",
        "name": "Scheduled"
    }
}

response = <http://requests.post|requests.post>(PREFECT_API_URL, json=payload, headers=headers)
A few important points: - This functionality is available in the free tier - You'll need to replace the placeholder values: - `{account_id}`: Your Prefect Cloud account ID - `{workspace_id}`: Your workspace ID - `your-api-key`: An API key generated from your Prefect Cloud account - `your-deployment-id`: The ID of the deployment you want to run You can find your account ID and workspace ID in the URL when you're logged into the Prefect Cloud UI, and you can generate an API key in the Cloud UI under Settings → API Keys. For more details and the complete API reference, you can check the REST API documentation.
1