# Toggle automation schedule Instantly enable or disable the scheduled trigger without altering the cron expression itself. #### Headers **`Authorization`** string required **`Content-Type`** string required ยท `application/json` #### Path Parameters **`automation_id`** string required #### Request Body **`enabled`** boolean required Set `true` to resume the cron schedule or `false` to pause all timed executions. ## Returns The updated automation object including `schedule.enabled` plus previous cron metadata. Basic Request ```bash curl -X POST "https://api.aitronos.com/v1/streamline/automations/sauto_daily_report/schedule/toggle" \ -H "Authorization: Bearer $FREDDY_SESSION_TOKEN" \ -H "Content-Type: application/json" \ -d '{"enabled": true}' ``` ```python import os import requests url = "https://api.aitronos.com/v1/streamline/automations/sauto_daily_report/schedule/toggle" payload = {"enabled": True} response = requests.post( url, headers={ "Authorization": f"Bearer {os.environ['FREDDY_SESSION_TOKEN']}", "Content-Type": "application/json" }, json=payload ) response.raise_for_status() ``` ```javascript const res = await fetch( "https://api.aitronos.com/v1/streamline/automations/sauto_daily_report/schedule/toggle", { method: "POST", headers: { Authorization: `Bearer ${process.env.FREDDY_SESSION_TOKEN}`, "Content-Type": "application/json" }, body: JSON.stringify({ enabled: true }) } ); const automation = await res.json(); ``` With Options ```bash curl -X POST "https://api.aitronos.com/v1/streamline/automations/sauto_daily_report/schedule/toggle" \ -H "Authorization: Bearer $FREDDY_SESSION_TOKEN" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: toggle-sauto_daily_report" \ -d '{"enabled": false}' ``` ```python import os import requests headers = { "Authorization": f"Bearer {os.environ['FREDDY_SESSION_TOKEN']}", "Content-Type": "application/json", "Idempotency-Key": "toggle-sauto_daily_report" } payload = {"enabled": False} requests.post( "https://api.aitronos.com/v1/streamline/automations/sauto_daily_report/schedule/toggle", headers=headers, json=payload, timeout=10 ).raise_for_status() ``` ```javascript const headers = new Headers({ Authorization: `Bearer ${process.env.FREDDY_SESSION_TOKEN}`, "Content-Type": "application/json", "Idempotency-Key": "toggle-sauto_daily_report" }); await fetch( "https://api.aitronos.com/v1/streamline/automations/sauto_daily_report/schedule/toggle", { method: "POST", headers, body: JSON.stringify({ enabled: false }) } ); ``` Advanced ```bash toggle() { automation_id="$1"; state="$2" curl -s -X POST "https://api.aitronos.com/v1/streamline/automations/$automation_id/schedule/toggle" \ -H "Authorization: Bearer $FREDDY_SESSION_TOKEN" \ -H "Content-Type: application/json" \ -d "{\"enabled\": $state}" } toggle sauto_daily_report true toggle sauto_inventory_cleanup false ``` ```python import os import requests session = os.environ["FREDDY_SESSION_TOKEN"] ids = ["sauto_daily_report", "sauto_inventory_cleanup"] for automation_id in ids: payload = {"enabled": automation_id.endswith("report")} response = requests.post( f"https://api.aitronos.com/v1/streamline/automations/{automation_id}/schedule/toggle", headers={ "Authorization": f"Bearer {session}", "Content-Type": "application/json" }, json=payload ) print(automation_id, response.status_code) ``` ```javascript async function toggleSchedule(id, enabled) { const response = await fetch( `https://api.aitronos.com/v1/streamline/automations/${id}/schedule/toggle`, { method: "POST", headers: { Authorization: `Bearer ${process.env.FREDDY_SESSION_TOKEN}`, "Content-Type": "application/json" }, body: JSON.stringify({ enabled }) } ); if (!response.ok) throw new Error(`Toggle failed for ${id}`); return response.json(); } await toggleSchedule("sauto_daily_report", true); await toggleSchedule("sauto_inventory_cleanup", false); ``` **Response:** 200 OK ```json { "id": "sauto_daily_report", "name": "Daily Report Generation", "schedule": { "enabled": true, "cron_expression": "0 10 * * 1", "timezone": "Europe/Zurich" } } ``` 400 Bad Request ```json { "success": false, "error": { "code": "MISSING_ENABLED_FLAG", "message": "enabled must be provided", "status": 400, "trace_id": "req_f9a77bde" } } ``` 401 Unauthorized ```json { "success": false, "error": { "code": "UNAUTHORIZED", "message": "Missing session token", "status": 401, "trace_id": "req_1a94a7af" } } ``` 404 Not Found ```json { "success": false, "error": { "code": "AUTOMATION_NOT_FOUND", "message": "Automation sauto_daily_report was not found", "status": 404, "trace_id": "req_59ebcf7d" } } ``` 429 Rate Limit ```json { "success": false, "error": { "code": "RATE_LIMIT", "message": "Too many schedule toggles", "status": 429, "retry_after": 15, "trace_id": "req_4ee6b894" } } ``` 500 Server Error ```json { "success": false, "error": { "code": "INTERNAL_ERROR", "message": "Unable to toggle schedule", "status": 500, "trace_id": "req_2a3d1c24" } } ``` ## Related - [Set cron schedule](/docs/api-reference/streamline/automations-set-schedule) - [Remove schedule](/docs/api-reference/streamline/automations-remove-schedule)