# Grant project access

> Grant a principal that has signed in at least once a role on the project, or change the one it has, reaching every computer and database in the project with no workspace role needed.

> Nevia is in early access for selected teams. The CLI installs with `curl -fsSL https://get.nevia.cloud | sh`, and the MCP server is at https://api.nevia.cloud/mcp. A person signs in once in the browser.
> Setup, sign-in and requesting access: [SKILL.md](https://nevia.cloud/SKILL.md). When Nevia fits and when it doesn't: [why.md](https://nevia.cloud/why.md).

> For the complete documentation index, see [llms.txt](https://nevia.cloud/llms.txt). This page's HTML version: https://nevia.cloud/docs/reference/api/projects/updateProjectAccess

`PUT https://api.nevia.cloud/v1/projects/{prj}/access/{principal}`

## Authorization

- `bearerAuth`: HTTP bearer in the Authorization header

Send the token in the `Authorization: Bearer <token>` header. See [Authenticate](https://nevia.cloud/docs/reference/api.md#authenticate).

## Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `prj` | path | string | yes | Project id: 27 lowercase letters and digits. Match `^[A-Za-z0-9_-]{1,64}$`. |
| `principal` | path | string | yes | Principal id: 27 lowercase letters and digits. Match `^[A-Za-z0-9_-]{1,64}$`. |

## Request body

Content type: `application/json`, required

Schema: `ProjectAccessRequest`

| Field | Type | Required | Description |
|---|---|---|---|
| `role` | string | yes | Role on a project: `editor` creates, changes and deletes its resources, `viewer` reads them. One of `editor` · `viewer`. |

## Example request

### cURL

```bash
curl -X PUT "https://api.nevia.cloud/v1/projects/01ck8y1dm5qqnf88mytnh4m0h4g/access/01d4cnjmn4fbb1r5btxb5mypv62" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "role": "viewer"
  }'
```

### JavaScript

```js
const body = JSON.stringify({
  "role": "viewer"
})

fetch("https://api.nevia.cloud/v1/projects/01ck8y1dm5qqnf88mytnh4m0h4g/access/01d4cnjmn4fbb1r5btxb5mypv62", {
  method: "PUT",
  headers: {
    "Content-Type": "application/json",
    "Authorization": `Bearer ${process.env.TOKEN}`
  },
  body
})
```

### Python

```python
import os
import requests

url = "https://api.nevia.cloud/v1/projects/01ck8y1dm5qqnf88mytnh4m0h4g/access/01d4cnjmn4fbb1r5btxb5mypv62"
body = """{
  "role": "viewer"
}"""
response = requests.request("PUT", url, data = body, headers = {
  "Content-Type": "application/json", 
  "Authorization": f"Bearer {os.environ['TOKEN']}"
})

print(response.text)
```

## Responses

### 200

The grant.

Content type: `application/json`

Schema: `ProjectAccessResponse`

| Field | Type | Required | Description |
|---|---|---|---|
| `access` | ProjectAccess | yes | A principal's grant on one project, beside any workspace role it holds. |
| `operations` | array<OperationId> | no | Present only when this request schedules asynchronous work. Absent for synchronous responses. |

Example:

```json
{
  "access": {
    "project": "01ck8y1dm5qqnf88mytnh4m0h4g",
    "principal": {
      "id": "01d4cnjmn4fbb1r5btxb5mypv62",
      "auth": "email",
      "email": "string",
      "name": "string"
    },
    "role": "editor",
    "created_at": "2026-09-10T12:34:56Z",
    "updated_at": "2026-09-10T12:34:56Z"
  },
  "operations": [
    "01d4cnjm89yk0r3xtv80dy0x7by"
  ]
}
```

### 400

`validation_failed`: malformed body, unknown field, or invalid id or name. Fix `details.field` and retry.

Content type: `application/json`

Schema: `ErrorEnvelope`

Body of every error response

| Field | Type | Required | Description |
|---|---|---|---|
| `error` | Error | yes |  |

Example `validation_failed`:

```json
{
  "error": {
    "code": "validation_failed",
    "message": "Unknown field `colour` in the request body. Remove it; request bodies are strict.",
    "details": {
      "field": "colour",
      "in": "body"
    }
  }
}
```

### 401

`unauthorized`: the credential is missing, malformed, expired, or revoked. Send a valid bearer token.

Content type: `application/json`

Schema: `ErrorEnvelope`

Body of every error response

| Field | Type | Required | Description |
|---|---|---|---|
| `error` | Error | yes |  |

Example `unauthorized`:

```json
{
  "error": {
    "code": "unauthorized",
    "message": "Missing credential. Send `Authorization: Bearer <token>` with an access token.",
    "details": {}
  }
}
```

### 403

`forbidden`: the token is read-only or scoped elsewhere, or the role cannot do this. Use a token or role that allows it.

Content type: `application/json`

Schema: `ErrorEnvelope`

Body of every error response

| Field | Type | Required | Description |
|---|---|---|---|
| `error` | Error | yes |  |

Example `forbidden`:

```json
{
  "error": {
    "code": "forbidden",
    "message": "You can view computer 01d4cnjk3xg90y576w8y6t4gdwm but your role does not allow computer#edit. Ask a workspace admin to change your role (PATCH /v1/workspaces/{ws}/access/{principal}).",
    "details": {
      "computer": "01d4cnjk3xg90y576w8y6t4gdwm",
      "permission": "computer#edit"
    }
  }
}
```

### 404

`not_found`: the project does not exist, or you cannot see it. Both return the same response. `not_found`: the principal has never signed in. `not_found`: the principal is a private key of another workspace.

Content type: `application/json`

Schema: `ErrorEnvelope`

Body of every error response

| Field | Type | Required | Description |
|---|---|---|---|
| `error` | Error | yes |  |

Example `not_found: the project does not exist, or you cannot see it. Both return the same response`:

```json
{
  "error": {
    "code": "not_found",
    "message": "Project 01ck8y1dm5qqnf88mytnh4m0h4g was not found. List the projects you can access with GET /v1/projects?workspace=<ws>.",
    "details": {
      "project": "01ck8y1dm5qqnf88mytnh4m0h4g"
    }
  }
}
```

Example `not_found: the principal has never signed in`:

```json
{
  "error": {
    "code": "not_found",
    "message": "Principal 01d4cnjmn4fbb1r5btxb5mypv62 was not found. They have to sign in once before they can be given access to a project.",
    "details": {
      "principal": "01d4cnjmn4fbb1r5btxb5mypv62"
    }
  }
}
```

Example `not_found: the principal is a private key of another workspace`:

```json
{
  "error": {
    "code": "not_found",
    "message": "Principal 01d4cnjmn4fbb1r5btxb5mypv62 was not found. A private-key principal can only be given access to projects in its own workspace.",
    "details": {
      "principal": "01d4cnjmn4fbb1r5btxb5mypv62"
    }
  }
}
```

### 429

`rate_limited`: slow down. Retry after `Retry-After`.

Content type: `application/json`

Schema: `ErrorEnvelope`

Body of every error response

| Field | Type | Required | Description |
|---|---|---|---|
| `error` | Error | yes |  |

Example `rate_limited`:

```json
{
  "error": {
    "code": "rate_limited",
    "message": "Too many requests. Retry after 2 seconds.",
    "details": {
      "retry_after_seconds": 2
    }
  }
}
```

### 500

`request_failed`, or the failed action's own code, such as `creation_failed`, `authorization_failed` or `command_execution_failed`. The diagnostic stays in server logs.

Content type: `application/json`

Schema: `ErrorEnvelope`

Body of every error response

| Field | Type | Required | Description |
|---|---|---|---|
| `error` | Error | yes |  |

Example `request_failed`:

```json
{
  "error": {
    "code": "request_failed",
    "message": "request failed",
    "details": {}
  }
}
```

### 503

The action is temporarily unavailable, named by its code (`creation_failed`, `wake_failed`, ...). Wait at least `Retry-After` seconds (60 by default). `details.retryable` says whether repeating the request is safe. Keep the original `Idempotency-Key`. Signing in again does not help.

Content type: `application/json`

Schema: `ErrorEnvelope`

Body of every error response

| Field | Type | Required | Description |
|---|---|---|---|
| `error` | Error | yes |  |

Example `creation_failed`:

```json
{
  "error": {
    "code": "creation_failed",
    "message": "The computer could not be created. Try again later.",
    "details": {
      "retryable": true
    }
  }
}
```
