> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://docs.alfa.boosted.ai/alfa/guides/build-with-alfa/scheduling-workplans/schedule-and-automate-workplans/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.alfa.boosted.ai/_mcp/server. # Schedule and automate workplans Once you've created workplans to analyze your data, you'll often want them to update automatically to reflect the latest information. This guide explains how to schedule and automate your workplans to keep their outputs fresh. ## Create a schedule You can customize when your workplan runs using natural language schedules. If the system is unable to parse the request, the workplan will be scheduled to run daily at 8AM in the US/Eastern timezone. You can make further edits this schedule using the same endpoint. ```python def set_workplan_schedule(workplan_id, schedule_description, timezone=None): """Set a custom schedule for a workplan using natural language.""" url = f"{BASE_URL}/v2/workplans/{workplan_id}/set-schedule" payload = { "user_schedule_description": schedule_description } if timezone: payload["workplan_timezone"] = timezone response = requests.post(url, headers=headers, json=payload) if response.status_code == 200: data = response.json() print(f"Schedule updated: {data['schedule']['generated_schedule_description']}") print(f"Next run will use timezone: {data['schedule']['timezone']}") return data else: print(f"Error: {response.status_code}, {response.text}") return None # Set a custom schedule set_workplan_schedule("your-workplan-id", "Weekly on Friday at 3pm", "US/Pacific") ``` The schedule is interpreted by our backend and converted to the appropriate cron expression. You can use natural language to describe when you want your workplan to run. ### Example schedule descriptions Here are some examples of schedule descriptions you can use: * **"Daily at 9:30am"**: Every day at 9:30 AM * **"Weekly on Monday at 7am"**: Every Monday at 7:00 AM * **"Every weekday at 4pm"**: Monday through Friday at 4:00 PM * **"Monthly on the 1st at 12pm"**: First day of each month at 12:00 PM ### Example: Schedule an earnings report workplan to run weekly #### Identify the workplan Select the earnings report workplan you want to schedule #### Set the schedule Configure it to run weekly before market open: ```python # Schedule weekly earnings report before market open workplan_id = "earnings-report-123456" schedule = "Weekly on Monday at 8:30am" timezone = "US/Eastern" result = set_workplan_schedule(workplan_id, schedule, timezone) print(f"Your earnings report will run every Monday at 8:30am Eastern Time") ``` ## View workplan schedule You can view a workplan's schedule using the `view-schedule` endpoint. If no schedule is associated with a workplan, `schedule` will be `null`. ```python def view_workplan_schedule(workplan_id): """View a workplan's schedule.""" url = f"{BASE_URL}/v2/workplans/{workplan_id}/view-schedule" response = requests.get(url, headers=headers) if response.status_code == 200: data = response.json() else: print(f"Error: {repsonse.status_code}, {response.text}") return False # View workplan schedule view_workplan_schedule(workplan_id) ``` ## Cancel workplan schedule If you to cancel workplan scheduling, you can delete the schedule using the `delete-schedule` endpoint: ```python def delete_workplan_schedule(workplan_id): """Deletes a workplan's schedule.""" url = f"{BASE_URL}/v2/workplans/{workplan_id}/delete-schedule" payload = {} response = requests.post(url, headers=headers, json=payload) if response.status_code == 200: data = response.json() if data.get("success"): print("Automation successfully disabled") return data.get("success", False) else: print(f"Error: {response.status_code}, {response.text}") return False # Delete workplan schedule delete_workplan_schedule("your-workplan-id") ``` ## Manually triggering updates If you need updated results immediately, you can manually run a workplan. ```python def rerun_workplan(workplan_id): """Manually trigger a workplan to run again.""" url = f"{BASE_URL}/v2/workplans/{workplan_id}/run-workplan" payload = {} response = requests.post(url, headers=headers, json=payload) if response.status_code == 200: data = response.json() success = data.get("success", False) if success: print("Workplan rerun successfully initiated") return success else: print(f"Error: {response.status_code}, {response.text}") return False # Rerun our workplan to get fresh data rerun_workplan("your-workplan-id") ``` After triggering a rerun, you'll need to check the workplan's status again and retrieve the new outputs once it completes. ### Example: Rerun after breaking news #### Breaking news happens A significant event occurs that impacts your analysis #### Trigger immediate update Don't wait for the next scheduled run: ```python # Trigger immediate update after breaking news workplan_id = "breaking-news-analyzer-123" # Trigger the rerun rerun_success = rerun_workplan(workplan_id) if rerun_success: print("Breaking news analysis has been initiated!") ``` > Learn how to set up automatic updates and scheduling for your Alfa workplans