Docs
BlogHomeStart building

Cron Jobs (totalum-sdk/cron)


import … from 'totalum-sdk/cron' — or the same namespace on totalum from 'totalum-sdk'. Install, configuration and errors: Totalum SDK.

Run a route of your own app on a schedule: every night at 8:00, every 15 minutes, the first day of the month. Totalum calls the URL you give (on the project's own published host) at each tick and records every run. Use it for reports, reminders, clean-ups and long tasks done in steps. Jobs run against the published site, so publish the project first. Each run costs a small fraction of a credit; the number of jobs and the shortest interval depend on the plan.

ts
await totalum.cron.create({
  name: 'daily-report',
  schedule: '0 8 * * *',
  timezone: 'Europe/Madrid',
  request: { method: 'POST', url: 'https://acme.totalum.app/api/cron/report' },
});
Method or typeWhat it does
totalumCronCreates the cron namespace (the same object as totalum.cron, scope cron): HTTP jobs against the project's own host, fired by Totalum's Scheduler; limits per plan (429 CRON_LIMIT_REACHED {limit, plan}, 400 INVALID_SCHEDULE {minIntervalSeconds}).
cron.createCreates a job that calls a route of your own app on a schedule — a cron expression ('0 8 * * *') or { everyMinutes: 15 }.
cron.listEvery job of the project, both environments.
cron.getOne job, or null when the project has no job with this id.
cron.updateChanges any field of a job (schedule, request, enabled, timezone, …); fields you leave out keep their value.
cron.deleteDeletes a job and its run history.
cron.pauseStops a job from firing until resume (the same as update(id, { enabled: false })).
cron.resumeLets a paused job fire again — also one paused after failing runs (paused_failures) once its route is fixed.
cron.runsA job's executions of the last 30 days, newest first: when each ran, the HTTP status your route answered and how long it took.
cron.triggerFires a job now, outside its schedule — a "Run now" button, or to test a new job.
CronJobA scheduled job.
CronJobInputA job for cron.create().
CronJobPatchThe fields cron.update() changes; each is optional and means the same as in cron.create().
CronRunOne execution of a job.
CronRunsPageOne page of cron.runs().

#totalumCron

ts
totalumCron(options?: TotalumClientOptions): TotalumCron

Creates the cron namespace (the same object as totalum.cron, scope cron): HTTP jobs against the project's own host, fired by Totalum's Scheduler; limits per plan (429 CRON_LIMIT_REACHED {limit, plan}, 400 INVALID_SCHEDULE {minIntervalSeconds}). Each run costs a small fraction of a credit. timezone (IANA) reads the schedule on that zone's clock, daylight saving included; pauseAfterFailures (1–100, default 3; null = never) sets how many failed runs in a row pause it.

Parameters

NameTypeRequiredDescription
optionsTotalumClientOptionsnoThe project key, API URL and environment; each falls back to its environment variable.
options.keystringnoProject key tlm_pk_…; default TOTALUM_PROJECT_KEY. Server-side only.
options.apiUrlstringnoThe Totalum API's URL: default TOTALUM_SDK_API_URL, else https://sdk-api.totalum.app.
options.env'dev' | 'live'noSent as x-totalum-env on every call (the database it targets, and dev vs live usage); default TOTALUM_ENV, else live.

Returns TotalumCron — The cron namespace: the methods below.

Example

ts
import { totalumCron } from 'totalum-sdk/cron';

const cron = totalumCron();
const jobs = await cron.list();

The namespace's type is exported as TotalumCron (import type { TotalumCron } from 'totalum-sdk/cron').

#cron.create

ts
cron.create(input: CronJobInput): Promise<CronJob>

Creates a job that calls a route of your own app on a schedule — a cron expression ('0 8 * * *') or { everyMinutes: 15 }. The URL must be the project's own https:// host: the published site for a live job, the preview for a dev one (without env, the URL decides). Each call is signed by Totalum (the template's cron routes check it) and recorded in runs().

Parameters

NameTypeRequiredDescription
inputCronJobInputyesThe name, schedule, request and options.
input.namestringyesA name of yours (daily-report). Allowed: at least 1 character, at most 64 characters.
input.schedulestring | { everyMinutes }yesWhen it runs: a 5-field cron expression ("0 8 * * *" = 08:00 every day, "*/15 * * * *" = every 15 minutes) or { everyMinutes: n }. The plan sets the shortest interval.
input.schedule.everyMinutesnumberyesRun every this many minutes. Allowed: > 0.
input.request{ method, url, headers?, body?, timeoutMs? }yesThe HTTP call each run makes.
input.request.method'GET' | 'POST'yesGET or POST.
input.request.urlstringyesA URL on the project's own https:// host (the published site for live, the preview for dev). Allowed: a URL.
input.request.headersRecord<string, string>noExtra headers to send.
input.request.bodystringnoThe body of a POST. Allowed: at most 65536 characters.
input.request.timeoutMsnumbernoHow long a run may take. Default 30 s, at most 30 s. Allowed: > 0, ≤ 30000.
input.enabledbooleannofalse creates it paused. Default true.
input.descriptionstringnoA note of yours.
input.env'dev' | 'live'nolive (the published site) or dev (the preview). Default: the environment of request.url.
input.timezonestringnoAn IANA time zone (Europe/Madrid): the schedule reads that zone's clock, daylight saving included. Default UTC. Allowed: at least 1 character, at most 64 characters.
input.pauseAfterFailuresnumber | nullnoPause the job after this many failed runs in a row. Default 3; null or 0 never pauses. Allowed: ≥ 0, ≤ 100.

Returns Promise<CronJob> — The new job.

FieldTypeAlways presentDescription
idstringyesThe job id (cj_…).
namestringyesA name of yours (daily-report). Allowed: at least 1 character, at most 64 characters.
schedulestring | { everyMinutes }yesWhen it runs: a 5-field cron expression ("0 8 * * *" = 08:00 every day, "*/15 * * * *" = every 15 minutes) or { everyMinutes: n }. The plan sets the shortest interval.
schedule.everyMinutesnumberyesRun every this many minutes. Allowed: > 0.
request{ method, url, headers?, body?, timeoutMs? }yesThe HTTP call each run makes.
request.method'GET' | 'POST'yesGET or POST.
request.urlstringyesA URL on the project's own https:// host (the published site for live, the preview for dev). Allowed: a URL.
request.headersRecord<string, string>noExtra headers to send.
request.bodystringnoThe body of a POST. Allowed: at most 65536 characters.
request.timeoutMsnumbernoHow long a run may take. Default 30 s, at most 30 s. Allowed: > 0, ≤ 30000.
enabledbooleanyesfalse creates it paused. Default true.
status'active' | 'paused' | 'paused_failures'yesactive, paused (by you) or paused_failures (after too many failed runs; fix the route and resume).
nextRunAtstring | nullyesWhen it runs next, or null while paused.
createdAtstringyesWhen it was created.
env'dev' | 'live'yeslive (the published site) or dev (the preview). Default: the environment of request.url.
pauseAfterFailuresnumber | nullyesFailed runs in a row before it pauses; null = never. Allowed: ≥ 0, ≤ 100.
lastRun{ at, status, latencyMs }noThe latest run.
lastRun.atstringyesWhen it ran.
lastRun.statusnumber | 'timeout' | 'error' | 'skipped'yesThe HTTP status your route answered, or timeout, error (no answer) or skipped (cron was switched off).
lastRun.latencyMsnumberyesHow long it took.
descriptionstringnoA note of yours.
timezonestringnoAn IANA time zone (Europe/Madrid): the schedule reads that zone's clock, daylight saving included. Default UTC. Allowed: at least 1 character, at most 64 characters.

Errors — besides the errors every call can throw:

CodeHTTPWhen
INVALID_SCHEDULE400Not a valid schedule, or it fires more often than the plan allows; details.minIntervalSeconds.
CRON_URL_NOT_ALLOWED403The URL is not the project's own https:// host for that environment; details.allowedHost.
CRON_REQUIRES_PUBLISHED_PROJECT403A live job, but the project is not published yet.
CRON_LIMIT_REACHED429The plan's number of jobs per environment is reached; details.limit.
ENGINE_UNAVAILABLE502The scheduler is unavailable; retry shortly.

Example

ts
const job = await totalum.cron.create({
  name: 'daily-report',
  schedule: '0 8 * * *', // 08:00 in Madrid all year
  timezone: 'Europe/Madrid',
  request: { method: 'POST', url: 'https://acme.totalum.app/api/cron/report' },
});

Result:

json
{
  "id": "cj_01M4P1F0R7T2Y9U4I6O3P8A5SD",
  "name": "daily-report",
  "schedule": "0 8 * * *",
  "request": { "method": "POST", "url": "https://acme.totalum.app/api/cron/report" },
  "enabled": true,
  "status": "active",
  "nextRunAt": "2026-10-12T06:00:00.000Z",
  "createdAt": "2026-10-11T18:30:00.000Z",
  "env": "live",
  "timezone": "Europe/Madrid",
  "pauseAfterFailures": 3
}

#cron.list

ts
cron.list(): Promise<CronJob[]>

Every job of the project, both environments. Free.

Returns Promise<CronJob[]> — The jobs.

Each item:

FieldTypeAlways presentDescription
idstringyesThe job id (cj_…).
namestringyesA name of yours (daily-report). Allowed: at least 1 character, at most 64 characters.
schedulestring | { everyMinutes }yesWhen it runs: a 5-field cron expression ("0 8 * * *" = 08:00 every day, "*/15 * * * *" = every 15 minutes) or { everyMinutes: n }. The plan sets the shortest interval.
schedule.everyMinutesnumberyesRun every this many minutes. Allowed: > 0.
request{ method, url, headers?, body?, timeoutMs? }yesThe HTTP call each run makes.
request.method'GET' | 'POST'yesGET or POST.
request.urlstringyesA URL on the project's own https:// host (the published site for live, the preview for dev). Allowed: a URL.
request.headersRecord<string, string>noExtra headers to send.
request.bodystringnoThe body of a POST. Allowed: at most 65536 characters.
request.timeoutMsnumbernoHow long a run may take. Default 30 s, at most 30 s. Allowed: > 0, ≤ 30000.
enabledbooleanyesfalse creates it paused. Default true.
status'active' | 'paused' | 'paused_failures'yesactive, paused (by you) or paused_failures (after too many failed runs; fix the route and resume).
nextRunAtstring | nullyesWhen it runs next, or null while paused.
createdAtstringyesWhen it was created.
env'dev' | 'live'yeslive (the published site) or dev (the preview). Default: the environment of request.url.
pauseAfterFailuresnumber | nullyesFailed runs in a row before it pauses; null = never. Allowed: ≥ 0, ≤ 100.
lastRun{ at, status, latencyMs }noThe latest run.
lastRun.atstringyesWhen it ran.
lastRun.statusnumber | 'timeout' | 'error' | 'skipped'yesThe HTTP status your route answered, or timeout, error (no answer) or skipped (cron was switched off).
lastRun.latencyMsnumberyesHow long it took.
descriptionstringnoA note of yours.
timezonestringnoAn IANA time zone (Europe/Madrid): the schedule reads that zone's clock, daylight saving included. Default UTC. Allowed: at least 1 character, at most 64 characters.

Errors — besides the errors every call can throw:

CodeHTTPWhen
ENGINE_UNAVAILABLE502The scheduler is unavailable; retry shortly.

Example

ts
const jobs = await totalum.cron.list();

Result:

json
[
  {
    "id": "cj_01M4P1F0R7T2Y9U4I6O3P8A5SD",
    "name": "daily-report",
    "schedule": "0 8 * * *",
    "request": { "method": "POST", "url": "https://acme.totalum.app/api/cron/report" },
    "enabled": true,
    "status": "active",
    "nextRunAt": "2026-10-12T06:00:00.000Z",
    "lastRun": { "at": "2026-10-11T06:00:00.412Z", "status": 200, "latencyMs": 812 },
    "createdAt": "2026-10-01T18:30:00.000Z",
    "env": "live",
    "timezone": "Europe/Madrid",
    "pauseAfterFailures": 3
  }
]

#cron.get

ts
cron.get(id: string): Promise<CronJob | null>

One job, or null when the project has no job with this id. Free.

Parameters

NameTypeRequiredDescription
idstringyesThe job's id (cj_…).

Returns Promise<CronJob \| null> — The job, or null.

Errors — besides the errors every call can throw:

CodeHTTPWhen
ENGINE_UNAVAILABLE502The scheduler is unavailable; retry shortly.

Example

ts
const job = await totalum.cron.get('cj_01M4P1F0R7T2Y9U4I6O3P8A5SD');

Result:

ts
{ "id": "cj_01M4P1F0R7T2Y9U4I6O3P8A5SD", "name": "daily-report", "status": "active", "nextRunAt": "2026-10-12T06:00:00.000Z", … }

#cron.update

ts
cron.update(id: string, patch: CronJobPatch): Promise<CronJob>

Changes any field of a job (schedule, request, enabled, timezone, …); fields you leave out keep their value. The same checks as create apply.

Parameters

NameTypeRequiredDescription
idstringyesThe job's id.
patchCronJobPatchyesThe fields to change.
patch.namestringnoA name of yours (daily-report). Allowed: at least 1 character, at most 64 characters.
patch.schedulestring | { everyMinutes }noWhen it runs: a 5-field cron expression ("0 8 * * *" = 08:00 every day, "*/15 * * * *" = every 15 minutes) or { everyMinutes: n }. The plan sets the shortest interval.
patch.schedule.everyMinutesnumberyesRun every this many minutes. Allowed: > 0.
patch.request{ method, url, headers?, body?, timeoutMs? }noThe HTTP call each run makes.
patch.request.method'GET' | 'POST'yesGET or POST.
patch.request.urlstringyesA URL on the project's own https:// host (the published site for live, the preview for dev). Allowed: a URL.
patch.request.headersRecord<string, string>noExtra headers to send.
patch.request.bodystringnoThe body of a POST. Allowed: at most 65536 characters.
patch.request.timeoutMsnumbernoHow long a run may take. Default 30 s, at most 30 s. Allowed: > 0, ≤ 30000.
patch.enabledbooleannofalse creates it paused. Default true.
patch.descriptionstringnoA note of yours.
patch.env'dev' | 'live'nolive (the published site) or dev (the preview). Default: the environment of request.url.
patch.timezonestringnoAn IANA time zone (Europe/Madrid): the schedule reads that zone's clock, daylight saving included. Default UTC. Allowed: at least 1 character, at most 64 characters.
patch.pauseAfterFailuresnumber | nullnoPause the job after this many failed runs in a row. Default 3; null or 0 never pauses. Allowed: ≥ 0, ≤ 100.

Returns Promise<CronJob> — The updated job.

FieldTypeAlways presentDescription
idstringyesThe job id (cj_…).
namestringyesA name of yours (daily-report). Allowed: at least 1 character, at most 64 characters.
schedulestring | { everyMinutes }yesWhen it runs: a 5-field cron expression ("0 8 * * *" = 08:00 every day, "*/15 * * * *" = every 15 minutes) or { everyMinutes: n }. The plan sets the shortest interval.
schedule.everyMinutesnumberyesRun every this many minutes. Allowed: > 0.
request{ method, url, headers?, body?, timeoutMs? }yesThe HTTP call each run makes.
request.method'GET' | 'POST'yesGET or POST.
request.urlstringyesA URL on the project's own https:// host (the published site for live, the preview for dev). Allowed: a URL.
request.headersRecord<string, string>noExtra headers to send.
request.bodystringnoThe body of a POST. Allowed: at most 65536 characters.
request.timeoutMsnumbernoHow long a run may take. Default 30 s, at most 30 s. Allowed: > 0, ≤ 30000.
enabledbooleanyesfalse creates it paused. Default true.
status'active' | 'paused' | 'paused_failures'yesactive, paused (by you) or paused_failures (after too many failed runs; fix the route and resume).
nextRunAtstring | nullyesWhen it runs next, or null while paused.
createdAtstringyesWhen it was created.
env'dev' | 'live'yeslive (the published site) or dev (the preview). Default: the environment of request.url.
pauseAfterFailuresnumber | nullyesFailed runs in a row before it pauses; null = never. Allowed: ≥ 0, ≤ 100.
lastRun{ at, status, latencyMs }noThe latest run.
lastRun.atstringyesWhen it ran.
lastRun.statusnumber | 'timeout' | 'error' | 'skipped'yesThe HTTP status your route answered, or timeout, error (no answer) or skipped (cron was switched off).
lastRun.latencyMsnumberyesHow long it took.
descriptionstringnoA note of yours.
timezonestringnoAn IANA time zone (Europe/Madrid): the schedule reads that zone's clock, daylight saving included. Default UTC. Allowed: at least 1 character, at most 64 characters.

Errors — besides the errors every call can throw:

CodeHTTPWhen
CRON_JOB_NOT_FOUND404No job with this id.
INVALID_SCHEDULE400The new schedule is invalid or too frequent for the plan.
CRON_URL_NOT_ALLOWED403The new URL is not the project's own host.

Example

ts
const job = await totalum.cron.update('cj_01M4P1F0R7T2Y9U4I6O3P8A5SD', { schedule: { everyMinutes: 60 } });

Result:

ts
{ "id": "cj_01M4P1F0R7T2Y9U4I6O3P8A5SD", "name": "daily-report", "schedule": { "everyMinutes": 60 }, "status": "active", "nextRunAt": "2026-10-11T19:30:00.000Z", … }

#cron.delete

ts
cron.delete(id: string): Promise<void>

Deletes a job and its run history.

Parameters

NameTypeRequiredDescription
idstringyesThe job's id.

Returns Promise<void> — Nothing once deleted.

Errors — besides the errors every call can throw:

CodeHTTPWhen
CRON_JOB_NOT_FOUND404No job with this id.

Example

ts
await totalum.cron.delete('cj_01M4P1F0R7T2Y9U4I6O3P8A5SD');

#cron.pause

ts
cron.pause(id: string): Promise<CronJob>

Stops a job from firing until resume (the same as update(id, { enabled: false })).

Parameters

NameTypeRequiredDescription
idstringyesThe job's id.

Returns Promise<CronJob> — The job, now paused.

FieldTypeAlways presentDescription
idstringyesThe job id (cj_…).
namestringyesA name of yours (daily-report). Allowed: at least 1 character, at most 64 characters.
schedulestring | { everyMinutes }yesWhen it runs: a 5-field cron expression ("0 8 * * *" = 08:00 every day, "*/15 * * * *" = every 15 minutes) or { everyMinutes: n }. The plan sets the shortest interval.
schedule.everyMinutesnumberyesRun every this many minutes. Allowed: > 0.
request{ method, url, headers?, body?, timeoutMs? }yesThe HTTP call each run makes.
request.method'GET' | 'POST'yesGET or POST.
request.urlstringyesA URL on the project's own https:// host (the published site for live, the preview for dev). Allowed: a URL.
request.headersRecord<string, string>noExtra headers to send.
request.bodystringnoThe body of a POST. Allowed: at most 65536 characters.
request.timeoutMsnumbernoHow long a run may take. Default 30 s, at most 30 s. Allowed: > 0, ≤ 30000.
enabledbooleanyesfalse creates it paused. Default true.
status'active' | 'paused' | 'paused_failures'yesactive, paused (by you) or paused_failures (after too many failed runs; fix the route and resume).
nextRunAtstring | nullyesWhen it runs next, or null while paused.
createdAtstringyesWhen it was created.
env'dev' | 'live'yeslive (the published site) or dev (the preview). Default: the environment of request.url.
pauseAfterFailuresnumber | nullyesFailed runs in a row before it pauses; null = never. Allowed: ≥ 0, ≤ 100.
lastRun{ at, status, latencyMs }noThe latest run.
lastRun.atstringyesWhen it ran.
lastRun.statusnumber | 'timeout' | 'error' | 'skipped'yesThe HTTP status your route answered, or timeout, error (no answer) or skipped (cron was switched off).
lastRun.latencyMsnumberyesHow long it took.
descriptionstringnoA note of yours.
timezonestringnoAn IANA time zone (Europe/Madrid): the schedule reads that zone's clock, daylight saving included. Default UTC. Allowed: at least 1 character, at most 64 characters.

Errors — besides the errors every call can throw:

CodeHTTPWhen
CRON_JOB_NOT_FOUND404No job with this id.

Example

ts
const job = await totalum.cron.pause('cj_01M4P1F0R7T2Y9U4I6O3P8A5SD');

Result:

ts
{ "id": "cj_01M4P1F0R7T2Y9U4I6O3P8A5SD", "enabled": false, "status": "paused", "nextRunAt": null, … }

#cron.resume

ts
cron.resume(id: string): Promise<CronJob>

Lets a paused job fire again — also one paused after failing runs (paused_failures) once its route is fixed.

Parameters

NameTypeRequiredDescription
idstringyesThe job's id.

Returns Promise<CronJob> — The job, now active.

FieldTypeAlways presentDescription
idstringyesThe job id (cj_…).
namestringyesA name of yours (daily-report). Allowed: at least 1 character, at most 64 characters.
schedulestring | { everyMinutes }yesWhen it runs: a 5-field cron expression ("0 8 * * *" = 08:00 every day, "*/15 * * * *" = every 15 minutes) or { everyMinutes: n }. The plan sets the shortest interval.
schedule.everyMinutesnumberyesRun every this many minutes. Allowed: > 0.
request{ method, url, headers?, body?, timeoutMs? }yesThe HTTP call each run makes.
request.method'GET' | 'POST'yesGET or POST.
request.urlstringyesA URL on the project's own https:// host (the published site for live, the preview for dev). Allowed: a URL.
request.headersRecord<string, string>noExtra headers to send.
request.bodystringnoThe body of a POST. Allowed: at most 65536 characters.
request.timeoutMsnumbernoHow long a run may take. Default 30 s, at most 30 s. Allowed: > 0, ≤ 30000.
enabledbooleanyesfalse creates it paused. Default true.
status'active' | 'paused' | 'paused_failures'yesactive, paused (by you) or paused_failures (after too many failed runs; fix the route and resume).
nextRunAtstring | nullyesWhen it runs next, or null while paused.
createdAtstringyesWhen it was created.
env'dev' | 'live'yeslive (the published site) or dev (the preview). Default: the environment of request.url.
pauseAfterFailuresnumber | nullyesFailed runs in a row before it pauses; null = never. Allowed: ≥ 0, ≤ 100.
lastRun{ at, status, latencyMs }noThe latest run.
lastRun.atstringyesWhen it ran.
lastRun.statusnumber | 'timeout' | 'error' | 'skipped'yesThe HTTP status your route answered, or timeout, error (no answer) or skipped (cron was switched off).
lastRun.latencyMsnumberyesHow long it took.
descriptionstringnoA note of yours.
timezonestringnoAn IANA time zone (Europe/Madrid): the schedule reads that zone's clock, daylight saving included. Default UTC. Allowed: at least 1 character, at most 64 characters.

Errors — besides the errors every call can throw:

CodeHTTPWhen
CRON_JOB_NOT_FOUND404No job with this id.

Example

ts
const job = await totalum.cron.resume('cj_01M4P1F0R7T2Y9U4I6O3P8A5SD');

Result:

ts
{ "id": "cj_01M4P1F0R7T2Y9U4I6O3P8A5SD", "enabled": true, "status": "active", "nextRunAt": "2026-10-12T06:00:00.000Z", … }

#cron.runs

ts
cron.runs(id: string, opts?: { limit?, cursor? }): Promise<CronRunsPage>

A job's executions of the last 30 days, newest first: when each ran, the HTTP status your route answered and how long it took. Free.

Parameters

NameTypeRequiredDescription
idstringyesThe job's id.
opts{ limit?, cursor? }noPaging.
opts.limitnumbernoRuns per page.
opts.cursorstringnoThe previous page's nextCursor.

Returns Promise<CronRunsPage> — One page of runs.

FieldTypeAlways presentDescription
itemsCronRun[]yesThe runs, newest first.
nextCursorstring | nullyesPass it as cursor for the next page; null on the last.

Errors — besides the errors every call can throw:

CodeHTTPWhen
CRON_JOB_NOT_FOUND404No job with this id.

Example

ts
const page = await totalum.cron.runs('cj_01M4P1F0R7T2Y9U4I6O3P8A5SD', { limit: 2 });

Result:

json
{
  "items": [
    { "id": "cr_01M4P1G2H3J4K5L6M7N8P9Q0RS", "scheduledFor": "2026-10-11T06:00:00.000Z", "startedAt": "2026-10-11T06:00:00.412Z", "status": 200, "latencyMs": 812, "responseSnippet": "{\"ok\":true}" },
    { "id": "cr_01M4MZ8B7V6C5X4Z3A2S1D0F9G", "scheduledFor": "2026-10-10T06:00:00.000Z", "startedAt": "2026-10-10T06:00:00.388Z", "status": "timeout", "latencyMs": 30000, "error": "The request timed out" }
  ],
  "nextCursor": "MjAyNi0xMC0xMFQwNjowMDowMC4wMDBa"
}

#cron.trigger

ts
cron.trigger(id: string): Promise<{ runId }>

Fires a job now, outside its schedule — a "Run now" button, or to test a new job. At most 10 manual runs a minute per project.

Parameters

NameTypeRequiredDescription
idstringyesThe job's id.

Returns Promise<{ runId }> — The id of the run it started (it shows in runs() once done).

FieldTypeAlways presentDescription
runIdstringyesThe id of the run that was started.

Errors — besides the errors every call can throw:

CodeHTTPWhen
CRON_JOB_NOT_FOUND404No job with this id.
RATE_LIMITED429More than 10 manual runs in a minute; details.retryAfterSeconds.

Example

ts
const { runId } = await totalum.cron.trigger('cj_01M4P1F0R7T2Y9U4I6O3P8A5SD');

Result:

json
{ "runId": "cr_01M4P1H5J6K7L8M9N0P1Q2R3ST" }

#CronJob

A scheduled job.

FieldTypeAlways presentDescription
idstringyesThe job id (cj_…).
namestringyesA name of yours (daily-report). Allowed: at least 1 character, at most 64 characters.
schedulestring | { everyMinutes }yesWhen it runs: a 5-field cron expression ("0 8 * * *" = 08:00 every day, "*/15 * * * *" = every 15 minutes) or { everyMinutes: n }. The plan sets the shortest interval.
schedule.everyMinutesnumberyesRun every this many minutes. Allowed: > 0.
request{ method, url, headers?, body?, timeoutMs? }yesThe HTTP call each run makes.
request.method'GET' | 'POST'yesGET or POST.
request.urlstringyesA URL on the project's own https:// host (the published site for live, the preview for dev). Allowed: a URL.
request.headersRecord<string, string>noExtra headers to send.
request.bodystringnoThe body of a POST. Allowed: at most 65536 characters.
request.timeoutMsnumbernoHow long a run may take. Default 30 s, at most 30 s. Allowed: > 0, ≤ 30000.
enabledbooleanyesfalse creates it paused. Default true.
status'active' | 'paused' | 'paused_failures'yesactive, paused (by you) or paused_failures (after too many failed runs; fix the route and resume).
nextRunAtstring | nullyesWhen it runs next, or null while paused.
createdAtstringyesWhen it was created.
env'dev' | 'live'yeslive (the published site) or dev (the preview). Default: the environment of request.url.
pauseAfterFailuresnumber | nullyesFailed runs in a row before it pauses; null = never. Allowed: ≥ 0, ≤ 100.
lastRun{ at, status, latencyMs }noThe latest run.
lastRun.atstringyesWhen it ran.
lastRun.statusnumber | 'timeout' | 'error' | 'skipped'yesThe HTTP status your route answered, or timeout, error (no answer) or skipped (cron was switched off).
lastRun.latencyMsnumberyesHow long it took.
descriptionstringnoA note of yours.
timezonestringnoAn IANA time zone (Europe/Madrid): the schedule reads that zone's clock, daylight saving included. Default UTC. Allowed: at least 1 character, at most 64 characters.

#CronJobInput

A job for cron.create().

NameTypeRequiredDescription
namestringyesA name of yours (daily-report). Allowed: at least 1 character, at most 64 characters.
schedulestring | { everyMinutes }yesWhen it runs: a 5-field cron expression ("0 8 * * *" = 08:00 every day, "*/15 * * * *" = every 15 minutes) or { everyMinutes: n }. The plan sets the shortest interval.
schedule.everyMinutesnumberyesRun every this many minutes. Allowed: > 0.
request{ method, url, headers?, body?, timeoutMs? }yesThe HTTP call each run makes.
request.method'GET' | 'POST'yesGET or POST.
request.urlstringyesA URL on the project's own https:// host (the published site for live, the preview for dev). Allowed: a URL.
request.headersRecord<string, string>noExtra headers to send.
request.bodystringnoThe body of a POST. Allowed: at most 65536 characters.
request.timeoutMsnumbernoHow long a run may take. Default 30 s, at most 30 s. Allowed: > 0, ≤ 30000.
enabledbooleannofalse creates it paused. Default true.
descriptionstringnoA note of yours.
env'dev' | 'live'nolive (the published site) or dev (the preview). Default: the environment of request.url.
timezonestringnoAn IANA time zone (Europe/Madrid): the schedule reads that zone's clock, daylight saving included. Default UTC. Allowed: at least 1 character, at most 64 characters.
pauseAfterFailuresnumber | nullnoPause the job after this many failed runs in a row. Default 3; null or 0 never pauses. Allowed: ≥ 0, ≤ 100.

#CronJobPatch

The fields cron.update() changes; each is optional and means the same as in cron.create().

NameTypeRequiredDescription
namestringnoA name of yours (daily-report). Allowed: at least 1 character, at most 64 characters.
schedulestring | { everyMinutes }noWhen it runs: a 5-field cron expression ("0 8 * * *" = 08:00 every day, "*/15 * * * *" = every 15 minutes) or { everyMinutes: n }. The plan sets the shortest interval.
schedule.everyMinutesnumberyesRun every this many minutes. Allowed: > 0.
request{ method, url, headers?, body?, timeoutMs? }noThe HTTP call each run makes.
request.method'GET' | 'POST'yesGET or POST.
request.urlstringyesA URL on the project's own https:// host (the published site for live, the preview for dev). Allowed: a URL.
request.headersRecord<string, string>noExtra headers to send.
request.bodystringnoThe body of a POST. Allowed: at most 65536 characters.
request.timeoutMsnumbernoHow long a run may take. Default 30 s, at most 30 s. Allowed: > 0, ≤ 30000.
enabledbooleannofalse creates it paused. Default true.
descriptionstringnoA note of yours.
env'dev' | 'live'nolive (the published site) or dev (the preview). Default: the environment of request.url.
timezonestringnoAn IANA time zone (Europe/Madrid): the schedule reads that zone's clock, daylight saving included. Default UTC. Allowed: at least 1 character, at most 64 characters.
pauseAfterFailuresnumber | nullnoPause the job after this many failed runs in a row. Default 3; null or 0 never pauses. Allowed: ≥ 0, ≤ 100.

#CronRun

One execution of a job.

FieldTypeAlways presentDescription
idstringyesThe run id (cr_…).
scheduledForstringyesWhen it was due.
startedAtstring | nullyesWhen the call started, or null if it never did.
statusnumber | 'timeout' | 'error' | 'skipped'yesThe HTTP status your route answered, or timeout, error or skipped.
latencyMsnumber | nullyesHow long the call took, or null.
errorstringnoWhy it failed, when it did.
responseSnippetstringnoThe first 1 KB of your route's answer.

#CronRunsPage

One page of cron.runs().

FieldTypeAlways presentDescription
itemsCronRun[]yesThe runs, newest first.
nextCursorstring | nullyesPass it as cursor for the next page; null on the last.