# Set automation schedule Create or update the cron expression for a Streamline automation. #### Headers **`Authorization`** string required Bearer token authentication. Use either: - `Bearer ${FREDDY_API_KEY}` for API key authentication - `Bearer ${FREDDY_SESSION_TOKEN}` for session token authentication **`Content-Type`** string required ยท `application/json` #### Path Parameters **`automation_id`** string required #### Request Body **`cron_expression`** string required **`timezone`** string required IANA timezone used to evaluate the cron schedule. ## Returns Confirmation payload with `success`, `message`, and normalized cron expression. Basic Request ```bash curl -X POST "https://api.aitronos.com/v1/streamline/automations/sauto_daily_report/schedule" \ -H "Authorization: Bearer $FREDDY_SESSION_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "cron_expression": "0 10 * * 1", "timezone": "Europe/Zurich" }' ``` ```python import os import requests payload = { "cron_expression": "0 10 * * 1", "timezone": "Europe/Zurich" } requests.post( "https://api.aitronos.com/v1/streamline/automations/sauto_daily_report/schedule", headers={ "Authorization": f"Bearer {os.environ['FREDDY_SESSION_TOKEN']}", "Content-Type": "application/json" }, json=payload ).raise_for_status() ``` ```javascript await fetch( "https://api.aitronos.com/v1/streamline/automations/sauto_daily_report/schedule", { method: "POST", headers: { Authorization: `Bearer ${process.env.FREDDY_SESSION_TOKEN}`, "Content-Type": "application/json" }, body: JSON.stringify({ cron_expression: "0 10 * * 1", timezone: "Europe/Zurich" }) } ); ``` With Options ```bash curl -X POST "https://api.aitronos.com/v1/streamline/automations/sauto_daily_report/schedule" \ -H "Authorization: Bearer $FREDDY_SESSION_TOKEN" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: cron-sauto" \ -d '{ "cron_expression": "*/15 * * * *", "timezone": "UTC" }' ``` ```python import os import requests headers = { "Authorization": f"Bearer {os.environ['FREDDY_SESSION_TOKEN']}", "Content-Type": "application/json", "Idempotency-Key": "cron-sauto" } requests.post( "https://api.aitronos.com/v1/streamline/automations/sauto_daily_report/schedule", headers=headers, json={"cron_expression": "*/15 * * * *", "timezone": "UTC"} ).raise_for_status() ``` ```javascript const headers = new Headers({ Authorization: `Bearer ${process.env.FREDDY_SESSION_TOKEN}`, "Content-Type": "application/json", "Idempotency-Key": "cron-sauto" }); await fetch( "https://api.aitronos.com/v1/streamline/automations/sauto_daily_report/schedule", { method: "POST", headers, body: JSON.stringify({ cron_expression: "*/15 * * * *", timezone: "UTC" }) } ); ``` Advanced ```bash set_schedule() { automation_id="$1"; cron="$2"; tz="$3" curl -X POST "https://api.aitronos.com/v1/streamline/automations/$automation_id/schedule" \ -H "Authorization: Bearer $FREDDY_SESSION_TOKEN" \ -H "Content-Type: application/json" \ -d "{\"cron_expression\": \"$cron\", \"timezone\": \"$tz\"}" } set_schedule sauto_daily_report "0 0 * * *" "UTC" set_schedule sauto_inventory_cleanup "0 12 * * 1" "America/New_York" ``` ```python import os import requests session = os.environ["FREDDY_SESSION_TOKEN"] updates = [ ("sauto_daily_report", "0 0 * * *", "UTC"), ("sauto_inventory_cleanup", "0 12 * * 1", "America/New_York") ] for automation_id, cron_expression, timezone in updates: response = requests.post( f"https://api.aitronos.com/v1/streamline/automations/{automation_id}/schedule", headers={ "Authorization": f"Bearer {session}", "Content-Type": "application/json" }, json={"cron_expression": cron_expression, "timezone": timezone} ) response.raise_for_status() ``` ```javascript async function updateSchedule(id, cron, timezone) { const response = await fetch( `https://api.aitronos.com/v1/streamline/automations/${id}/schedule`, { method: "POST", headers: { Authorization: `Bearer ${process.env.FREDDY_SESSION_TOKEN}`, "Content-Type": "application/json" }, body: JSON.stringify({ cron_expression: cron, timezone }) } ); if (!response.ok) throw new Error(`Schedule update failed for ${id}`); } await updateSchedule("sauto_daily_report", "0 0 * * *", "UTC"); await updateSchedule("sauto_inventory_cleanup", "0 12 * * 1", "America/New_York"); ``` **Response:** 200 OK ```json { "success": true, "message": "Schedule set successfully", "cron": "0 10 * * 1" } ``` 400 Bad Request ```json { "success": false, "error": { "code": "INVALID_CRON", "message": "cron_expression is invalid", "status": 400, "trace_id": "req_1b0e06ce" } } ``` 401 Unauthorized ```json { "success": false, "error": { "code": "UNAUTHORIZED", "message": "Missing session token", "status": 401, "trace_id": "req_e6bcdaf1" } } ``` 404 Not Found ```json { "success": false, "error": { "code": "AUTOMATION_NOT_FOUND", "message": "Automation sauto_daily_report was not found", "status": 404, "trace_id": "req_49ccca7a" } } ``` 429 Rate Limit ```json { "success": false, "error": { "code": "RATE_LIMIT", "message": "Too many schedule updates", "status": 429, "retry_after": 30, "trace_id": "req_6e4e6d1a" } } ``` 500 Server Error ```json { "success": false, "error": { "code": "INTERNAL_ERROR", "message": "Failed to save schedule", "status": 500, "trace_id": "req_9688b6a0" } } ``` ## Cron examples - Every 24 hours: `0 0 * * *` - Every Monday at 10 AM: `0 10 * * 1` - Every 15 minutes: `*/15 * * * *` ## Related - [Toggle schedule](/docs/api-reference/streamline/automations-toggle-schedule) - [Remove schedule](/docs/api-reference/streamline/automations-remove-schedule)