---
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/5066/api/kibana/operation/operation-mlsync
resource: https://www.elastic.co/elastic/docs-builder/docs/5066/api/kibana/operation/operation-mlsync
products:
  - Kibana
---

# Sync saved objects in the default space

Authentication: required

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

## Paths

- `GET` `/api/ml/saved_objects/sync`
- `GET` `/s/{space_id}/api/ml/saved_objects/sync`

#### Path parameters

- `space_id` (string) — optional
  An identifier for the space. If `space_id` is not provided in the URL, the default space is used. Refer to [Spaces](https://www.elastic.co/docs/deploy-manage/manage-spaces) for more information.

## 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) — optional
  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 (object)
  - `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 (object)
  - `success` (boolean)
    The success or failure of the synchronization.
- `savedObjectsCreated` (object)
  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 (object)
    - `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 (object)
    - `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 (object)
    - `success` (boolean)
      The success or failure of the synchronization.
- `savedObjectsDeleted` (object)
  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 (object)
    - `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 (object)
    - `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 (object)
    - `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 kbn:/api/ml/saved_objects/sync
```

#### curl

```curl
curl -X GET "${KIBANA_URL}/api/ml/saved_objects/sync" \
  -H "Authorization: ApiKey ${API_KEY}"
```

## Response examples

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

`application/json`

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

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

`application/json`

```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
}
```

