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

# Views

> Learn how to create and manage Views using the Fibery API.

Views API is provided at `https://YOUR_ACCOUNT.fibery.io/api/views/json-rpc`.

It follows the [JSON-RPC specification](https://www.jsonrpc.org/specification).

## Getting views

To get a list of Views, use the `query-views` method.

All filters and params are optional. If omitted, all Views will be returned.

<CodeGroup>
  ```javascript JavaScript theme={null}
  const response = await fetch('https://YOUR_ACCOUNT.fibery.io/api/views/json-rpc', {
    method: 'POST',
    headers: {
      'Authorization': 'Token YOUR_TOKEN',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      jsonrpc: '2.0',
      method: 'query-views',
      params: {
        filter: {
          ids: ['b190008d-3fef-4df5-b8b9-1b432a0e0f05', 'dd62b0df-537e-4c12-89f2-d937da128c7b'],
          publicIds: ['1001', '1002']
        }
      }
    })
  });
  const data = await response.json();
  ```

  ```bash cURL theme={null}
  curl -X POST https://YOUR_ACCOUNT.fibery.io/api/views/json-rpc \
    -H 'Authorization: Token YOUR_TOKEN' \
    -H 'Content-Type: application/json' \
    -d \
    '{
      "jsonrpc": "2.0",
      "method": "query-views",
      "params": {
        "filter": {
          "ids": ["b190008d-3fef-4df5-b8b9-1b432a0e0f05", "dd62b0df-537e-4c12-89f2-d937da128c7b"],
          "publicIds": ["1001", "1002"]
        }
      }
    }'
  ```
</CodeGroup>

Possible filters are:

|             |                                                                                           |                                                                                                                                                                                               |
| ----------- | ----------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `ids`       | array of UUID strings                                                                     | Matches views by the `fibery/id` field.                                                                                                                                                       |
| `publicIds` | array of numeric strings                                                                  | Matches views by the `fibery/public-id` field.                                                                                                                                                |
| `isPrivate` | `true` or `false`                                                                         | If true, return only matching views from "My space". If false, return only matching views outside of "My space". If omitted, matching views both from and outside of "My space" are returned. |
| `container` | `{type: "entity"; typeId: "6ded97e6-b4ca-4a8c-a740-6c34c3651cd1"; publicIds: ["1", "2"]}` | If provided, the query will return only views attached to entities with the given public ids in the database (type) with the given typeId.                                                    |

## **Creating views**

To create one or more Views, use the `create-views` method:

"Container app" in this example contains a `fibery/id` reference to the space where the new View is to be created.

<CodeGroup>
  ```javascript JavaScript theme={null}
  const response = await fetch('https://YOUR_ACCOUNT.fibery.io/api/views/json-rpc', {
    method: 'POST',
    headers: {
      'Authorization': 'Token YOUR_TOKEN',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      jsonrpc: '2.0',
      method: 'create-views',
      params: {
        views: [
          {
            'fibery/id': '3541bdf6-ab15-4d5e-b17b-eb124b8fe2f7',
            'fibery/name': 'My Board',
            'fibery/type': 'board',
            'fibery/meta': {},
            'fibery/container-app': {
              'fibery/id': '760ee2e2-e8ca-4f92-aaf2-4cde7f9dad0e'
            }
          }
        ]
      }
    })
  });
  const data = await response.json();
  ```

  ```bash cURL theme={null}
  curl -X POST https://YOUR_ACCOUNT.fibery.io/api/views/json-rpc \
    -H 'Authorization: Token YOUR_TOKEN' \
    -H 'Content-Type: application/json' \
    -d \
    '{
      "jsonrpc": "2.0",
      "method": "create-views",
      "params": {
        "views": [
          {
            "fibery/id": "3541bdf6-ab15-4d5e-b17b-eb124b8fe2f7",
            "fibery/name": "My Board",
            "fibery/type": "board",
            "fibery/meta": {},
            "fibery/container-app": {
              "fibery/id": "760ee2e2-e8ca-4f92-aaf2-4cde7f9dad0e"
            }
          }
        ]
      }
    }'
  ```
</CodeGroup>

## Updating views

To update one or more Views, use the `update-views` method:

<CodeGroup>
  ```javascript JavaScript theme={null}
  const response = await fetch('https://YOUR_ACCOUNT.fibery.io/api/views/json-rpc', {
    method: 'POST',
    headers: {
      'Authorization': 'Token YOUR_TOKEN',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      jsonrpc: '2.0',
      method: 'update-views',
      params: {
        updates: [
          {
            id: '3541bdf6-ab15-4d5e-b17b-eb124b8fe2f7',
            values: {
              'fibery/name': 'My Updated Board',
              'fibery/meta': {}
            }
          }
        ]
      }
    })
  });
  const data = await response.json();
  ```

  ```bash cURL theme={null}
  curl -X POST https://YOUR_ACCOUNT.fibery.io/api/views/json-rpc \
    -H 'Authorization: Token YOUR_TOKEN' \
    -H 'Content-Type: application/json' \
    -d \
    '{
      "jsonrpc": "2.0",
      "method": "update-views",
      "params": {
        "updates": [
          {
            "id": "3541bdf6-ab15-4d5e-b17b-eb124b8fe2f7",
            "values": {
              "fibery/name": "My Updated Board",
              "fibery/meta": {}
            }
          }
        ]
      }
    }'
  ```
</CodeGroup>

## Deleting views

To delete one or more Views, use the `delete-views` method:

<CodeGroup>
  ```javascript JavaScript theme={null}
  const response = await fetch('https://YOUR_ACCOUNT.fibery.io/api/views/json-rpc', {
    method: 'POST',
    headers: {
      'Authorization': 'Token YOUR_TOKEN',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      jsonrpc: '2.0',
      method: 'delete-views',
      params: {
        ids: ['3541bdf6-ab15-4d5e-b17b-eb124b8fe2f7']
      }
    })
  });
  const data = await response.json();
  ```

  ```bash cURL theme={null}
  curl -X POST https://YOUR_ACCOUNT.fibery.io/api/views/json-rpc \
    -H 'Authorization: Token YOUR_TOKEN' \
    -H 'Content-Type: application/json' \
    -d \
    '{
      "jsonrpc": "2.0",
      "method": "delete-views",
      "params": {
        "ids": ["3541bdf6-ab15-4d5e-b17b-eb124b8fe2f7"]
      }
    }'
  ```
</CodeGroup>
