---
title: "Update a saved view"
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.cloudraker.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Update a saved view

Path: CloudRaker Workspace API › Data Objects

`PATCH /spaces/{spaceId}/objects/{definitionId}/views/{viewId}`

Partially updates a saved view. Authorization: requires `space:contribute` on `:spaceId` — lacking it gives **403** (no `space:read` → 404). Strict body accepting any of `name`, `fields[]`, `filters[]`, `sorts[]`, `filterLogic`. The seeded default view cannot be renamed → 400 `default_view_not_renamable`; unknown view → 404; invalid body → 422. Returns `{ view }`.

## Authentication

- `bearerAuth`, http, header `Authorization`

## Path parameters

- `spaceId` (`updateObjectView.path.spaceId`; string, required)
- `definitionId` (`updateObjectView.path.definitionId`; string, required)
- `viewId` (`updateObjectView.path.viewId`; string, required)

## Request body

_Required._

- `name` (`updateObjectView.name`; string, optional)
  - minLength 1; maxLength 200
- `fields` (`updateObjectView.fields`; array<object>, optional)
  - `fieldKey` (`updateObjectView.fields.fieldKey`; string, required)
    - minLength 1
  - `isVisible` (`updateObjectView.fields.isVisible`; boolean, optional)
  - `width` (`updateObjectView.fields.width`; number, optional)
    - min 1
  - `position` (`updateObjectView.fields.position`; number, optional)
- `filters` (`updateObjectView.filters`; array<object>, optional)
  - `fieldKey` (`updateObjectView.filters.fieldKey`; string, required)
    - minLength 1
  - `operand` (`updateObjectView.filters.operand`; string, required) — One of the 14 supported operands.
    - minLength 1
  - `subField` (`updateObjectView.filters.subField`; string, optional)
  - `value` (`updateObjectView.filters.value`; unknown, optional)
- `sorts` (`updateObjectView.sorts`; array<object>, optional)
  - `fieldKey` (`updateObjectView.sorts.fieldKey`; string, required)
    - minLength 1
  - `direction` (`updateObjectView.sorts.direction`; string, required)
    - one of `"asc"`, `"desc"`
  - `subField` (`updateObjectView.sorts.subField`; string, optional)
- `filterLogic` (`updateObjectView.filterLogic`; string, optional)
  - minLength 1

## Example request

```json
{
  "name": "string",
  "fields": [
    {
      "fieldKey": "string",
      "isVisible": true,
      "width": 1,
      "position": 0
    }
  ],
  "filters": [
    {
      "fieldKey": "string",
      "subField": "string",
      "operand": "string",
      "value": null
    }
  ],
  "sorts": [
    {
      "fieldKey": "string",
      "subField": "string",
      "direction": "asc"
    }
  ],
  "filterLogic": "string"
}
```

## Code samples

### cURL

```bash
curl --request PATCH \
  --url 'https://api.cloudraker.com/spaces/<spaceId>/objects/<definitionId>/views/<viewId>' \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "name": "string",
  "fields": [
    {
      "fieldKey": "string",
      "isVisible": true,
      "width": 1,
      "position": 0
    }
  ],
  "filters": [
    {
      "fieldKey": "string",
      "subField": "string",
      "operand": "string",
      "value": null
    }
  ],
  "sorts": [
    {
      "fieldKey": "string",
      "subField": "string",
      "direction": "asc"
    }
  ],
  "filterLogic": "string"
}
'
```

### TypeScript

```typescript
const url = 'https://api.cloudraker.com/spaces/<spaceId>/objects/<definitionId>/views/<viewId>';
const options = {
  method: 'PATCH',
  headers: {'Content-Type': 'application/json', Authorization: 'Bearer <token>'},
  body: JSON.stringify({
    name: 'string',
    fields: [{fieldKey: 'string', isVisible: true, width: 1, position: 0}],
    filters: [{fieldKey: 'string', subField: 'string', operand: 'string', value: null}],
    sorts: [{fieldKey: 'string', subField: 'string', direction: 'asc'}],
    filterLogic: 'string'
  })
};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://api.cloudraker.com/spaces/<spaceId>/objects/<definitionId>/views/<viewId>"

payload = {
    "name": "string",
    "fields": [
        {
            "fieldKey": "string",
            "isVisible": True,
            "width": 1,
            "position": 0
        }
    ],
    "filters": [
        {
            "fieldKey": "string",
            "subField": "string",
            "operand": "string",
            "value": None
        }
    ],
    "sorts": [
        {
            "fieldKey": "string",
            "subField": "string",
            "direction": "asc"
        }
    ],
    "filterLogic": "string"
}
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <token>"
}

response = requests.patch(url, json=payload, headers=headers)

print(response.text)
```

## Responses

### 200

The updated view.

#### Example

```json
{
  "view": {
    "_id": "string",
    "spaceId": "string",
    "definitionId": "string",
    "name": "string",
    "isDefault": true,
    "filterLogic": "string",
    "fields": [
      {
        "fieldKey": "string",
        "isVisible": true,
        "width": 1,
        "position": 0
      }
    ],
    "filters": [
      {
        "fieldKey": "string",
        "subField": "string",
        "operand": "string",
        "value": null
      }
    ],
    "sorts": [
      {
        "fieldKey": "string",
        "subField": "string",
        "direction": "asc"
      }
    ],
    "createdAt": "2019-08-24T14:15:22Z",
    "updatedAt": "2019-08-24T14:15:22Z",
    "createdBy": "string"
  }
}
```

- `view` (`updateObjectView.response.200.view`; object, required)
  - `_id` (`updateObjectView.response.200.view._id`; string, required)
  - `spaceId` (`updateObjectView.response.200.view.spaceId`; string, required)
  - `definitionId` (`updateObjectView.response.200.view.definitionId`; string, required)
  - `name` (`updateObjectView.response.200.view.name`; string, required)
  - `isDefault` (`updateObjectView.response.200.view.isDefault`; boolean, required) — The seeded default view: never renamable, never deletable.
  - `filterLogic` (`updateObjectView.response.200.view.filterLogic`; string, required)
  - `fields` (`updateObjectView.response.200.view.fields`; array<object>, required)
    - `fieldKey` (`updateObjectView.response.200.view.fields.fieldKey`; string, required)
      - minLength 1
    - `isVisible` (`updateObjectView.response.200.view.fields.isVisible`; boolean, required)
    - `width` (`updateObjectView.response.200.view.fields.width`; number, required)
      - min 1
    - `position` (`updateObjectView.response.200.view.fields.position`; number, required)
  - `filters` (`updateObjectView.response.200.view.filters`; array<object>, required)
    - `fieldKey` (`updateObjectView.response.200.view.filters.fieldKey`; string, required)
      - minLength 1
    - `operand` (`updateObjectView.response.200.view.filters.operand`; string, required) — One of the 14 supported operands.
      - minLength 1
    - `subField` (`updateObjectView.response.200.view.filters.subField`; string, optional)
    - `value` (`updateObjectView.response.200.view.filters.value`; unknown, optional)
  - `sorts` (`updateObjectView.response.200.view.sorts`; array<object>, required)
    - `fieldKey` (`updateObjectView.response.200.view.sorts.fieldKey`; string, required)
      - minLength 1
    - `direction` (`updateObjectView.response.200.view.sorts.direction`; string, required)
      - one of `"asc"`, `"desc"`
    - `subField` (`updateObjectView.response.200.view.sorts.subField`; string, optional)
  - `createdAt` (`updateObjectView.response.200.view.createdAt`; string, required)
    - format `date-time`; pattern `^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z))$`
  - `updatedAt` (`updateObjectView.response.200.view.updatedAt`; string, required)
    - format `date-time`; pattern `^(?:(?:\d\d[2468][048]|\d\d[13579][26]|\d\d0[48]|[02468][048]00|[13579][26]00)-02-29|\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\d|30)|(?:02)-(?:0[1-9]|1\d|2[0-8])))T(?:(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z))$`
  - `createdBy` (`updateObjectView.response.200.view.createdBy`; string, required)

### 400

`default_view_not_renamable` — the default view cannot be renamed.

### 403

Missing `space:contribute`.

### 404

Unknown view (or missing `space:read`).

### 422

`validation_failed` — invalid body.


Source: https://docs.cloudraker.com/workspace/api/data-objects/update-object-view/index.md
