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.next_token
(string: "")
- This endpoint supports paging. Thenext_token
parameter accepts a string which identifies the next expected job. This value can be obtained from theX-Nomad-NextToken
header from the previous response.per_page
(int: 0)
- Specifies a maximum number of jobs to return for this request. If omitted, the response is not paginated. The value of theX-Nomad-NextToken
header of the last response can be used as thenext_token
of the next request to fetch additional pages.filter
(string: "")
- Specifies the expression used to filter the results. Consider using pagination or a query parameter to reduce resource used to serve the request.namespace
(string: "default")
- Specifies the target namespace. Specifying*
would return all jobs across all the authorized namespaces.meta
(bool: false)
- If set, jobs returned will include a meta field containing key-value pairs provided in the job specification'smeta
block.
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.Submission
(JobSubmission: <optional>)
- Specifies the original HCL/HCL2/JSON definition of the job. This data is useful for reference only, it is not considered for the actual scheduling ofJob
.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.EvalPriority
(int: 0)
- Override the priority of the evaluations produced as a result of this job registration. By default, this is set to the priority of the job.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 | namespace:parse-job namespace:submit-job |
Parameters
namespace
(string: "default")
- Specifies the target namespace. If ACL is enabled, this value must match a namespace that the token is allowed to access. This is specified as a query string parameter.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.Variables
(string: "")
- Specifies HCL2 variables to use during parsing of the job in the var file format.VariableFlags
(map[string]string: nil)
- Specifies HCL2 variables to use during parsing of the job in key = value format.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.namespace
(string: "default")
- Specifies the namespace of the job. If not specified, defaults to "default". This is specified as a URL query parameter.
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:
Read Job Submission
This endpoint reads original source information about a specific version of a single job. The data this endpoint provides is only available if it was provided with the original job during job registration. Only the most recent 6 job source files are retained.
Method | Path | Produces |
---|---|---|
GET | /v1/job/:job_id/submission | application/json |
Parameters
:job_id
(string: <required>)
- Specifies the ID of the job. This is specified as part of the path.version
(int: <required>)
- Specifies the version number of the job for which to retrieve the original source information. This is specified as a query string parameter.namespace
(string: "default")
- Specifies the target namespace. If ACL is enabled, this value must match a namespace that the token is allowed to access. This is specified as a query string parameter.
Sample Request
Sample Response
Field Reference
JobID
: The ID of the job associated with the original job file.Format
: The file format of the original job file. One ofhcl2
,hcl1
, orjson
.Source
: The literal content of the original job file.VariableFlags
: The key-value pairs of HCL variables as submitted via-var
command line arguments when submitting the job via CLI.Variables
: The content of the variables form when submitting the job via the WebUI.Version
: The version of the job this submission source is associated with.
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.namespace
(string: "default")
- Specifies the target namespace. If ACL is enabled, this value must match a namespace that the token is allowed to access. This is specified as a query string parameter.
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 re-registered.namespace
(string: "default")
- Specifies the target namespace. If ACL is enabled, this value must match a namespace that the token is allowed to access. This is specified as a query string parameter.
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.namespace
(string: "default")
- Specifies the target namespace. If ACL is enabled, this value must match a namespace that the token is allowed to access. This is specified as a query string parameter.
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 re-registered.namespace
(string: "default")
- Specifies the target namespace. If ACL is enabled, this value must match a namespace that the token is allowed to access. This is specified as a query string parameter.
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.namespace
(string: "default")
- Specifies the target namespace. If ACL is enabled, this value must match a namespace that the token is allowed to access. This is specified as a query string parameter.
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.namespace
(string: "default")
- Specifies the target namespace. If ACL is enabled, this value must match a namespace that the token is allowed to access. This is specified as a query string parameter.
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.Submission
(JobSubmission: <optional>)
- Specifies the original HCL/HCL2/JSON definition of the job. This data is useful for reference only, it is not considered for the actual scheduling ofJob
.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.EvalPriority
(int: 0)
- Override the priority of the evaluations produced as a result of this job update. By default, this is set to the priority of the job.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.namespace
(string: "default")
- Specifies the target namespace. If ACL is enabled, this value must match a namespace that the token is allowed to access. This is specified as a query string parameter.
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.IdempotencyToken
(string: "")
- Optional identifier used to prevent more than one instance of the job from being dispatched. This is specified as a URL query parameter.IdPrefixTemplate
(string: "")
- Optional prefix added to dispatched job IDs.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.namespace
(string: "default")
- Specifies the target namespace. If ACL is enabled, this value must match a namespace that the token is allowed to access. This is specified as a query string parameter.
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.namespace
(string: "default")
- Specifies the target namespace. If ACL is enabled, this value must match a namespace that the token is allowed to access. This is specified as a query string parameter.
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.namespace
(string: "default")
- Specifies the target namespace. If ACL is enabled, this value must match a namespace that the token is allowed to access. This is specified as a query string parameter.
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: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.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 rescheduling limit, or are delayed by several hours because the allocation's reschedule policy has exponential delay.
namespace
(string: "default")
- Specifies the target namespace. If ACL is enabled, this value must match a namespace that the token is allowed to access. This is specified as a query string parameter.
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.namespace
(string: "default")
- Specifies the target namespace. If ACL is enabled, this value must match a namespace that the token is allowed to access. This is specified as a query string parameter.
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.eval_priority
(int: 0)
- Override the priority of the evaluations produced as a result of this job deregistration. By default, this is set to the priority of the job.global
(bool: false)
- Stop a multi-region job in all its regions. By default, job stop will stop only a single region at a time. Ignored for single-region jobs.purge
(bool: false)
- Specifies that the job should be 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.namespace
(string: "default")
- Specifies the target namespace. If ACL is enabled, this value must match a namespace that the token is allowed to access. This is specified as a query string parameter.no_shutdown_delay
(bool: false)
- Ignore the group and taskshutdown_delay
configuration so that there is no delay between service deregistration and task shutdown. Note that using this flag will result in failed network connections to the allocations being stopped.
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.namespace
(string: "default")
- Specifies the target namespace. If ACL is enabled, this value must match a namespace that the token is allowed to access. This is specified as a query string parameter.
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.namespace
(string: "default")
- Specifies the target namespace. If ACL is enabled, this value must match a namespace that the token is allowed to access. This is specified as a query string parameter.
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.
Job Services
The endpoint is used to read all services registered within Nomad belonging to the passed job ID.
Method | Path | Produces |
---|---|---|
GET | /job/:job_id/services | application/json |
The table below shows this endpoint's support for blocking queries, consistency modes and required ACLs.
Blocking Queries | Consistency Modes | ACL Required |
---|---|---|
YES | all | 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.namespace
(string: "default")
- Specifies the target namespace.
Sample Request
Sample Response