Managing jobs in Management API
On this page
This article documents how to list current jobs, list past jobs, obtain a status of jobs in progress, and how to stop jobs with the Management API.
See GET /api/jobs/ in the API reference.
Prerequisites
Before you complete the procedures in this guide, perform the following action:
-
Use a Connect API key with the following permissions:
-
Datastream: Read-only (
datastream:read) to list jobs and their imported data. -
Datastream: Write (
datastream:write) to stop a job.
Picking Write for a permission also gives the key its Read-only access. Without the permission a request needs, Management API returns HTTP
403. You cannot change the permissions of a key, so to add one, create a new key. For more information, see Creating a Connect API key in Adverity. -
Listing jobs
Listing all jobs in an instance
Use the API call documented in this section to list all currently running and scheduled jobs (for example, fetch jobs) in a whole instance.
To list all running and scheduled jobs, follow these steps:
-
Create a GET request to the following endpoint:
https://{{INSTANCE}}/api/jobs -
In the HTTP request header, include the parameter
Authorizationwith valueBearer {{KEY}}. -
Send the request.
Import the request example as raw text to your HTTP client (such as Postman). The cURL request example is the following:
curl --location --request GET 'https://{{INSTANCE}}/api/jobs/' \
--header 'Authorization: Bearer {{KEY}}'
The response to this request includes the state_label parameter with one of the following values assigned:
-
Scheduled
-
Running
-
Retrying - the job is waiting out a retry/backoff. The underlying
stateremainsRunningwhile this label is shown;state_labelis the only field that changes. -
Success
-
Cancelled
-
Failed
-
Discarded - this status is set in the following cases:
-
If a preceding job failed or was cancelled, the follow up jobs are discarded.
-
If a job does not start running within 2 days of the fetch start, it is discarded.
-
If a job is cancelled manually, it is discarded.
-
-
Stale - this status is not set currently. Generally, it can be used to label jobs that will not complete due to internal failures and lost or removed tasks.
The response of a fetch job also includes the user field:
Scroll horizontally to see the full table.
Field | Description |
|---|---|
| The email of the user who triggered the fetch. This field is |
The response also includes the last_executed field:
Scroll horizontally to see the full table.
Field | Description |
|---|---|
| The timestamp when a job in this job’s job group last started executing. This is a job-group-level value — it reflects any job in the group, not only this one. |
Each job’s nested datastream object also includes the auth and uuid fields:
Scroll horizontally to see the full table.
Field | Description |
|---|---|
| The ID of the authorization the datastream uses. |
| The UUID of the datastream. The endpoints under |
Filtering the jobs
You can filter the jobs returned from this endpoint with a number of parameters:
Scroll horizontally to see the full table.
Parameter | Value | Description |
|---|---|---|
|
| Use this parameter to list the jobs of a specific datastream. |
|
| Use this parameter to list the jobs of datastreams in a specific workspace. A non-numeric value returns a |
| Dates | Use these parameters to list the jobs within a specific date or time range. |
| One of the options: | Use this parameter to list the jobs of a specific type. |
| An email address, for example | Use this parameter to list only the jobs triggered by a specific user. |
|
| Use this parameter to list only human-triggered jobs ( |
For example, to list the jobs of a datastream, import the following request example as raw text to your HTTP client (such as Postman):
curl --location -g --request GET 'https://{{INSTANCE}}/api/jobs/?datastream_id={{DATASTREAM_ID}}/' \
--header 'Authorization: Bearer {{KEY}}'
For example, to list the jobs of datastreams in a specific workspace, import the following request example as raw text to your HTTP client (such as Postman):
curl --location -g --request GET 'https://{{INSTANCE}}/api/jobs/?stack_id={{WORKSPACE_ID}}' \
--header 'Authorization: Bearer {{KEY}}'
For example, to list the jobs within a given date range, import the following request example as raw text to your HTTP client (such as Postman):
curl --location -g --request GET 'https://{{INSTANCE}}/api/jobs/?start=YYYY-MM-DD&end=YYYY-MM-DD' \
--header 'Authorization: Bearer {{KEY}}'
For example, to list the jobs within a more specific time rangeby using timestamps, import the following request example as raw text to your HTTP client (such as Postman):
curl --location -g --request GET 'https://{{INSTANCE}}/api/jobs/?start=YYYY-MM-DDT00:00:00Z&end=YYYY-MM-DDT00:00:00Z' \
--header 'Authorization: Bearer {{KEY}}'
For example, to list the jobs of a certain type, for example Fetch, import the following request example as raw text to your HTTP client (such as Postman):
curl --location -g --request GET 'https://{{INSTANCE}}/api/jobs/?type=Fetch' \
--header 'Authorization: Bearer {{KEY}}'
For example, to list only the jobs triggered by a specific user, import the following request example as raw text to your HTTP client (such as Postman):
curl --location -g --request GET 'https://{{INSTANCE}}/api/jobs/?user=jane@doe.com' \
--header 'Authorization: Bearer {{KEY}}'
For example, to list only the jobs triggered by a person rather than by the system, import the following request example as raw text to your HTTP client (such as Postman):
curl --location -g --request GET 'https://{{INSTANCE}}/api/jobs/?triggered_by_user=true' \
--header 'Authorization: Bearer {{KEY}}'
Listing the fetch jobs of a specific datastream
To list the fetch jobs of a single datastream, you can also use the dedicated /api/datastreams/{{DATASTREAM_ID}}/jobs/ endpoint. This endpoint returns a paginated list of the datastream’s fetch jobs, ordered from the most recent to the oldest.
To list the fetch jobs of a datastream, follow these steps:
-
Create a GET request to the following endpoint:
https://{{INSTANCE}}/api/datastreams/{{DATASTREAM_ID}}/jobs/Replace
{{DATASTREAM_ID}}with the datastream’s ID. -
In the HTTP request header, include the parameter
Authorizationwith valueBearer {{KEY}}. -
Send the request.
As a result, you obtain a paginated list of the datastream’s fetch jobs.
Import the request example as raw text to your HTTP client (such as Postman). The cURL request example is the following:
curl --location -g --request GET 'https://{{INSTANCE}}/api/datastreams/{{DATASTREAM_ID}}/jobs/' \
--header 'Authorization: Bearer {{KEY}}'
The response is a paginated envelope with the count, next, previous, and results fields. Use the page and page_size query parameters to page through the results:
curl --location -g --request GET 'https://{{INSTANCE}}/api/datastreams/{{DATASTREAM_ID}}/jobs/?page=1&page_size=50' \
--header 'Authorization: Bearer {{KEY}}'
Obtaining the status of a job in progress
To obtain a status of a job in progress, follow these steps:
-
Create a GET request to the following endpoint:
https://{{INSTANCE}}/api/jobs/{{JOB_ID}}/imported/Find the value of
JOB_IDparameter in the response of the API request described in the previous section. In this response,JOB_IDparameter is named asid. -
In the HTTP request header, include the parameter
Authorizationwith valueBearer {{KEY}}. -
Send the request.
Import the request example as raw text to your HTTP client (such as Postman). The cURL request example is the following:
curl --location -g --request GET 'https://{{INSTANCE}}/api/jobs/{{JOB_ID}}/imported/' \
--header 'Authorization: Bearer {{KEY}}'
The response contains the following fields:
Scroll horizontally to see the full table.
Field | Description |
|---|---|
| Boolean. |
| Boolean. |
Stopping jobs
To stop a job, list the currently running jobs, and find the JOB_ID of the job to stop. You can only stop jobs in the fetch stage.
To stop a job using JOB_ID, follow these steps:
-
Create a POST request to the following endpoint:
https://{{INSTANCE}}/api/jobs/{{JOB_ID}}/stop/ -
In the HTTP request header, include the parameter
Authorizationwith valueBearer {{KEY}}. -
Send the request.
Import the request example as raw text to your HTTP client (such as Postman). The cURL request example is the following:
curl --location -g --request POST 'https://{{INSTANCE}}/api/jobs/{{JOB_ID}}/stop/' \
--header 'Authorization: Bearer {{KEY}}'