<@ULVA73B9P> how do i send a curl request (with a ...
# ask-marvin
a
@Marvin how do i send a curl request (with a msg input) to a controlFlow agent running in prefect cloud?
m
thought for 218.4 seconds
a
??
m
Short answer: you don’t call a ControlFlow agent “directly” in Prefect Cloud. You trigger a Prefect deployment (that wraps your agent) via the Prefect Cloud REST API and pass your
msg
as a flow parameter. Assuming Prefect 3.x, here’s the curl you’re after:
Copy code
# required values
ACCOUNT_ID="your-account-id"
WORKSPACE_ID="your-workspace-id"
DEPLOYMENT_ID="your-deployment-id"
PREFECT_API_KEY="pnu_..."  # user or service account key

curl -X POST \
  "<https://api.prefect.cloud/api/accounts/${ACCOUNT_ID}/workspaces/${WORKSPACE_ID}/flow_runs>" \
  -H "Authorization: Bearer ${PREFECT_API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{
    "deployment_id": "'"${DEPLOYMENT_ID}"'",
    "parameters": {
      "msg": "Hello, agent."
    },
    "name": "agent-run-from-curl"
  }'
- This creates a flow run for your deployment and passes
{"msg": "Hello, agent."}
to the flow. - Your flow needs to accept a
msg
parameter and hand it to your ControlFlow agent logic. API reference: Create a flow run (Prefect 3 Cloud API) If you actually meant “hit an HTTP endpoint exposed by my agent,” Prefect Cloud does not host arbitrary HTTP endpoints for your code. Options: - Use the REST call above (recommended), or - Create a Cloud Automation with a Webhook trigger that forwards the payload into your flow parameters, then curl the webhook URL. If you want, share how you deployed the agent (flow signature, deployment name) and I’ll tailor the exact payload and endpoint details. I live to serve. Begrudgingly.
a
I've already deployed and triggered the flow. I want to create a remote interactive chatbot, so I need to send an input via http? The agent in the flow is set to 'interactive'.
??
@Marvin??
m
thought for 113.6 seconds
Got it — quick fork in the road: Are you trying to: A) trigger your agent’s deployment with a
msg
parameter, or B) hit a stable webhook URL you can curl directly? Option A — call the Prefect Cloud API to start your deployment with a `msg`:
Copy code
ACCOUNT_ID="your-account-id"
WORKSPACE_ID="your-workspace-id"
DEPLOYMENT_ID="your-deployment-id"
PREFECT_API_KEY="pnu_..."

curl -X POST \
  "<https://api.prefect.cloud/api/accounts/${ACCOUNT_ID}/workspaces/${WORKSPACE_ID}/flow_runs>" \
  -H "Authorization: Bearer ${PREFECT_API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{
    "deployment_id": "'"${DEPLOYMENT_ID}"'",
    "parameters": { "msg": "Hello, agent." },
    "name": "agent-run-from-curl"
  }'
- Your flow must accept a
msg: str
parameter and feed it into your ControlFlow logic. - API reference: Create a flow run Option B — use a Prefect Cloud Webhook (gives you a URL to curl): 1) In Cloud: Automations → New → Trigger: Webhook → Action: Run Deployment. 2) In the action’s parameters, map your flow param, e.g.
msg = {{ event.body.msg }}
. 3) Curl it:
Copy code
curl -X POST "<YOUR_WEBHOOK_URL>" \
  -H "Content-Type: application/json" \
  -d '{"msg":"Hello, agent."}'
- Webhook guide: Create a webhook Tell me which route you prefer (and your deployment/flow param name), and I’ll tailor the exact payload. I can hardly contain my enthusiasm.
a
like i said, i already deployed the workflow, and its running. i need a way for my users to send msg to the running chatbot agent. i was trying to use this cmd: curl -s -X POST "$PREFECT_API_URL/flow_runs/$FLOW_RUN_ID/input" \ -H "Authorization: Bearer $PREFECT_API_KEY" \ -H "Content-Type: application/json" \ -H "x-prefect-api-version: 0.8.5" \ -d '{"key":"default","value":"Hello"}' but doesnt seem to register in the flow logs?? Should a webhook be a better approach
@Marvin
???