---
type: api
title: Preview swap references
description: **Spaces method and path for this operation:**
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/kibana/operation/operation-previewswapdataviewsdefault
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/kibana/operation/operation-previewswapdataviewsdefault
products:
  - Kibana
---

# Preview swap references

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

## Paths

- `POST` `/api/data_views/swap_references/_preview`
- `POST` `/s/{space_id}/api/data_views/swap_references/_preview`

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

## Description

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

Preview the effect of swapping saved object references from one data view to another. Returns the list of affected saved objects without making any 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`

- `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/_preview
{"fromId":"abcd-efg","toId":"xyz-123"}
```

#### curl

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

## Response Examples

#### A preview of saved objects that would be affected by a data view swap.

The result array lists every saved object that references the source data view. No saved objects are modified by the preview endpoint.

```json
{
  "result": [
    {
      "id": "8963ca30-bca7-11e8-aa00-0123456789ab",
      "type": "visualization"
    },
    {
      "id": "edf84fe0-e1a0-11e7-b6d5-4dc382ef7f5b",
      "type": "dashboard"
    }
  ]
}
```

