---
type: api
title: Update saved objects in spaces
description: Update one or more saved objects to add or remove them from some spaces.
url: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/kibana/v0/operation/operation-post-spaces-update-objects-spaces
resource: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/kibana/v0/operation/operation-post-spaces-update-objects-spaces
products:
  - Kibana
---

# Update saved objects in spaces

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

## Paths

- `POST` `/api/spaces/_update_objects_spaces`

## Description

Update one or more saved objects to add or remove them from some spaces.

## Authentication

- Api key: `Authorization: <value>`
  These APIs use key-based authentication. You must create an API key and use the encoded value in the request header. For example: `Authorization: ApiKey base64AccessApiKey`
- Basic: `Authorization: Basic <credentials>`

## Header parameters

- `kbn-xsrf` (string) — required
  A required header to protect against CSRF attacks

## Request body

`application/json`

- `objects` (object[] · max items: 1000) — required
  - `id` (string) — required
    The identifier of the saved object to update.
  - `type` (string) — required
    The type of the saved object to update.
- `spacesToAdd` (string[] · max items: 1000) — required
- `spacesToRemove` (string[] · max items: 1000) — required

## Response

OK: A successful request.

`application/json`

## Code examples

#### Console

```console
POST kbn:/api/spaces/_update_objects_spaces
{
  "objects": [
    {
      "type": "index-pattern",
      "id": "90943e30-9a47-11e8-b64d-95841ca0b247"
    }
  ],
  "spacesToAdd": [
    "test"
  ],
  "spacesToRemove": []
}
```

#### curl

```curl
curl -X POST "${KIBANA_URL}/api/spaces/_update_objects_spaces" \
  -H "kbn-xsrf: true" \
  -H "Authorization: ApiKey ${API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{
    "objects": [
      {
        "type": "index-pattern",
        "id": "90943e30-9a47-11e8-b64d-95841ca0b247"
      }
    ],
    "spacesToAdd": [
      "test"
    ],
    "spacesToRemove": []
  }'
```

## Response examples

#### Update saved object spaces

The response from updating the spaces of saved objects.

```json
{
  "objects": [
    {
      "type": "index-pattern",
      "id": "90943e30-9a47-11e8-b64d-95841ca0b247",
      "spaces": [
        "default",
        "test"
      ]
    }
  ]
}
```

