We have a order fulfillment system, where each order has a order_dropped time, whenever an order is dropped in the system, we want to schedule a DAGRun with start time as order_dropped_time+ 30min
how can we do it using Airflow API
We have a order fulfillment system, where each order has a order_dropped time, whenever an order is dropped in the system, we want to schedule a DAGRun with start time as order_dropped_time+ 30min
how can we do it using Airflow API
You can schedule your dag for desired time using airflow restapi, just provide logical_date, data_interval_start, data_interval_end with the time you want. So the dag will be queued and executed when the specified time comes. (don’t forget to replace localhost:8080 with your airflow server url, same with DAG_NAME and user credentials if you have)
curl -X 'POST' \
'http://localhost:8080/api/v1/dags/DAG_NAME/dagRuns' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
--user "{AIRFLOW_USERNAME}:{AIRFLOW_PASSWORD}" \
-d '{
"conf": {},
"dag_run_id": "new_order_run",
"data_interval_end": "2024-10-25T13:46:44.181Z",
"data_interval_start": "2024-10-25T13:46:44.181Z",
"logical_date": "2024-10-25T13:46:44.181Z"
}'