Jobs HTTP API
The /jobs
endpoints are used to query for and interact with jobs.
List Jobs
This endpoint lists all known jobs in the system registered with Nomad.
Method | Path | Produces |
---|---|---|
GET | /v1/jobs | application/json |
The table below shows this endpoint's support for blocking queries and required ACLs.
Blocking Queries | ACL Required |
---|---|
YES | namespace:list-jobs |
Parameters
prefix
(string: "")
- Specifies a string to filter jobs on based on an index prefix. This is specified as a query string parameter.namespace
(string: "default")
- Specifies the target namespace. Specifying*
would return all jobs across all the authorized namespaces.
Sample Request
Sample Response
Create Job
This endpoint creates (aka "registers") a new job in the system.
Method | Path | Produces |
---|---|---|
POST | /v1/jobs | application/json |
The table below shows this endpoint's support for blocking queries and required ACLs.
Blocking Queries | ACL Required |
---|---|
NO | namespace:submit-job namespace:sentinel-override if PolicyOverride set |
Parameters
Job
(Job: <required>)
- Specifies the JSON definition of the job.EnforceIndex
(bool: false)
- If set, the job will only be registered if the passedJobModifyIndex
matches the current job's index. If the index is zero, the register only occurs if the job is new. This paradigm allows check-and-set style job updating.JobModifyIndex
(int: 0)
- Specifies theJobModifyIndex
to enforce the current job is at.PolicyOverride
(bool: false)
- If set, any soft mandatory Sentinel policies will be overridden. This allows a job to be registered when it would be denied by policy.PreserveCounts
(bool: false)
- If set, existing task group counts are preserved, over those specified in the new job spec.
Sample Payload
Sample Request
Sample Response
Parse Job
This endpoint will parse a HCL jobspec and produce the equivalent JSON encoded job.
Method | Path | Produces |
---|---|---|
POST | /v1/jobs/parse | application/json |
The table below shows this endpoint's support for blocking queries and required ACLs.
Blocking Queries | ACL Required |
---|---|
NO | none |
Parameters
JobHCL
(string: <required>)
- Specifies the HCL definition of the job encoded in a JSON string.Canonicalize
(bool: false)
- Flag to enable setting any unset fields to their default values.HCLv1
(bool: false)
- Use the legacy v1 HCL parser.
Sample Payload
You can use a tool such as jq
to generate
the payload from a local HCL file:
Sample Request
Sample Response
Read Job
This endpoint reads information about a single job for its specification and status.
Method | Path | Produces |
---|---|---|
GET | /v1/job/:job_id | application/json |
The table below shows this endpoint's support for blocking queries and required ACLs.
Blocking Queries | ACL Required |
---|---|
YES | namespace:read-job |
Parameters
:job_id
(string: <required>)
- Specifies the ID of the job (as specified in the job file during submission). This is specified as part of the path.
Sample Request
Sample Response
Field Reference
Status
: The job's current state. It can have one of the following values:Type
: The type of job in terms of scheduling. It can have one of the following values:
List Job Versions
This endpoint reads information about all versions of a job.
Method | Path | Produces |
---|---|---|
GET | /v1/job/:job_id/versions | application/json |
The table below shows this endpoint's support for blocking queries and required ACLs.
Blocking Queries | ACL Required |
---|---|
YES | namespace:read-job |
Parameters
diffs
(bool: false)
- Specifies if the Diffs field should be populated, containing the structured diff between the current and last job version.:job_id
(string: <required>)
- Specifies the ID of the job (as specified in the job file during submission). This is specified as part of the path.
Sample Request
Sample Response
List Job Allocations
This endpoint reads information about a single job's allocations.
Method | Path | Produces |
---|---|---|
GET | /v1/job/:job_id/allocations | application/json |
The table below shows this endpoint's support for blocking queries and required ACLs.
Blocking Queries | ACL Required |
---|---|
YES | namespace:read-job |
Parameters
:job_id
(string: <required>)
- Specifies the ID of the job (as specified in the job file during submission). This is specified as part of the path.all
(bool: false)
- Specifies whether the list of allocations should include allocations from a previously registered job with the same ID. This is possible if the job is deregistered and reregistered.
Sample Request
Sample Response
List Job Evaluations
This endpoint reads information about a single job's evaluations
Method | Path | Produces |
---|---|---|
GET | /v1/job/:job_id/evaluations | application/json |
The table below shows this endpoint's support for blocking queries and required ACLs.
Blocking Queries | ACL Required |
---|---|
YES | namespace:read-job |
Parameters
:job_id
(string: <required>)
- Specifies the ID of the job (as specified in the job file during submission). This is specified as part of the path.
Sample Request
Sample Response
List Job Deployments
This endpoint lists a single job's deployments
Method | Path | Produces |
---|---|---|
GET | /v1/job/:job_id/deployments | application/json |
The table below shows this endpoint's support for blocking queries and required ACLs.
Blocking Queries | ACL Required |
---|---|
YES | namespace:read-job |
Parameters
:job_id
(string: <required>)
- Specifies the ID of the job (as specified in the job file during submission). This is specified as part of the path.all
(bool: false)
- Specifies whether the list of deployments should include deployments from a previously registered job with the same ID. This is possible if the job is deregistered and reregistered.
Sample Request
Sample Response
Read Job's Most Recent Deployment
This endpoint returns a single job's most recent deployment.
Method | Path | Produces |
---|---|---|
GET | /v1/job/:job_id/deployment | application/json |
The table below shows this endpoint's support for blocking queries and required ACLs.
Blocking Queries | ACL Required |
---|---|
YES | namespace:read-job |
Parameters
:job_id
(string: <required>)
- Specifies the ID of the job (as specified in the job file during submission). This is specified as part of the path.
Sample Request
Sample Response
Read Job Summary
This endpoint reads summary information about a job.
Method | Path | Produces |
---|---|---|
GET | /v1/job/:job_id/summary | application/json |
The table below shows this endpoint's support for blocking queries and required ACLs.
Blocking Queries | ACL Required |
---|---|
YES | namespace:read-job |
Parameters
:job_id
(string: <required>)
- Specifies the ID of the job (as specified in the job file during submission). This is specified as part of the path.
Sample Request
Sample Response
Update Existing Job
This endpoint registers a new job or updates an existing job.
Method | Path | Produces |
---|---|---|
POST | /v1/job/:job_id | application/json |
The table below shows this endpoint's support for blocking queries and required ACLs.
Blocking Queries | ACL Required |
---|---|
NO | namespace:submit-job namespace:sentinel-override if PolicyOverride set |
Parameters
:job_id
(string: <required>)
- Specifies the ID of the job (as specified in the job file during submission). This is specified as part of the path.Job
(Job: <required>)
- Specifies the JSON definition of the job.EnforceIndex
(bool: false)
- If set, the job will only be registered if the passedJobModifyIndex
matches the current job's index. If the index is zero, the register only occurs if the job is new. This paradigm allows check-and-set style job updating.JobModifyIndex
(int: 0)
- Specifies theJobModifyIndex
to enforce the current job is at.PolicyOverride
(bool: false)
- If set, any soft mandatory Sentinel policies will be overridden. This allows a job to be registered when it would be denied by policy.
Sample Payload
Sample Request
Sample Response
Dispatch Job
This endpoint dispatches a new instance of a parameterized job.
Method | Path | Produces |
---|---|---|
POST | /v1/job/:job_id/dispatch | application/json |
The table below shows this endpoint's support for blocking queries and required ACLs.
Blocking Queries | ACL Required |
---|---|
NO | namespace:dispatch-job |
Parameters
:job_id
(string: <required>)
- Specifies the ID of the job (as specified in the job file during submission). This is specified as part of the path.Payload
(string: "")
- Specifies a base64 encoded string containing the payload. This is limited to 16384 bytes (16KiB).Meta
(meta<string|string>: nil)
- Specifies arbitrary metadata to pass to the job.
Sample Payload
Sample Request
Sample Response
Revert to older Job Version
This endpoint reverts the job to an older version.
Method | Path | Produces |
---|---|---|
POST | /v1/job/:job_id/revert | application/json |
The table below shows this endpoint's support for blocking queries and required ACLs.
Blocking Queries | ACL Required |
---|---|
NO | namespace:submit-job |
Parameters
JobID
(string: <required>)
- Specifies the ID of the job (as specified in the job file during submission). This is specified as part of the path.JobVersion
(integer: 0)
- Specifies the job version to revert to.EnforcePriorVersion
(integer: nil)
- Optional value specifying the current job's version. This is checked and acts as a check-and-set value before reverting to the specified job.ConsulToken
(string:"")
- Optional value specifying the consul token used for Consul service identity polity authentication checking.VaultToken
(string: "")
- Optional value specifying the vault token used for Vault policy authentication checking.
Sample Payload
Sample Request
Sample Response
Set Job Stability
This endpoint sets the job's stability.
Method | Path | Produces |
---|---|---|
POST | /v1/job/:job_id/stable | application/json |
The table below shows this endpoint's support for blocking queries and required ACLs.
Blocking Queries | ACL Required |
---|---|
NO | namespace:submit-job |
Parameters
JobID
(string: <required>)
- Specifies the ID of the job (as specified in the job file during submission). This is specified as part of the path.JobVersion
(integer: 0)
- Specifies the job version to set the stability on.Stable
(bool: false)
- Specifies whether the job should be marked as stable or not.
Sample Payload
Sample Request
Sample Response
Create Job Evaluation
This endpoint creates a new evaluation for the given job. This can be used to force run the scheduling logic if necessary. Since Nomad 0.8.4, this endpoint supports a JSON payload with additional options. Support for calling this end point without a JSON payload will be removed in Nomad 0.9.
Method | Path | Produces |
---|---|---|
POST | /v1/job/:job_id/evaluate | application/json |
The table below shows this endpoint's support for blocking queries and required ACLs.
Blocking Queries | ACL Required |
---|---|
NO | namespace:read-job |
Parameters
:job_id
(string: <required>)
- Specifies the ID of the job (as specified in the job file during submission). This is specified as part of the path.JobID
(string: <required>)
- Specify the ID of the job in the JSON payloadEvalOptions
(<optional>)
- Specify additional options to be used during the forced evaluation.ForceReschedule
(bool: false)
- If set, failed allocations of the job are rescheduled immediately. This is useful for operators to force immediate placement even if the failed allocations are past their reschedule limit, or are delayed by several hours because the allocation's reschedule policy has exponential delay.
Sample Payload
Sample Request
Sample Response
Create Job Plan
This endpoint invokes a dry-run of the scheduler for the job.
Method | Path | Produces |
---|---|---|
POST | /v1/job/:job_id/plan | application/json |
The table below shows this endpoint's support for blocking queries and required ACLs.
Blocking Queries | ACL Required |
---|---|
NO | namespace:submit-job namespace:sentinel-override if PolicyOverride set |
Parameters
:job_id
(string: <required>)
- Specifies the ID of the job (as specified inthe job file during submission). This is specified as part of the path.
Job
(string: <required>)
- Specifies the JSON definition of the job.Diff
(bool: false)
- Specifies whether the diff structure between the submitted and server side version of the job should be included in the response.PolicyOverride
(bool: false)
- If set, any soft mandatory Sentinel policies will be overridden. This allows a job to be registered when it would be denied by policy.
Sample Payload
Sample Request
Sample Response
Field Reference
Diff
- A diff structure between the submitted job and the server side version. The top-level object is a Job Diff which contains Task Group Diffs, which in turn contain Task Diffs. Each of these objects then has Object and Field Diff structures embedded.NextPeriodicLaunch
- If the job being planned is periodic, this field will include the next launch time for the job.CreatedEvals
- A set of evaluations that were created as a result of the dry-run. These evaluations can signify a follow-up rolling update evaluation or a blocked evaluation.JobModifyIndex
- TheJobModifyIndex
of the server side version of this job.FailedTGAllocs
- A set of metrics to understand any allocation failures that occurred for the Task Group.Annotations
- Annotations include theDesiredTGUpdates
, which tracks whatthe scheduler would do given enough resources for each Task Group.
Force New Periodic Instance
This endpoint forces a new instance of the periodic job. A new instance will be
created even if it violates the job's
prohibit_overlap
settings. As such, this should be only used to immediately run a periodic job.
Method | Path | Produces |
---|---|---|
POST | /v1/job/:job_id/periodic/force | application/json |
The table below shows this endpoint's support for blocking queries and required ACLs.
Blocking Queries | ACL Required |
---|---|
NO | namespace:dispatch-job or namespace:submit-job |
Parameters
:job_id
(string: <required>)
- Specifies the ID of the job (as specified in the job file during submission). This is specified as part of the path.
Sample Request
Sample Response
Stop a Job
This endpoint deregisters a job, and stops all allocations part of it.
Method | Path | Produces |
---|---|---|
DELETE | /v1/job/:job_id | application/json |
The table below shows this endpoint's support for blocking queries and required ACLs.
Blocking Queries | ACL Required |
---|---|
NO | namespace:submit-job |
Parameters
:job_id
(string: <required>)
- Specifies the ID of the job (as specified in the job file during submission). This is specified as part of the path.purge
(bool: false)
- Specifies that the job should stopped and purged immediately. This means the job will not be queryable after being stopped. If not set, the job will be purged by the garbage collector.
Sample Request
Sample Response
Read Job Scale Status
This endpoint reads scale information about a job.
Method | Path | Produces |
---|---|---|
GET | /v1/job/:job_id/scale | application/json |
The table below shows this endpoint's support for blocking queries and required ACLs.
Blocking Queries | ACL Required |
---|---|
YES | namespace:read-job-scaling or namespace:read-job |
Parameters
:job_id
(string: <required>)
- Specifies the ID of the job (as specified in the job file during submission). This is specified as part of the path.
Sample Request
Sample Response
Scale Task Group
This endpoint performs a scaling action against a job. Currently, this endpoint supports scaling the count for a task group. This will return a 400 error if the job has an active deployment.
Method | Path | Produces |
---|---|---|
POST | /v1/job/:job_id/scale | application/json |
The table below shows this endpoint's support for blocking queries and required ACLs.
Blocking Queries | ACL Required |
---|---|
NO | namespace:scale-job or namespace:submit-job namespace:sentinel-override if PolicyOverride set |
Parameters
:job_id
(string: <required>)
- Specifies the ID of the job (as specified in the job file during submission). This is specified as part of the path.Count
(int: <optional>)
- Specifies the new task group count.Target
(json: required)
- JSON map containing the target of the scaling operation. Must contain a fieldGroup
with the name of the task group that is the target of this scaling action.Message
(string: <optional>)
- Description of the scale action, persisted as part of the scaling event. Indicates information or reason for scaling; one ofMessage
orError
must be provided.Error
(string: <optional>)
- Description of the scale action, persisted as part of the scaling event. Indicates an error state preventing scaling; one ofMessage
orError
must be provided.Meta
(json: <optional>)
- JSON block that is persisted as part of the scaling event.PolicyOverride
(bool: false)
- If set, any soft mandatory Sentinel policies will be overridden. This allows a job to be scaled when it would be denied by policy.
Sample Payload
Sample Request
Sample Response
This is the same payload as returned by job update.
EvalCreateIndex
and EvalID
will only be present if the scaling operation resulted in the creation of an evaluation.