---
type: api
title: Force buffered data to be processed
description: The flush jobs API is only applicable when sending data for analysis using
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v9/operation/operation-ml-flush-job
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v9/operation/operation-ml-flush-job
products:
  - Elasticsearch
---

# Force buffered data to be processed

deprecated

Availability: 5.4+

## Paths

- `POST` `/_ml/anomaly_detectors/{job_id}/_flush`

- [Api key auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v9/authentication#apikeyauth)
- [Basic auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v9/authentication#basicauth)
- [Bearer auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v9/authentication#bearerauth)

#### Path Parameters

- `job_id` (string Id)
  Identifier for the anomaly detection job.

## Description

The flush jobs API is only applicable when sending data for analysis using
the post data API. Depending on the content of the buffer, then it might
additionally calculate new results. Both flush and close operations are
similar, however the flush is more efficient if you are expecting to send
more data for analysis. When flushing, the job remains open and is available
to continue analyzing data. A close operation additionally prunes and
persists the model state to disk and the job must be opened again before
analyzing further data.

## Required authorization

* Cluster privileges: `manage_ml`

## Query String Parameters

- `advance_time` (union DateTime)
  Specifies to advance to a particular time value. Results are generated
and the model is updated for data from the specified time interval.
  One of: `string` or `EpochTimeUnitMillis`
- `calc_interim` (boolean)
  If true, calculates the interim results for the most recent bucket or all
buckets within the latency period.
- `end` (union DateTime)
  When used in conjunction with `calc_interim` and `start`, specifies the
range of buckets on which to calculate interim results.
  One of: `string` or `EpochTimeUnitMillis`
- `skip_time` (union DateTime)
  Specifies to skip to a particular time value. Results are not generated
and the model is not updated for data from the specified time interval.
  One of: `string` or `EpochTimeUnitMillis`
- `start` (union DateTime)
  When used in conjunction with `calc_interim`, specifies the range of
buckets on which to calculate interim results.
  One of: `string` or `EpochTimeUnitMillis`

## Request Body

`application/json`

- `advance_time` (DateTime) — optional
  Refer to the description for the `advance_time` query parameter.
- `calc_interim` (boolean) — optional
  Refer to the description for the `calc_interim` query parameter.
- `end` (DateTime) — optional
  Refer to the description for the `end` query parameter.
- `skip_time` (DateTime) — optional
  Refer to the description for the `skip_time` query parameter.
- `start` (DateTime) — optional
  Refer to the description for the `start` query parameter.

## Response

`application/json`

- `flushed` (boolean)
- `last_finalized_bucket_end` (number)
  Provides the timestamp (in milliseconds since the epoch) of the end of
the last bucket that was processed.
## Code Examples

#### Console

```console
POST _ml/anomaly_detectors/low_request_rate/_flush
{
  "calc_interim": true
}
```

#### JavaScript

```javascript
const response = await client.ml.flushJob({
  job_id: "low_request_rate",
  calc_interim: true,
});
```

#### Python

```python
resp = client.ml.flush_job(
    job_id="low_request_rate",
    calc_interim=True,
)
```

#### curl

```curl
curl -X POST "$ELASTICSEARCH_URL/_ml/anomaly_detectors/low_request_rate/_flush" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "calc_interim": true
  }'
```

#### Java

```java
client.ml().flushJob(f -> f
    .calcInterim(true)
    .jobId("low_request_rate")
);
```

#### C#

```c#
var response = await client.MachineLearning
    .FlushJobAsync(jobId: "low_request_rate", d1 => d1
        .CalcInterim(true)
    );
```

#### PHP

```php
$resp = $client->ml()->flushJob([
    "job_id" => "low_request_rate",
    "body" => [
        "calc_interim" => true,
    ],
]);
```

#### Ruby

```ruby
response = client.ml.flush_job(
  job_id: "low_request_rate",
  body: {
    "calc_interim": true
  }
)
```

