--
:api: close-job
:request: CloseJobRequest
:response: CloseJobResponse
--
[role="xpack"]
[id="{upid}-{api}"]
=== Close {anomaly-jobs} API

Closes {anomaly-jobs} in the cluster. It accepts a +{request}+ object and responds with a +{response}+ object.

[id="{upid}-{api}-request"]
==== Close {anomaly-jobs} request

A +{request}+ object gets created with an existing non-null `jobId`.

["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests-file}[{api}-request]
--------------------------------------------------
<1> Constructing a new request referencing existing job IDs
<2> Optionally used to close a failed job, or to forcefully close a job
which has not responded to its initial close request.
<3> Optionally set to ignore if a wildcard expression matches no jobs.
 (This includes `_all` string or when no jobs have been specified)
<4> Optionally setting the `timeout` value for how long the
execution should wait for the job to be closed.

[id="{upid}-{api}-response"]
==== Close {anomaly-jobs} response

["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests-file}[{api}-response]
--------------------------------------------------
<1> `isClosed()` from the +{response}+ indicates if the job was successfully
closed or not.

include::../execution.asciidoc[]
