Skip to main content
Version: 25.03

Jobs - Read Jobs

Endpoint​

/o?method=jobs

Overview​

Returns the scheduled jobs of the server as a table. Without name, one row per job name is returned. With name, the individual runs of that job are returned.

Authentication​

Pass api_key or auth_token as a query parameter, or send countly-token as a header. See Authentication.

Permissions​

  • Requires a global administrator.

Request Parameters​

ParameterTypeRequiredDescription
methodStringYesMust be jobs.
app_idStringYesApplication ID. The request is rejected if it is missing.
api_keyStringYes (or use auth_token)Dashboard API key.
auth_tokenStringYes (or use api_key)Dashboard auth token.
nameStringNoJob name. When set, the runs of this job are returned instead of the job list.
sSearchStringNoText to look for in job names. Only used when name is not set.
iDisplayStartNumberNoNumber of rows to skip. Default is 0.
iDisplayLengthNumberNoNumber of rows to return. Default is 10.
iSortCol_0NumberNoIndex of the column to sort by. Default is 0. The columns are name, schedule, next, finished, status, total for the job list, and schedule, next, finished, status, data, duration for the runs of a job.
sSortDir_0StringNoasc for ascending order; any other value sorts in descending order.
sEchoStringNoCounter that is returned unchanged in the response.

Examples​

List jobs​

/o?method=jobs&
app_id=6991c75b024cb89cdc04efd2&
api_key=YOUR_API_KEY

List runs of one job​

/o?method=jobs&
app_id=6991c75b024cb89cdc04efd2&
api_key=YOUR_API_KEY&
name=api:ping

Response​

Success Response​

{
"sEcho": "0",
"iTotalRecords": 14,
"iTotalDisplayRecords": 14,
"aaData": [
{
"_id": "server-stats:stats",
"name": "server-stats:stats",
"status": "SCHEDULED",
"schedule": "every 1 day",
"next": 1650326400000,
"finished": 1650240007917,
"total": 1
}
]
}

Response Fields​

FieldTypeDescription
sEchoStringThe sEcho value of the request.
iTotalRecordsNumberTotal number of jobs (or of runs, when name is set).
iTotalDisplayRecordsNumberSame value as iTotalRecords.
aaDataArrayRows of the table.
aaData[].nameStringJob name.
aaData[].statusStringJob status: SCHEDULED, RUNNING, DONE, CANCELLED, ABORTED, PAUSED, WAITING or SUSPENDED.
aaData[].scheduleStringSchedule of the job.
aaData[].nextNumberTime of the next run, as a timestamp in milliseconds.
aaData[].finishedNumberTime the job last finished, as a timestamp in milliseconds.
aaData[].totalNumberNumber of stored runs of the job. Only in the job list.

When name is set, each row is a single run of the job and also has the job's own fields, such as created, started, duration, data and error.

Error Responses​

  • 400
{
"result": "Missing parameter \"app_id\""
}

Authentication and authorization failures are returned by the common auth layer.

Behavior​

  • In the job list, the status shown for a job is taken from its run that is scheduled first, then suspended ones, then the most recently finished.
  • sSearch matches job names as plain text, ignoring case, and is limited to 256 characters.
Implementation details

Database Collections

CollectionUsed forData touched by this endpoint
countly.jobsJob schedules and runsReads job documents.