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

# Update Workspace User Role

> Requires `workspace-users-write`. Update a member's role.

# Update Workspace User Role

Change a member's role within a workspace.

## Authentication & Scope

Requires the `workspace-users-write` ability and **admin** privileges in the workspace.

## Request

```http theme={null}
PUT /open/workspaces/{workspaceId}/users/{userId}/update-role HTTP/1.1
Host: api.opnform.com
Content-Type: application/json
Authorization: Bearer <token>
```

### Path Parameters

| Parameter   | Type   | Description               |
| ----------- | ------ | ------------------------- |
| workspaceId | number | ID of the workspace.      |
| userId      | number | ID of the user to update. |

### Body Parameters

| Field | Type   | Required | Description                                |
| ----- | ------ | -------- | ------------------------------------------ |
| role  | string | Yes      | New role (`admin`, `user`, or `readonly`). |

Example:

```json theme={null}
{
  "role": "readonly"
}
```

## Response

`200 OK` – Confirmation message.

```json theme={null}
{
  "message": "User role changed successfully."
}
```

`403 Forbidden` – Token lacks `workspace-users-write` or you lack permission.


## OpenAPI

````yaml put /open/workspaces/{workspaceId}/users/{userId}/update-role
openapi: 3.0.1
info:
  title: OpnForm API
  description: API for interacting with OpnForm, primarily used for Zapier integration
  version: 1.0.0
servers:
  - url: https://api.opnform.com
security:
  - bearerAuth: []
tags:
  - name: Workspaces
    description: Create and manage workspaces.
  - name: Workspace Users
    description: Manage users within a workspace.
  - name: Forms
    description: Manage and retrieve forms.
  - name: Submissions
    description: Access and manage form submissions.
  - name: Integrations
    description: Manage form integrations (webhooks) via API.
  - name: Zapier
    description: Legacy endpoints for the Zapier integration.
paths:
  /open/workspaces/{workspaceId}/users/{userId}/update-role:
    put:
      tags:
        - Workspace Users
      summary: Update Workspace User Role
      description: Requires `workspace-users-write`. Update a member's role.
      parameters:
        - name: workspaceId
          in: path
          required: true
          schema:
            type: string
        - name: userId
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - role
              properties:
                role:
                  type: string
                  enum:
                    - admin
                    - user
                    - readonly
                  description: New role for the user.
      responses:
        '200':
          description: Role updated
        '403':
          description: Forbidden
      security:
        - bearerAuth: []
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Personal Access Token
      x-bearer-scopemap:
        workspaces-read: Read access to workspaces
        workspaces-write: Write access to workspaces
        workspace-users-read: Read access to workspace users
        workspace-users-write: Write access to workspace users
        forms-read: Read access to forms
        forms-write: Write access to forms
        manage-integrations: Manage form integrations (webhooks)

````