---
search:
  tags:
    - Views
    - PUT
seo:
  description: >-
    Add and remove a View's grants and set its restriction, then list who it…
    Reference for the PUT /v1/views/id/{view_id}/access endpoint in the Roboto
    REST API.
sidebar:
  label: Edit view access
  badge: PUT
title: Edit view access
type: openapi-operation
---
Add and remove a View's grants and set its restriction, then list who it is shared with.

Grantable roles are ``viewer`` and ``editor``; a new ``deleter`` grant is refused with 400,
and an existing one may be removed. The author and the owning org are fixed when the View is
created and cannot be changed here.

Which permission a request needs depends on what it changes:

- Setting the restriction makes the View visible only to its author, the org's admins and
  owners and the holders of its grants, or visible to every member of the org. Only the author
  and the org's admins and owners may set it.
- Adding or removing a grant requires permission to change the View, which its author, the
  org's admins and owners and the holders of an ``editor`` or ``deleter`` grant have. An
  editor can therefore hand out access, edit rights included, without controlling who can see
  the View.

A request that does both must satisfy both, and a request refused by either check changes
nothing; a refused check answers 401. A View that does not exist, or that belongs to an org the
caller may not work in, answers 404.

From API version 2026-11-19 the body is an ``EditRecordAccessRequest``: grants to add and to
remove, and ``restricted``. The response is as from ``GET`` on the same route. A request that
changes nothing answers as ``GET`` does and requires only permission to see the View. Refused
with 400 when a grant names an unknown subject kind or role, a ``user``, ``group`` or
``org_members`` subject without an id, or an ``everyone`` subject with an id or a role other
than ``viewer``, or when a grant in ``add`` names the members of another org.

On older API versions the body is an ``EditAccessRequest`` of OpenFGA tuples, each naming a
user or group, a relation and the View, and the response is the View's tuples, as from
``GET``. Adding or removing the org's all-members group as ``associated_group`` is how such a
request sets the restriction, and a request that changes nothing needs neither permission.
Refused with 401 when a tuple names a relation other than ``viewer``, ``editor``, ``deleter``
and ``associated_group``, or another record; refused with 400 when an added tuple names a
subject in a form no share takes, the members of another org, or a group other than the
View's own org group as ``associated_group``.

In either version, a grant in ``add`` that names a group is refused in two more cases: with 401
unless Roboto has turned groups on for the View's org, and with 400 when the group is neither
one of the View's org's groups nor a system group, one Roboto made rather than an org's admins.

#### Access control
 - Restricted tokens need the API scope `api.everything_else`

`PUT /v1/views/id/{view_id}/access`

**Request body** (`application/json`, required)

- `add` (GrantBody[])
- `remove` (GrantBody[])
- `restricted` (boolean | null)

Request body example:

```json
{
  "add": [
    {
      "subject": {
        "kind": "string",
        "id": null
      },
      "role": "string"
    }
  ],
  "remove": [
    {
      "subject": {
        "kind": "string",
        "id": null
      },
      "role": "string"
    }
  ],
  "restricted": null
}
```

**Responses**

- `200` — OK
- `400` — A conversation with Roboto's AI is longer than the AI model can read at once. The conversation's messages and tool results, together with the AI's instructions, exceed the model's context window. The exception does not carry the token count or the model's limit.
- `401` — The caller's token is expired or malformed.
- `403` — The request would take the user or organization past a limit on a resource, such as AI credits.
- `404` — The request names an API route Roboto does not serve.
- `409` — The request conflicts with an existing resource, such as by giving a name another resource already has.
- `410` — The resource the request names is missing or has expired.
- `500` — Roboto reported an error that this release of the SDK cannot match to a specific exception class. Reported for an element of a :py:class:\`\~roboto.http.BatchResponse\` whose error names a code this release defines no class for, or that arrived without a code, without a message, or as text that is not an error envelope at all. It carries whatever code and message Roboto sent, so a caller handling the failure still learns what went wrong; when no message could be read, the message is the error's raw text. :py:meth:\`\~roboto.domain.devices.Device.create\_session\` raises it, and :py:meth:\`\~roboto.domain.devices.Device.create\_sessions\` lists it in the batch's :py:attr:\`\~roboto.http.BatchResponse.failed\`. The error envelope carries no status code, so \`\`http\_status\_code\`\` reports the 500 inherited from \`\`RobotoDomainException\`\` rather than the status the failure had.
- `501` — The request asks for an operation this deployment of Roboto does not provide.
- `503` — Roboto could not accept the request, such as under heavy load. Retrying later may succeed.
- `504` — Roboto ran out of time while processing the request. Retrying may succeed.
- `507` — The response to the request is larger than Roboto can send. Retrying the same request fails the same way; request less data at a time.

Response example, 200:

```json
{
  "data": {
    "restricted": true,
    "grants": [
      {
        "subject": {
          "kind": "user",
          "id": null
        },
        "role": "viewer"
      }
    ]
  }
}
```
