---
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/4493/api/doc/elasticsearch-serverless/operation/operation-ml-flush-job
resource: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/elasticsearch-serverless/operation/operation-ml-flush-job
products:
  - Elasticsearch Serverless
---

# Force buffered data to be processed

deprecated

## Paths

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

#### Path parameters

- `job_id` (string) — required
  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`

## Authentication

- Api key: `Authorization: <value>`
  Elasticsearch APIs use key-based authentication.
  You must create an API key and use the encoded value in the request header.
  For example:
  
  
  ```
  curl -X GET "${ES_URL}/_cat/indices?v=true" \
    -H "Authorization: ApiKey ${API_KEY}"
  ```
  
  For more information about where to find API keys for the Elasticsearch endpoint (${ES_URL}) for a project, go to [Get started with Elasticsearch Serverless](https://www.elastic.co/docs/solutions/search/serverless-elasticsearch-get-started).

## Query string parameters

- `advance_time` (union oneOf) — optional
  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 `number`
- `calc_interim` (boolean) — optional
  If true, calculates the interim results for the most recent bucket or all
buckets within the latency period.
- `end` (union oneOf) — optional
  When used in conjunction with `calc_interim` and `start`, specifies the
range of buckets on which to calculate interim results.
  One of: `string` or `number`
- `skip_time` (union oneOf) — optional
  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 `number`
- `start` (union oneOf) — optional
  When used in conjunction with `calc_interim`, specifies the range of
buckets on which to calculate interim results.
  One of: `string` or `number`

## Request body

`application/json`

- `advance_time` (union) — 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` (union) — optional
  Refer to the description for the `end` query parameter.
- `skip_time` (union) — optional
  Refer to the description for the `skip_time` query parameter.
- `start` (union) — 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
  }
)
```

