---
type: api
title: Open anomaly detection jobs
description: An anomaly detection job must be opened to be ready to receive and analyze
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/operation/operation-ml-open-job
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/operation/operation-ml-open-job
products:
  - Elasticsearch
---

# Open anomaly detection jobs

Availability: 5.4+

## Paths

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

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

#### Path Parameters

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

## Description

An anomaly detection job must be opened to be ready to receive and analyze
data. It can be opened and closed multiple times throughout its lifecycle.
When you open a new job, it starts with an empty model.
When you open an existing job, the most recent model state is automatically
loaded. The job is ready to resume its analysis from where it left off, once
new data is received.

## Required authorization

* Cluster privileges: `manage_ml`

## Query String Parameters

- `timeout` (string Duration · default: 30m)
  Controls the time to wait until a job has opened.

## Request Body

`application/json`

- `timeout` (string Duration · default: 30m) — optional
  Refer to the description for the `timeout` query parameter.

## Response

`application/json`

- `opened` (boolean)
- `node` (string)
  The ID of the node that the job was started on. In serverless this will be the "serverless".
If the job is allowed to open lazily and has not yet been assigned to a node, this value is an empty string.
## Code Examples

#### Console

```console
POST /_ml/anomaly_detectors/job-01/_open
{
  "timeout": "35m"
}
```

#### JavaScript

```javascript
const response = await client.ml.openJob({
  job_id: "job-01",
  timeout: "35m",
});
```

#### Python

```python
resp = client.ml.open_job(
    job_id="job-01",
    timeout="35m",
)
```

#### curl

```curl
curl -X POST "$ELASTICSEARCH_URL/_ml/anomaly_detectors/job-01/_open" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "timeout": "35m"
  }'
```

#### Java

```java
client.ml().openJob(o -> o
    .jobId("job-01")
    .timeout(t -> t
        .time("35m")
    )
);
```

#### C#

```c#
var response = await client.MachineLearning
    .OpenJobAsync(jobId: "job-01", d1 => d1
        .Timeout("35m")
    );
```

#### PHP

```php
$resp = $client->ml()->openJob([
    "job_id" => "job-01",
    "body" => [
        "timeout" => "35m",
    ],
]);
```

#### Ruby

```ruby
response = client.ml.open_job(
  job_id: "job-01",
  body: {
    "timeout": "35m"
  }
)
```

## Response Examples

#### Ml open job response example1

A successful response when opening an anomaly detection job.

```json
{
  "opened": true,
  "node": "node-1"
}
```

