- EmDash
- Reference
- API routes
schedules
Create scheduled imports of a URL source with a saved template, run one now, and read when each runs next and how its last runs went.
Every route here is a POST to /_emdash/api/plugins/fluximporter/<route> with a JSON body, and needs an Administrator. See Before you call the API for authentication, the response envelope and the errors any route can return. Every schedule route is strict and takes a body of at most 16 KiB. For how schedules behave, see Schedules.
| Route | What it does | MCP tool |
|---|---|---|
schedules/create |
Creates a schedule | none |
schedules/update |
Changes, pauses or resumes a schedule | none |
schedules/delete |
Deletes a schedule | none |
schedules/run |
Runs a schedule now | none |
schedules/list |
Lists schedules | none |
schedules/overview |
Lists schedules as an agent may see them | fluximporter__list_schedules |
schedules/fence |
Says whether the site takes imports now | none |
A schedule imports one URL source with one revision of a saved template. Its times are in UTC. A site holds at most 20 schedules. Before each run, the scheduler checks that the Administrator who last enabled the schedule still exists and can import. Every run keeps a journal, so you can roll it back.
The schedule
Section titled “The schedule”schedules/create, schedules/update and schedules/run answer with { schedule }; schedules/list lists the same rows. A schedule has:
| Field | What it holds |
|---|---|
id, name |
Its ID and its unique name. |
templateId, templateRevision |
The saved template and the revision it runs. |
sourceId |
The URL source it imports. |
cron |
Its timing. |
publish, batchSize, budgetMs, missing |
The import options. |
enabled |
false while it’s paused. |
pause |
Why it was paused, when the scheduler paused it: { reason, at, jobId? }. |
nextRunAt |
Its next run, or null while it’s disabled. |
due, current |
A run waiting to launch, and the launch in progress. |
lastLaunch |
{ at, outcome, jobId?, errorCode? }, with outcome started, unchanged, busy or failed. |
runs |
Its last 20 runs, newest first: { jobId, at, outcome, counters, rolledBack? }. |
launchFailures |
Failed launches in a row. |
revision |
Starts at 1 and goes up with each change. |
sourcePin, armedBy, createdAt, updatedAt, createdBy, updatedBy |
Bookkeeping. |
pause.reason is one of template_gone, template_changed, source_gone, source_changed, creator_gone, invalid_template, credential_missing, url_blocked, too_large, fetch_failed, job_failed, cancelled, rolled_back, missing_refused or empty_feed.
schedules/create
Section titled “schedules/create”POST /_emdash/api/plugins/fluximporter/schedules/create
Checks the template, the source and the timing, then saves the schedule and, when it’s enabled, books its runs.
| Field | Type | Required | Notes |
|---|---|---|---|
name |
string | yes | 1 to 100 characters, unique among schedules, with no leading or trailing whitespace and no control or format characters. |
templateId |
string | yes | A saved template’s ID. |
templateRevision |
integer ≥ 1 | yes | The template’s current revision. |
sourceId |
string | yes | A URL source’s ID. |
cron |
string | yes | Five cron fields (minute, hour, day of month, month, day of week), or @hourly, @daily, @weekly, @monthly or @yearly. UTC. |
publish |
boolean | no | Default true. |
batchSize |
integer | no | 1 to 500, default 50. |
budgetMs |
integer | no | 500 to 20,000, default 4,000. |
enabled |
boolean | no | Default true. |
missing |
false, "template" or object |
for some | Required when the template has rules.missing, refused when it hasn’t. false skips the missing-entries phase, "template" uses the template’s threshold, and { "maxPercent": 0–100 } a lower one. See Missing entries. |
curl -X POST "https://example.com/_emdash/api/plugins/fluximporter/schedules/create" \ -H "Authorization: Bearer $EMDASH_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "name": "Nightly supplier import", "templateId": "01JDQ6Y2B9C4D7E1F3G5H8J0KM", "templateRevision": 3, "sourceId": "01JDQ9A4V7W2X5Y8Z1B3C6D9EF", "cron": "0 2 * * *" }'const res = await fetch("/_emdash/api/plugins/fluximporter/schedules/create", { method: "POST", headers: { "Content-Type": "application/json", "X-EmDash-Request": "1" }, body: JSON.stringify({ name: "Nightly supplier import", templateId, templateRevision: 3, sourceId, cron: "@daily", }),});const { data: { schedule } } = await res.json();console.log(schedule.nextRunAt);| Code | Status | Meaning |
|---|---|---|
NAME_TAKEN |
409 | Another schedule has this name. |
SCHEDULE_LIMIT |
409 | The site already has 20 schedules. |
TEMPLATE_NOT_FOUND |
404 | No saved template has this ID. |
TEMPLATE_CHANGED |
409 | The template isn’t at templateRevision. details.revision has the current one. |
TEMPLATE_PROBLEMS |
409 | The template doesn’t fit the site. details.problems says why. |
SOURCE_NOT_FOUND |
404 | No URL source has this ID. |
INVALID_CRON |
400 | The timing isn’t valid, or never comes. |
MISSING_REQUIRED |
400 | The template has rules.missing, and missing isn’t set. |
INVALID_OPTIONS |
400 | missing is set for a template without rules.missing, or its maxPercent is over the template’s. |
CONFLICT |
409 | The schedule kept changing. Try again. |
schedules/update
Section titled “schedules/update”POST /_emdash/api/plugins/fluximporter/schedules/update
Changes a schedule at the revision you read. Send id, revision and at least one other field from schedules/create. enabled: false pauses the schedule; enabled: true resumes it, clears its pause and failures, and makes you the Administrator the scheduler checks for.
| Field | Type | Required | Notes |
|---|---|---|---|
id |
string | yes | The schedule’s ID. |
revision |
integer ≥ 1 | yes | The revision you read. |
name, sourceId, cron, publish, batchSize, budgetMs, enabled |
no | As for schedules/create. |
|
templateId |
string | no | Needs templateRevision. |
templateRevision |
integer ≥ 1 | no | On its own, moves the schedule to another revision of its template. |
missing |
as for create, or null |
no | null removes it, for a template without rules.missing. |
Response: { schedule }.
Errors: those of schedules/create, and NOT_FOUND (404); SCHEDULE_CHANGED (409) when the schedule isn’t at revision, with the current one in details.revision; SCHEDULE_BUSY (409) when you change its template, source or missing while one of its imports is unfinished.
schedules/delete
Section titled “schedules/delete”POST /_emdash/api/plugins/fluximporter/schedules/delete
| Field | Type | Required | Notes |
|---|---|---|---|
id |
string | yes | The schedule’s ID. |
revision |
integer ≥ 1 | yes | The revision you read. |
Response: { "deleted": true }. The jobs it ran stay.
Errors: NOT_FOUND (404); SCHEDULE_CHANGED (409); SCHEDULE_BUSY (409) while one of its imports is unfinished; CONFLICT (409).
schedules/run
Section titled “schedules/run”POST /_emdash/api/plugins/fluximporter/schedules/run
Queues a run now, as Run now does. The scheduler starts it at its next tick; the route itself fetches nothing.
| Field | Type | Required | Notes |
|---|---|---|---|
id |
string | yes | The schedule’s ID. |
force |
boolean | no | true imports even when the feed and the template haven’t changed since the last run. |
Response: { "queued": true, "schedule": … }.
Errors: NOT_FOUND (404); SCHEDULE_DISABLED (409) when it’s paused: resume it first; SCHEDULE_BUSY (409) when an import of it, or of its source, is unfinished; CONFLICT (409).
schedules/list
Section titled “schedules/list”POST /_emdash/api/plugins/fluximporter/schedules/list
Takes an optional cursor and answers with { items, hasMore, cursor? }, 20 schedules a page, so normally all of them on one page.
schedules/overview
Section titled “schedules/overview”POST /_emdash/api/plugins/fluximporter/schedules/overview · MCP tool fluximporter__list_schedules
Lists schedules as an agent may see them. Takes an optional cursor. Each item has id, name, templateId, templateRevision, sourceId, cron, enabled, publish, batchSize, budgetMs, missing, pause (its reason as a code), due (true when a run is queued), runningJobId, lastLaunch, its newest 5 runs and runCount, launchFailures, nextRunAt, revision, createdAt and updatedAt. Users and the source pin are left out.
schedules/fence
Section titled “schedules/fence”POST /_emdash/api/plugins/fluximporter/schedules/fence
Takes {} and answers with { "fence": … }: clear when the site takes imports, or what holds them back: import (an EmDash site import is running), export, media, or error when it couldn’t be checked. Scheduled imports wait while the site is fenced; the Schedules tab shows a banner then.