---
title: "Assign or update user model role"
method: POST
path: "/v1/users/{userId}/model-roles"
tags: ["User model roles"]
---

# Assign or update user model role

`POST /v1/users/{userId}/model-roles`

Assign or update a model role for a user. If the user already has a role for the specified model, this endpoint will update it to the new role.

Model roles control what actions a user can perform on models and connections. To manage users, see the [User APIs](/api/users).

## Path parameters

- `userId` string, uuid, required

## Request body

- object
  - `connectionId` string, uuid — The ID of the connection that the model belongs to: - **Required** if `modelId` is not provided - **Optional** if `modelId` is provided, in which case it will be inferred from the model
  - `modelId` string, uuid — The ID of the model to assign the role for: - **Optional** when assigning `CONNECTION_ADMIN` or [custom roles](/administration/users/custom-roles) with `CONNECTION_ADMIN` as the base role - **Required** for other role types
  - `roleName` string, required — The role to assign. Available roles include: - `VIEWER` - Can view the model - `QUERIER` - Can view and query the model - `QUERY_TOPICS` - Can query specific topics. Equivalent to **Restricted Querier**. - `MODELER` - Can edit and model the data - `CONNECTION_ADMIN` - Full administrative access to the connection - `NO_ACCESS` - No access to the model - [Custom roles](/administration/users/custom-roles) defined for your organization

## Response `200`

Model role assigned or updated successfully.

- object
  - `userId` string, uuid — The ID of the user.
  - `connectionId` string, uuid — The ID of the connection.
  - `modelId` string, uuid — The ID of the model.
  - `roleName` string — The assigned role name.

## Other responses

- `400` — Bad Request. Possible error messages include: - `Invalid JSON` - `Invalid model ID` - `Invalid connection ID` - `Method not allowed`
- `404` — Not Found. Possible error messages include: - `User not found in organization` - `Model does not exist` - `Connection does not exist`
- `422` — Unprocessable Entity. Possible error messages include: - `Invalid role` - `Model does not belong to connection` - `Only shared and shared_extension models can be assigned model roles`
- `429` — Too Many Requests - Rate limit exceeded (60 requests/minute)

---

[API](https://skmtc.net/omni/apis/omni-api.md) · [All operations](https://skmtc.net/omni/apis/omni-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/omni/omni-api/revisions/6b02f7349d0e/schema)
