---
type: api
title: Swap saved object references
description: Swap saved object references from one data view to another. Use this endpoint to update dashboards, visualizations, and other saved objects that reference a data view. WARNING: Misuse can break large numbers of saved objects! Use the [`_preview`](https://www.elastic.co/docs/api/doc/kibana/operation/operation-previewswapdataviewsdefault) endpoint to see which saved objects would be affected before making changes.
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/kibana/v0/operation/operation-swapdataviewsdefault
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/kibana/v0/operation/operation-swapdataviewsdefault
products:
  - Kibana
---

# Swap saved object references

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

## Paths

- `POST` `/api/data_views/swap_references`

- [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

Swap saved object references from one data view to another. Use this endpoint to update dashboards, visualizations, and other saved objects that reference a data view. WARNING: Misuse can break large numbers of saved objects! Use the [`_preview`](https://www.elastic.co/docs/api/doc/kibana/operation/operation-previewswapdataviewsdefault) endpoint to see which saved objects would be affected before making changes.

## Request Body

`application/json`

- `delete` (boolean) — optional
  Deletes referenced saved object if all references are removed.
- `forId` (union string | [] string) — optional
  Limit the affected saved objects to one or more by identifier.
- `forType` (string) — optional
  Limit the affected saved objects by type.
- `fromId` (string) — required
  The saved object reference to change.
- `fromType` (string) — optional
  Specify the type of the saved object reference to alter. The default value is `index-pattern` for data views.
- `toId` (string) — required
  New saved object reference value to replace the old value.

## Response

Indicates a successful call.

`application/json`

- `deleteStatus` (object)
  - `deletePerformed` (boolean)
  - `remainingRefs` (integer)
- `result` ([] object)
  - `id` (string)
    A saved object identifier.
  - `type` (string)
    The saved object type.
## Code Examples

#### Console

```console
POST kbn://api/data_views/swap_references
{"fromId":"abcd-efg","toId":"xyz-123","delete":true}
```

#### curl

```curl
curl \
  -X POST "${KIBANA_URL}/api/data_views/swap_references" \
  -H "Authorization: ApiKey ${API_KEY}" \
  -H "kbn-xsrf: true" \
  -H "Content-Type: application/json" \
  -d '{"fromId":"abcd-efg","toId":"xyz-123","delete":true}'
```

## Response Examples

#### The swap references API returns a list of the affected saved objects.

The list of saved objects whose references were updated, along with the delete status of the source.

```json
{
  "deleteStatus": {
    "deletePerformed": true,
    "remainingRefs": 0
  },
  "result": [
    {
      "id": "123",
      "type": "visualization"
    }
  ]
}
```

