Skip to main content
Version: 24.05

/o?method=jobs

Endpoint​

/o?method=jobs

Overview​

Lists the background jobs of the server, one row per job name. When name is given, lists the individual runs of that job instead.

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
api_keyStringYes (or use auth_token)Dashboard API authentication key.
auth_tokenStringYes (or use api_key)Dashboard auth token.
app_idStringYesApp ID. The request is rejected without it.
methodStringYesMust be jobs.
nameStringNoJob name. When set, returns the runs of this job.
sSearchStringNoText to look for in job names. Plain text, case-insensitive, at most 256 characters. Only applies to the list without name.
iDisplayStartNumberNoNumber of rows to skip. Default 0.
iDisplayLengthNumberNoNumber of rows to return. Default 10.
iSortCol_0NumberNoIndex of the column to sort by.
sSortDir_0StringNoasc for ascending; any other value sorts descending.
sEchoStringNoCounter returned unchanged in the response.

Sortable columns (iSortCol_0): without name: name, schedule, next, finished, status, total (0-5). With name: schedule, next, finished, status, data, duration (0-5).

Examples​

Example 1: List jobs​

/o?method=jobs&
api_key=YOUR_API_KEY&
app_id=6991c75b024cb89cdc04efd2&
iDisplayStart=0&
iDisplayLength=10

Example 2: List the runs of one job​

/o?method=jobs&
api_key=YOUR_API_KEY&
app_id=6991c75b024cb89cdc04efd2&
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
sEchoStringValue of the sEcho request parameter.
iTotalRecordsNumberTotal number of rows.
iTotalDisplayRecordsNumberSame as iTotalRecords.
aaDataArrayJob rows.
aaData[].nameStringJob name.
aaData[].statusStringJob status as text.
aaData[].scheduleStringSchedule of the job.
aaData[].nextNumberNext run time (ms since epoch).
aaData[].finishedNumberLast finish time (ms since epoch).
aaData[].totalNumberNumber of stored runs of this job name.

With name, each row is a stored run of the job and contains the full job record (for example created, started, finished, duration, data, schedule, next, modified, error).

Error Responses​

Status Code: 400 Bad Request

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

Status Code: 500

"Fetching jobs failed"

Behavior​

  • Without name, rows are grouped by job name. For each name the row shown is a running or scheduled run if there is one, otherwise the most recently finished one.
Implementation details

Database Collections

CollectionUsed forData touched by this endpoint
countly.jobsJob storageReads job records.