---
type: api
title: Sync saved objects in the default space
description: Synchronizes Kibana saved objects for machine learning jobs and trained models in the default space. You must have `all` privileges for the **Machine Learning** feature in the **Analytics** section of the Kibana feature privileges. This API runs automatically when you start Kibana and periodically thereafter.
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/kibana/v0/operation/operation-mlsync
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/kibana/v0/operation/operation-mlsync
products:
  - Kibana
---

# Sync saved objects in the default space

- Server: `https://{kibana_url}`

## Paths

- `GET` `/api/ml/saved_objects/sync`

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

## Description

Synchronizes Kibana saved objects for machine learning jobs and trained models in the default space. You must have `all` privileges for the **Machine Learning** feature in the **Analytics** section of the Kibana feature privileges. This API runs automatically when you start Kibana and periodically thereafter.

## Query String Parameters

- `simulate` (boolean)
  When true, simulates the synchronization by returning only the list of actions that would be performed.

## Responses

#### `200`

Indicates a successful call

`application/json`

- `datafeedsAdded` (map string to object)
  If a saved object for an anomaly detection job is missing a datafeed identifier, it is added when you run the sync machine learning saved objects API.
  Map values ({})
  - `success` (boolean)
    The success or failure of the synchronization.
- `datafeedsRemoved` (map string to object)
  If a saved object for an anomaly detection job references a datafeed that no longer exists, it is deleted when you run the sync machine learning saved objects API.
  Map values ({})
  - `success` (boolean)
    The success or failure of the synchronization.
- `savedObjectsCreated` ({})
  If saved objects are missing for machine learning jobs or trained models, they are created when you run the sync machine learning saved objects API.
  - `anomaly-detector` (map string to object)
    If saved objects are missing for anomaly detection jobs, they are created.
    Map values ({})
    - `success` (boolean)
      The success or failure of the synchronization.
  - `data-frame-analytics` (map string to object)
    If saved objects are missing for data frame analytics jobs, they are created.
    Map values ({})
    - `success` (boolean)
      The success or failure of the synchronization.
  - `trained-model` (map string to object)
    If saved objects are missing for trained models, they are created.
    Map values ({})
    - `success` (boolean)
      The success or failure of the synchronization.
- `savedObjectsDeleted` ({})
  If saved objects exist for machine learning jobs or trained models that no longer exist, they are deleted when you run the sync machine learning saved objects API.
  - `anomaly-detector` (map string to object)
    If there are saved objects exist for nonexistent anomaly detection jobs, they are deleted.
    Map values ({})
    - `success` (boolean)
      The success or failure of the synchronization.
  - `data-frame-analytics` (map string to object)
    If there are saved objects exist for nonexistent data frame analytics jobs, they are deleted.
    Map values ({})
    - `success` (boolean)
      The success or failure of the synchronization.
  - `trained-model` (map string to object)
    If there are saved objects exist for nonexistent trained models, they are deleted.
    Map values ({})
    - `success` (boolean)
      The success or failure of the synchronization.
#### `401`

Authorization information is missing or invalid.

`application/json`

- `error` (string)
- `message` (string)
- `statusCode` (integer)
## Code Examples

#### Console

```console
GET /api/ml/saved_objects/sync
```

#### curl

```curl
curl -X GET "https://{kibana_url}/api/ml/saved_objects/sync"
```

## Response Examples

#### Two anomaly detection jobs required synchronization in this example.

```json
{
  "datafeedsAdded": {},
  "datafeedsRemoved": {},
  "savedObjectsCreated": {
    "anomaly-detector": {
      "myjob1": {
        "success": true
      },
      "myjob2": {
        "success": true
      }
    }
  },
  "savedObjectsDeleted": {}
}
```

#### Two anomaly detection jobs required synchronization in this example.

```json
{
  "error": "Unauthorized",
  "message": "[security_exception\n\tRoot causes:\n\t\tsecurity_exception: unable to authenticate user [ml_viewer] for REST request [/_security/_authenticate]]: unable to authenticate user [ml_viewer] for REST request [/_security/_authenticate]",
  "statusCode": 401
}
```

