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

# replaceUserApprovalAssignments

> Replaces a user's full set of roles and attributes in an authorization scope.

## Import

Call this method on a server-side ParaRestClient created with your server secret key.

```ts theme={null}
import { ParaRestClient } from "@getpara/rest-sdk";
```

async

Replaces a user's full set of roles and attributes in an authorization scope.

Copy method signature

### Returns

[`Promise<PermissionsV2AuthoritySetView>`](/v3/references/types/permissions#permissionsv2authoritysetview)

The saved assignments and their new revision.

## Route

Send `0` as `expectedRevision` for a user with no assignments yet. To give a user assignments, the user must have a wallet connected to your app. Removing every assignment works for any existing user.

```text theme={null}
PUT /v1/permissions-v2/authorization-scopes/{authorizationScopeId}/users/{userId}/assignments
```

> [!WARNING]
>
> Send every assignment the user should keep. Anything left out is removed, and an empty `assignments` array removes them all.

> [!NOTE]
>
> An approval case is open while it is `pending`, and after it completes until it is used to sign or expires. Para refuses a change that would invalidate open cases until you confirm it. A confirmed change ends those cases as `invalidated`, and their requests need a new attempt.
>
> Through the API, a refused change returns `409` with code `APPROVAL_CASES_AFFECTED` and the case IDs in `affectedCaseIds`, and nothing changes. To confirm it, send the same change again with `force: true`.
>
> In the REST SDK, the error is a `ParaRestError` with that `code`, and `ParaRestError.affectedCaseIds` lists the cases.

## Example

For the first write, send revision `0` and the complete assignment set to retain.

```ts theme={null}
const saved = await para.replaceUserApprovalAssignments(authorizationScopeId, userId, {
  expectedRevision: 0,
  assignments: [{ kind: "role", name: "finance-approver" }],
});
```

## Errors

A non-success response throws `ParaRestError` with the HTTP `status`, the error `code` and a `message`. [Permissions errors](/v3/references/permissions/errors) lists every error code.

An empty path argument throws `ParaRestValidationError` before the request is sent.

| Status | Code | When |
| - | - | - |
| 400 | `INVALID_REQUEST` | `userId` is not a UUID. |
| 400 | `INVALID_REQUEST` | A role or attribute is not declared by an active policy, or the user would hold more than 25 assignments. |
| 400 | `INVALID_REQUEST` | `assignments` is not empty and the user has no wallet connected to your app. The message is `user is not linked to this app`. |
| 403 | `PERMISSIONS_V2_EXTENSION_UNAVAILABLE` | Conditional approvals are not enabled for your API key. Contact Para to enable them. |
| 404 | `NOT_FOUND` | `assignments` is empty and the user does not exist. |
| 409 | `CONFLICT` | `expectedRevision` is not the current revision. Read the assignments again and retry. |
| 409 | `APPROVAL_CASES_AFFECTED` | The change would invalidate open approval cases. `affectedCaseIds` on the error lists them. Retry with `force: true` to apply the change. |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.