Hi :slightly_smiling_face:, I am scoring the docum...
# ask-community
m
Hi ๐Ÿ™‚, I am scoring the documentation but havenโ€™t found the answer yet: on prefect-cloud (in particular) is it possible to run a flow when it receives an http request? What would this look like in prefect?
a
Yes, it's possible! ๐Ÿ™‚ We have a topic about event-driven workflows here https://discourse.prefect.io/t/is-there-an-equivalent-to-sensors-in-prefect-how-do-i-trigger-event-driven-workflows/76 In short, you can e.g. trigger a flow run from some external API using the GraphQL create_flow_run mutation e.g.
Copy code
import requests

query = """
 mutation {
  create_flow_run(input: { version_group_id: "fb919cc4-7f74-4ed7-9f3c-71bdd9be69e8" }) {
    id
  }
}
"""

url = "<https://api.prefect.io>"
response = <http://requests.post|requests.post>(
    url, json={"query": query}, headers={"authorization": "Bearer XXX"}
)
print(response.status_code)
print(response.text)
m
Thank you @Anna Geller this is exactly what I was looking for! ๐Ÿ‘
๐Ÿ‘ 1