--
:api: forecast-job 
:request: ForecastJobRequest
:response: ForecastJobResponse
--
[role="xpack"]
[id="{upid}-{api}"]
=== Forecast jobs API

Forecasts a {ml} job's behavior based on historical data. It accepts a
+{request}+ object and responds with a +{response}+ object.

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

A +{request}+ object gets created with an existing non-null `jobId`.
All other fields are optional for the request.

["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests-file}[{api}-request]
--------------------------------------------------
<1> Constructing a new request referencing an existing `jobId`

==== Optional arguments

The following arguments are optional.

["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests-file}[{api}-request-options]
--------------------------------------------------
<1> Set when the forecast for the job should expire
<2> Set how far into the future should the forecast predict
<3> Set the maximum amount of memory the forecast is allowed to use.
    Defaults to 20mb. Maximum is 500mb, minimum is 1mb. If set to
    40% or more of the job's configured memory limit, it is
    automatically reduced to below that number.

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

A +{response}+ contains an acknowledgement and the forecast ID

["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests-file}[{api}-response]
--------------------------------------------------
<1> `isAcknowledged()` indicates if the forecast was successful
<2> `getForecastId()` provides the ID of the forecast that was created

include::../execution.asciidoc[]
