<@ULVA73B9P> how do i send a curl request (with a ...
# marvin-ai
a
@Marvin how do i send a curl request (with a msg input) to a controlFlow agent, running in prefect cloud?
m
thought for 981.2 seconds
a
??
m
Great question — assuming you’ve deployed your ControlFlow “agent” as a Prefect 3.x deployment in Prefect Cloud, you can trigger it with curl by creating a flow run from the deployment and passing parameters (e.g.,
msg
) in the request body. Option A: Direct REST API (authenticated) - You’ll need: - Prefect Cloud API key - Your account_id and workspace_id - The deployment_id (or the flow/deployment name to look it up) 1) If you already know the deployment_id:
Copy code
curl -X POST "<https://api.prefect.cloud/api/accounts/ACCOUNT_ID/workspaces/WORKSPACE_ID/deployments/DEPLOYMENT_ID/create_flow_run>" \
  -H "Authorization: Bearer PREFECT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"parameters": {"msg": "hello"}}'
2) If you only know the name (FLOW_NAME/DEPLOYMENT_NAME), look up the deployment_id then trigger:
Copy code
# Look up deployment by name
DEPLOYMENT_ID=$(curl -s \
  -H "Authorization: Bearer PREFECT_API_KEY" \
  "<https://api.prefect.cloud/api/accounts/ACCOUNT_ID/workspaces/WORKSPACE_ID/deployments/name/FLOW_NAME/DEPLOYMENT_NAME>" \
  | jq -r '.id')

# Trigger a flow run with parameters
curl -X POST "<https://api.prefect.cloud/api/accounts/ACCOUNT_ID/workspaces/WORKSPACE_ID/deployments/$DEPLOYMENT_ID/create_flow_run>" \
  -H "Authorization: Bearer PREFECT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"parameters": {"msg": "hello"}}'
Notes: - Your flow should accept a parameter named
msg
(e.g.,
@flow def my_flow(msg: str): ...
). - The response includes the new
flow_run.id
, which you can use to monitor status in the UI or via API. - API reference: Create a flow run from a deployment Option B: Webhook + Automation (no API key on caller) If you prefer a “webhook-style” URL to POST to (useful for external systems), you can: 1) Create a Cloud Webhook (gets you a unique URL) - CLI help:
prefect cloud webhook --help
2) Create an Automation in Prefect Cloud: Trigger “On webhook event” -> Action “Run a deployment” 3) Map the incoming JSON’s
msg
field to the deployment parameter
msg
in the Automation’s parameter mapping. Docs: - Webhooks and automations: Create deployment triggers with automations - Connecting to Cloud / API keys: Connect to Prefect Cloud Want me to tailor the exact curl command for your setup? Share: - Your flow/deployment name (e.g.,
AgentFlow/prod
) - The parameter name(s) you expect (looks like
msg
) - Whether you want to use the direct API or a webhook URL I’ll fill in the placeholders and produce a ready-to-run snippet.