---
title: "Give an account a role, or switch it off"
type: reference
method: POST
path: /rest-api/system-users/{userId}/access.do
tag: "Users"
---

# Give an account a role, or switch it off

`POST https://YOUR-NETWORK-DOMAIN/rest-api/system-users/{userId}/access.do`

Changes which role an account holds and whether it is switched on, and nothing else: the fields the call does not name are left exactly as they are. The role has to be one the caller may hand out (Create on it, as on the console's user form) and so does the account's current role, otherwise the call is refused and nothing changes -- which is what stops an account being taken over by re-saving it under a role the caller may hand out. The read's 'changeable' and 'assignableRoles' answer both questions before the call. Switching an account on or off sends the same activation or deactivation mail the console sends. A profile field other than these two is changed with user/update.do. No credential is part of this: a password cannot be set, reset or changed here, and no API key is issued. Requires the User Management console permission.

## Path params

| Name | Type | Required | Example | Description |
|---|---|---|---|---|
| `userId` | integer | yes | `42` | Numeric id of the user, as system-users/search.do reports it |

## Form params

| Name | Type | Required | Example | Description |
|---|---|---|---|---|
| `role` | string | no | `4` | The role to give the account: its id, or its name as roles.do spells it |
| `active` | boolean | no | `true` | Whether the account is switched on; off, it cannot sign in |

## Responses

- `200` — {success, changed:[...], and the account as the read answers it}
- `400` — 'role' names no role, or neither field was sent
- `401` — Authentication error
- `403` — The caller does not hold User Management, or may not hand out that role or change that account
- `404` — No user with that id

## Example request

```bash
curl --request POST \
  --url 'https://YOUR-NETWORK-DOMAIN/rest-api/system-users/42/access.do' \
  --header 'X-Api-Key: YOUR_API_KEY' \
  --header 'Content-Type: application/x-www-form-urlencoded' \
  --data-urlencode 'active=true' \
  --data-urlencode 'role=4'
```

Source: https://epom.com/ad-server/docs/api/users/post-system-users-access