{
  "topic": "schedules",
  "section": {
    "n": 5,
    "name": "Manage"
  },
  "title": "Run something on a timer",
  "covers": "Daily reports, nightly clean-ups and reminders: Embarko calls a route of the app at the times you set",
  "summary": "List the schedules in the app's embarko.json file and Embarko calls those routes of the app on time, for example GET /tasks/daily-digest every weekday at 9:00. The job is normal app code in that route. Embarko keeps a record of each run, and emails the owner if a schedule starts failing.",
  "done_when": "Each schedule ran once with outcome \"ok\", and the person knows when it runs next.",
  "available": true,
  "who": {
    "connector": "deploy_app with embarko.json among the files. Running them once now is HTTP only, with an Embarko key (the deploy token); the person can make one at https://embarko.ai/app/settings/developer",
    "api": "https://ship.embarko.ai/apps (embarko.json in the upload)",
    "dashboard": "https://embarko.ai/app: the app's Overview lists each scheduled job, its last and next run, and All runs. Read-only: no run-now or pause there.",
    "needs_human": "Only their time zone, if you cannot tell it."
  },
  "steps": {
    "any": [
      "Put the job in a GET route of the app, for example /tasks/daily-digest. Answer 2xx when it worked.",
      "First thing in that route: answer 401 unless the Authorization header is \"Bearer \" plus the CRON_SECRET env var. Embarko creates CRON_SECRET for the app; you never set or see it.",
      "Save anything the job must remember under DATA_DIR, not in memory: memory is not kept between runs.",
      "List the job under \"schedules\" in embarko.json, in the app's top folder (see the first example and embarko-json).",
      "Deploy as usual, any way. A bad schedule refuses the deploy before it builds; the error names the entry, e.g. \"Schedule 1: ...\".",
      "Check the test run. The skill runs each schedule once when the app is live and prints ok or the error. Over HTTP: POST links.runSchedules from the deploy reply, then poll each statusUrl until terminal is true.",
      "No HTTP (connector without a token, chat-only, upload page): you cannot run it now. Say so: the first real run is the test, they get an email if it fails, and they can see each run on the app's Overview at https://embarko.ai/app. Or ask for a deploy token (https://embarko.ai/app/settings/developer) and run it over HTTP if you can reach ship.embarko.ai.",
      "If a run failed, fix the route and deploy again.",
      "Tell the person when it runs, in their time zone."
    ],
    "manage": [
      "Change: edit embarko.json and deploy again. The list is the app's full set. A schedule keeps its history while its path stays the same.",
      "Remove one: delete it from the list and deploy. Remove all: \"schedules\": [].",
      "No embarko.json, or one without a \"schedules\" key: the schedules stay as they are.",
      "See runs: GET https://ship.embarko.ai/api/apps/{app-name}/schedules, then each schedule's links.runs. Newest first, 20 a page; add ?page=2, ?outcome=failed or ?trigger=schedule. The reply has total and totalPages. The last 100 runs of each schedule are kept.",
      "Pause one without a deploy: PATCH https://ship.embarko.ai/api/apps/{app-name}/schedules/{schedule-id} with {\"enabled\": false}. The next deploy that lists it turns it back on.",
      "Failure alerts to a webhook: PATCH the schedule with {\"alertWebhookUrl\": \"https://...\"}. The body is the JSON in the example, with no text field, so a Slack incoming webhook rejects it: point it at something that accepts any JSON.",
      "The person can see every schedule and run without the API: the app's Overview at https://embarko.ai/app, Scheduled jobs."
    ]
  },
  "fields": {
    "cron": "Required. Five fields: minute hour day-of-month month day-of-week. \"0 9 * * 1-5\" is 9:00 on weekdays. @hourly, @daily, @weekly, @monthly and @yearly also work.",
    "path": "Required. The route to call, starting with /. A query string is allowed: /tasks/cleanup?days=30. One schedule per path.",
    "timezone": "IANA name, such as Asia/Kolkata or Europe/London. Default UTC. Daylight saving is handled.",
    "name": "Optional, up to 100 characters. Shown in alert emails."
  },
  "receives": [
    "GET {path} on the app's own address, at each due time.",
    "Authorization: Bearer {CRON_SECRET}.",
    "X-Embarko-Schedule-Id and X-Embarko-Run-Id headers, and a User-Agent starting with Embarko-Scheduler/1.0."
  ],
  "run_outcomes": {
    "running": "The call is in progress. Keep polling.",
    "ok": "Final. The app answered 2xx.",
    "failed": "Final. Another status, no answer, a redirect, or no full answer within 5 minutes. error says which; responseExcerpt has the start of the app's reply.",
    "skipped": "Final. The previous run was still going when this one was due."
  },
  "alerts": [
    "The app's owner gets one email when a schedule fails 3 runs in a row, or has been failing for 6 hours with no successful run, whichever comes first. One more email when it works again. A single failed run that the next run fixes sends nothing.",
    "Test runs count too: a failing test run can send that email.",
    "With alertWebhookUrl set, the same two events also go there as JSON (see the example)."
  ],
  "examples": [
    {
      "title": "embarko.json, in the app's top folder",
      "lang": "json",
      "code": "{\n  \"$schema\": \"https://embarko.ai/schema/embarko.json\",\n  \"appId\": \"cmh1q2w3e0001abcdmyapp\",\n  \"schedules\": [\n    {\n      \"cron\": \"0 9 * * 1-5\",\n      \"path\": \"/tasks/daily-digest\",\n      \"timezone\": \"Asia/Kolkata\",\n      \"name\": \"daily digest\"\n    }\n  ]\n}",
      "note": "Next to package.json (or requirements.txt, go.mod...). Only the top folder is read."
    },
    {
      "title": "Deploy with a schedule (skill)",
      "command": "./scripts/deploy.sh ./my-app my-app",
      "note": "Write embarko.json first. When the app is live the script prints a line per schedule, for example \"/tasks/daily-digest: ok (200) Digest sent to 12 people\", and any warnings. It exits 1 if a test run failed."
    },
    {
      "title": "Deploy with a schedule (HTTP) → 202",
      "command": "tar -czf /tmp/app.tar.gz --exclude=node_modules --exclude=.git --exclude='.env*' -C ./my-app .\ncurl -sS -X POST 'https://ship.embarko.ai/apps' --oauth2-bearer $DEPLOY_TOKEN -H 'X-App-Name: my-app' -H 'X-Agent-Name: {your-name}' -F 'source=@/tmp/app.tar.gz'",
      "note": "The normal deploy. embarko.json travels inside the .tar.gz; in a JSON upload it is one of the files.",
      "response_status": 202,
      "response": {
        "success": true,
        "status": "building",
        "app": {
          "name": "my-app",
          "kind": "service",
          "claimed": true
        },
        "schedules": {
          "declared": 1,
          "appliesWhen": "live"
        },
        "next": "Building: poll links.status every 10 seconds until it says \"live\", \"failed\" or \"crashed\". Once live, its schedule runs on time; POST links.runSchedules (deploy token) to run it once now, and tell the user it works only when each run's outcome is \"ok\".",
        "links": {
          "status": "https://ship.embarko.ai/apps/my-app/status",
          "feedback": "https://ship.embarko.ai/apps/my-app/customer-query",
          "runSchedules": "https://ship.embarko.ai/api/apps/my-app/schedules/run"
        }
      }
    },
    {
      "title": "Run them once now (HTTP) → 202, then poll",
      "command": "curl -sS -X POST 'https://ship.embarko.ai/api/apps/my-app/schedules/run' --oauth2-bearer $DEPLOY_TOKEN\ncurl -sS 'https://ship.embarko.ai{statusUrl}' --oauth2-bearer $DEPLOY_TOKEN",
      "note": "Poll each statusUrl every 5 seconds until terminal is true. Done looks like {\"outcome\": \"ok\", \"httpStatus\": 200, \"responseExcerpt\": \"Digest sent to 12 people\", \"terminal\": true}.",
      "response_status": 202,
      "response": {
        "runs": [
          {
            "scheduleId": "cmgv2k8w0000108l4schd7x2a",
            "path": "/tasks/daily-digest",
            "id": "cmgv2m1qa000308l4run9f3kd",
            "trigger": "manual",
            "outcome": "running",
            "terminal": false,
            "httpStatus": null,
            "error": null,
            "responseExcerpt": null,
            "startedAt": "2026-10-17T10:01:00.000Z",
            "finishedAt": null,
            "durationMs": null,
            "statusUrl": "/api/apps/my-app/schedules/cmgv2k8w0000108l4schd7x2a/runs/cmgv2m1qa000308l4run9f3kd"
          }
        ]
      }
    },
    {
      "title": "The route, with the CRON_SECRET check (Node, Express)",
      "lang": "js",
      "code": "app.get('/tasks/daily-digest', async (req, res) => {\n  if (req.get('authorization') !== 'Bearer ' + process.env.CRON_SECRET) return res.sendStatus(401);\n  const sent = await sendDailyDigests(); // keep progress under DATA_DIR\n  res.send('Digest sent to ' + sent + ' people'); // kept as responseExcerpt\n});",
      "note": "Any other language: compare the Authorization header with \"Bearer \" plus CRON_SECRET and answer 401 if they differ. For work longer than 5 minutes, answer 202 at once and carry on in the background."
    },
    {
      "title": "Alert webhook payload",
      "lang": "json",
      "code": "{\"event\":\"schedule.failed\",\"app\":{\"name\":\"my-app\",\"url\":\"https://my-app.embarko.app\"},\"schedule\":{\"id\":\"cmgv2k8w0000108l4schd7x2a\",\"name\":\"daily digest\",\"cron\":\"0 9 * * 1-5\",\"timezone\":\"Asia/Kolkata\",\"path\":\"/tasks/daily-digest\"},\"run\":{\"id\":\"cmgv3a7pe000508l4run2h6qz\",\"trigger\":\"schedule\",\"outcome\":\"failed\",\"terminal\":true,\"httpStatus\":500,\"error\":\"HTTP 500\",\"responseExcerpt\":\"Error: SMTP login failed\",\"startedAt\":\"2026-10-19T03:30:00.412Z\",\"finishedAt\":\"2026-10-19T03:30:01.224Z\",\"durationMs\":812},\"consecutiveFailures\":3,\"sentAt\":\"2026-10-19T03:30:01.300Z\"}",
      "note": "event is schedule.failed or schedule.recovered."
    }
  ],
  "limits": [
    "Up to 5 schedules per app, at most once every 5 minutes each.",
    "Each call has 5 minutes to finish.",
    "Redirects are not followed and count as failed.",
    "The first 2KB of each reply and the last 100 runs of each schedule are kept.",
    "A time missed during an Embarko outage runs once when it can. Missed times are not replayed.",
    "Needs a kept app: claimed over HTTP, deployed through the connector, or uploaded in the dashboard. A temporary app deploys, but its schedules are not applied; the reply says so.",
    "Static sites cannot have schedules. A static site deploys, with the warning schedules_on_static_site.",
    "Schedules apply only when the deploy succeeds.",
    "embarko.json is the source of truth: a schedule paused or changed through the API is set back by the next deploy whose embarko.json lists it.",
    "A deploy with no schedules in embarko.json whose code lists a timer library (node-cron, node-schedule, APScheduler, rufus-scheduler...) goes ahead with the warning in_process_timer, and quotes any timing it found in the code. Move those jobs here.",
    "If the app has schedules and the upload declares none, the reply warns schedules_unchanged: they were kept."
  ],
  "errors": [
    {
      "code": "invalid_embarko_json",
      "status": 400,
      "retry": "No",
      "do": "The file is not valid JSON (the message gives line and column), not one object, \"schedules\" is not a list, or it is over 64 KB. Fix it and deploy again."
    },
    {
      "code": "secrets_in_embarko_json",
      "status": 400,
      "retry": "No",
      "do": "The file looks like it holds a secret. Remove it; use an env var. The route checks CRON_SECRET, which Embarko creates."
    },
    {
      "code": "invalid_schedules",
      "status": 400,
      "retry": "No",
      "do": "An entry in \"schedules\" has the wrong shape: cron or path missing, or a field of the wrong type. The message names it, e.g. (0.path: Required). Fix it and deploy again."
    },
    {
      "code": "invalid_cron",
      "status": 400,
      "retry": "No",
      "do": "Use five fields (minute hour day-of-month month day-of-week), or @daily and the like."
    },
    {
      "code": "schedule_too_frequent",
      "status": 400,
      "retry": "No",
      "do": "Two runs would be less than 5 minutes apart. Space them out."
    },
    {
      "code": "invalid_timezone",
      "status": 400,
      "retry": "No",
      "do": "Use an IANA name such as UTC or Asia/Kolkata."
    },
    {
      "code": "invalid_path",
      "status": 400,
      "retry": "No",
      "do": "A path on the app starting with /, with no host, spaces or #."
    },
    {
      "code": "duplicate_schedule_path",
      "status": 400,
      "retry": "No",
      "do": "Two schedules call the same path. Give each its own route."
    },
    {
      "code": "schedule_limit_reached",
      "status": 400,
      "retry": "No",
      "do": "More than 5 schedules. Combine some jobs into one route."
    },
    {
      "code": "no_schedules",
      "status": 404,
      "retry": "Yes, once",
      "do": "On run-now right after going live: wait 5 seconds and try again. Still 404: the deploy's embarko.json listed no schedules."
    },
    {
      "code": "run_in_progress",
      "status": 409,
      "retry": "Later",
      "do": "That schedule's last run has not finished. Poll it, then try again."
    },
    {
      "code": "invalid_alert_webhook",
      "status": 400,
      "retry": "No",
      "do": "alertWebhookUrl must be a public https:// address."
    },
    {
      "code": "not_supported_for_static",
      "status": 409,
      "retry": "No",
      "do": "A static site has no server to call. Deploy it as a server app under a new name."
    },
    {
      "code": "permission_denied",
      "status": 403,
      "retry": "No",
      "do": "The person who made this token is not allowed to do this. The reply names the permission and their access to the app (or their role). Nothing changed. Tell the person (say_to_user.no_permission); do not try another way round it."
    }
  ],
  "say_to_user": {
    "done": "Done: every weekday at 9:00 your app sends the digest. I ran it once just now and it worked. If it ever stops working, Embarko emails you."
  },
  "prerequisites": {
    "read_first": "https://embarko.ai/docs/prerequisites",
    "user": "The person is usually not a developer. They want to know if the app is live, not how.",
    "talk": "Reply in 1-3 short plain sentences: what happened, and what the person needs to do only if something is needed. Do not show commands, API names, tokens, headers or logs, or describe the steps you took, unless the person asks for technical details. If the person is clearly a developer (uses technical terms, asks what you ran), talk to them that way for the rest of the conversation. Never show a token. Never invent a link, name or code: use only what Embarko's replies, this guide or the person give you.",
    "route": "Connector first if it is in your tools, then the HTTP API. If you can reach neither, ask the person to add the connector. The upload page is the last resort.",
    "domains": "ship.embarko.ai (API), embarko.ai (website), {app-name}.embarko.app (apps): all Embarko.",
    "requires": [
      {
        "topic": "claim",
        "why": "Over HTTP the app must be claimed first; connector apps already are",
        "url": "https://embarko.ai/docs/claim",
        "only": "over HTTP only"
      }
    ]
  },
  "next": "Write the route with the CRON_SECRET check, list it in embarko.json, deploy, and check the test run.",
  "related": [
    {
      "topic": "embarko-json",
      "why": "The file the schedules are listed in",
      "url": "https://embarko.ai/docs/embarko-json"
    },
    {
      "topic": "deploy",
      "why": "The deploy that reads it",
      "url": "https://embarko.ai/docs/deploy"
    },
    {
      "topic": "logs",
      "why": "When a run fails",
      "url": "https://embarko.ai/docs/logs"
    },
    {
      "topic": "static-sites",
      "why": "Why a static site cannot have one",
      "url": "https://embarko.ai/docs/static-sites"
    }
  ],
  "links": {
    "deploy": "https://ship.embarko.ai/apps",
    "runSchedules": "https://ship.embarko.ai/api/apps/{app-name}/schedules/run",
    "schedules": "https://ship.embarko.ai/api/apps/{app-name}/schedules",
    "tokensPage": "https://embarko.ai/app/settings/developer"
  },
  "url": "https://embarko.ai/docs/schedules",
  "contents": "https://embarko.ai/docs",
  "version": "2026-11-24"
}