# Change a database's views

`POST /v1/databases/{databaseId}/views/change`

Adds, changes and removes views in one step. config is merged into the view's config (filter, sorts, groupBy, columns, …); see get_database for the current values.

Scope: `docs:write`. Undoable.

## Request

```bash
curl -X POST "https://api.lydie.co/v1/databases/01JCQ3V5MZ8G4ZK2X7T9R6N1PB/views/change" \
  -H "Authorization: Bearer $LYDIE_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{}'
```

## Path parameters

- `databaseId` (ULID, required)

## Body

- `add` (object[], optional): Default: `[]`.
  - `name` (string, required): (1–200 chars)
  - `type` (string, required): One of: `table`, `board`, `list`, `calendar`, `gallery`.
  - `config` (ViewConfigPatchInput, optional)
    - `filter` (FilterNode, optional, nullable)
    - `sorts` (object[], optional)
      - `propertyId` (ULID, required)
      - `direction` (string, optional): One of: `asc`, `desc`. Default: `"asc"`.
    - `groupBy` (GroupByInput, optional, nullable)
      - `propertyId` (ULID, required)
      - `direction` (string, optional): One of: `asc`, `desc`. Default: `"asc"`.
      - `order` (string[], optional)
      - `hideEmpty` (boolean, optional): Hide groups with no rows (board columns).
      - `dateBucket` (string, optional): Date grouping; default month. One of: `day`, `week`, `month`, `year`.
      - `collapsed` (string[], optional)
    - `subGroupBy` (GroupByInput, optional, nullable): Board swimlanes.
      - `propertyId` (ULID, required)
      - `direction` (string, optional): One of: `asc`, `desc`. Default: `"asc"`.
      - `order` (string[], optional)
      - `hideEmpty` (boolean, optional): Hide groups with no rows (board columns).
      - `dateBucket` (string, optional): Date grouping; default month. One of: `day`, `week`, `month`, `year`.
      - `collapsed` (string[], optional)
    - `columns` (ViewColumnInput[], optional)
      - `propertyId` (ULID, required)
      - `visible` (boolean, optional): Default: `true`.
      - `width` (integer, optional): (20–2000)
    - `limit` (integer, optional, nullable): (≥ 1)
    - `summaries` (object, optional): propertyId → summary name
    - `layout` (ViewLayoutInput, optional)
      - `rowHeight` (string, optional): table One of: `short`, `medium`, `tall`, `extra`.
      - `wrapCells` (boolean, optional): table
      - `cardSize` (integer, optional): board, gallery: px (50–1000)
      - `cover` (object, optional, nullable): board, gallery: the card image
      - `coverFit` (string, optional): One of: `cover`, `contain`.
      - `coverAspectRatio` (number, optional): (0.1–10)
      - `markers` (string, optional): list One of: `bullet`, `number`, `none`.
      - `calendarPropertyId` (ULID, optional): calendar: the date property placing rows
      - `calendarMode` (string, optional): One of: `month`, `week`.
      - `showWeekends` (boolean, optional)
      - `colorColumns` (boolean, optional): board
    - `extra` (object, optional)
- `update` (object[], optional): Default: `[]`.
  - `view` (string, required): A view's id or name (case-insensitive). (≥ 1 chars)
  - `name` (string, optional): (1–200 chars)
  - `type` (string, optional): One of: `table`, `board`, `list`, `calendar`, `gallery`.
  - `config` (ViewConfigPatchInput, optional)
    - `filter` (FilterNode, optional, nullable)
    - `sorts` (object[], optional)
      - `propertyId` (ULID, required)
      - `direction` (string, optional): One of: `asc`, `desc`. Default: `"asc"`.
    - `groupBy` (GroupByInput, optional, nullable)
      - `propertyId` (ULID, required)
      - `direction` (string, optional): One of: `asc`, `desc`. Default: `"asc"`.
      - `order` (string[], optional)
      - `hideEmpty` (boolean, optional): Hide groups with no rows (board columns).
      - `dateBucket` (string, optional): Date grouping; default month. One of: `day`, `week`, `month`, `year`.
      - `collapsed` (string[], optional)
    - `subGroupBy` (GroupByInput, optional, nullable): Board swimlanes.
      - `propertyId` (ULID, required)
      - `direction` (string, optional): One of: `asc`, `desc`. Default: `"asc"`.
      - `order` (string[], optional)
      - `hideEmpty` (boolean, optional): Hide groups with no rows (board columns).
      - `dateBucket` (string, optional): Date grouping; default month. One of: `day`, `week`, `month`, `year`.
      - `collapsed` (string[], optional)
    - `columns` (ViewColumnInput[], optional)
      - `propertyId` (ULID, required)
      - `visible` (boolean, optional): Default: `true`.
      - `width` (integer, optional): (20–2000)
    - `limit` (integer, optional, nullable): (≥ 1)
    - `summaries` (object, optional): propertyId → summary name
    - `layout` (ViewLayoutInput, optional)
      - `rowHeight` (string, optional): table One of: `short`, `medium`, `tall`, `extra`.
      - `wrapCells` (boolean, optional): table
      - `cardSize` (integer, optional): board, gallery: px (50–1000)
      - `cover` (object, optional, nullable): board, gallery: the card image
      - `coverFit` (string, optional): One of: `cover`, `contain`.
      - `coverAspectRatio` (number, optional): (0.1–10)
      - `markers` (string, optional): list One of: `bullet`, `number`, `none`.
      - `calendarPropertyId` (ULID, optional): calendar: the date property placing rows
      - `calendarMode` (string, optional): One of: `month`, `week`.
      - `showWeekends` (boolean, optional)
      - `colorColumns` (boolean, optional): board
    - `extra` (object, optional)
- `remove` (string[], optional): Default: `[]`.

## Response

- `id` (ULID, required)
- `properties` (object[], required)
  - `id` (ULID, required)
  - `name` (string, required)
  - `type` (string, required): One of: `title`, `text`, `number`, `select`, `multiSelect`, `status`, `date`, `checkbox`, `url`, `email`, `phone`, `person`, `files`, `relation`, `rollup`, `formula`, `uniqueId`, `createdTime`, `updatedTime`, `createdBy`, `updatedBy`.
  - `key` (string, required)
- `views` (object[], required)
  - `id` (ULID, required)
  - `name` (string, required)
  - `type` (string, required): One of: `table`, `board`, `list`, `calendar`, `gallery`.

```json
{
  "id": "01JCQ3V5MZ8G4ZK2X7T9R6N1PB",
  "properties": [
    {
      "id": "01JCQ3V5MZ8G4ZK2X7T9R6N1PB",
      "name": "Notes",
      "type": "title",
      "key": "string"
    }
  ],
  "views": [
    {
      "id": "01JCQ3V5MZ8G4ZK2X7T9R6N1PB",
      "name": "Notes",
      "type": "table"
    }
  ]
}
```

Errors use the envelope described at https://developers.lydie.co/errors.md.
