FastAPI-Cronsv2.4.0

Mounting the router

get_cron_router() returns a standard APIRouter. Mount it wherever you like; every path below is relative to that prefix.

python
from fastapi_crons import get_cron_router

app.include_router(get_cron_router(), prefix="/api")

These endpoints are unauthenticated

The router ships without auth, and one of its routes runs a job on demand. Guard it with a dependency — see Dashboard for an example — or keep it off public networks.

Routes

MethodPathPurpose
GET/List every registered job.
GET/{job_name}Details for one job.
GET/{job_name}/statusCurrent status of one job.
POST/{job_name}/runTrigger a job immediately.
GET/healthLiveness and readiness probe.
GET/system/statusScheduler-wide status.
GET/dashboardThe web dashboard, if installed.

Route order matters, and it is already handled

/health, /system/status and /dashboard are registered before /{job_name}, so they are matched first rather than being swallowed as job names.

Listing jobs

bash
curl http://127.0.0.1:8000/api/

Returns an array of job objects. A single job has the same shape:

json
{
  "name": "backup_database",
  "expr": "0 2 * * *",
  "tags": ["backup", "critical"],
  "last_run": "2026-07-27T02:00:00+00:00",
  "next_run": "2026-07-28T02:00:00+00:00",
  "hooks": {"before_run": 1, "after_run": 1, "on_error": 2},
  "config": {"max_retries": 3, "retry_delay": 5.0, "timeout": 600}
}

Triggering a job

Runs the job immediately, without waiting for its schedule. The run is marked as a manual trigger in the hook context.

bash
curl -X POST http://127.0.0.1:8000/api/backup_database/run

Health

Suitable for a Kubernetes liveness or readiness probe.

bash
curl http://127.0.0.1:8000/api/health
json
{
  "status": "healthy",
  "version": "2.4.0",
  "uptime": 3600.5,
  "jobs_total": 4,
  "jobs_running": 1
}
status
str
healthy, degraded or unhealthy.
version
str
Reported package version.
uptime
float
Seconds since the router was created.
jobs_total
int
Number of registered jobs.
jobs_running
int
Jobs currently executing.

The version field can be stale

It reads fastapi_crons.__version__, which the release automation does not update. Do not use it to assert which release is deployed.

Esc
IntroductionGetting StartedInstallationGetting StartedQuick StartGetting StartedCron ExpressionsCore ConceptsDefining JobsCore ConceptsHooksCore ConceptsConfigurationCore ConceptsState BackendsBackendsDistributed LockingBackendsDashboardOperationsHTTP EndpointsOperationsCLIOperations