---
title: "Swap saved object references"
method: POST
path: "/api/data_views/swap_references"
tags: ["data views"]
---

# Swap saved object references

`POST /api/data_views/swap_references`

**Spaces method and path for this operation:**

<div><span class="operation-verb post">post</span>&nbsp;<span class="operation-path">/s/{space_id}/api/data_views/swap_references</span></div>

Refer to [Spaces](https://www.elastic.co/docs/deploy-manage/manage-spaces) for more information.

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.

## Headers

- `kbn-xsrf` string, required

## Request body

- DataViewsSwapDataViewRequestObject
  - `delete` boolean — Deletes referenced saved object if all references are removed.
  - `forId` union — Limit the affected saved objects to one or more by identifier.
    - string
    - string[]
  - `forType` string — Limit the affected saved objects by type.
  - `fromId` string, required — The saved object reference to change.
  - `fromType` string — 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 `200`

Indicates a successful call.

- object
  - `deleteStatus` object
    - `deletePerformed` boolean
    - `remainingRefs` integer
  - `result` object[]
    - `id` string — A saved object identifier.
    - `type` string — The saved object type.

---

[API](https://skmtc.net/elastic/apis/kibana-apis.md) · [All operations](https://skmtc.net/elastic/apis/kibana-apis/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/elastic/kibana-apis/versions/531c9e2a7d23/schema)
