# Manage members

Change a member's organization role, sign a member out everywhere, or remove a member from the organization.

Members are the people who sign in with their own email address. Replace member-id with the
membership's id from `dcloud iam members list`.

## Prerequisites

- To change a role, `iam:UpdateMember`. To remove a member, `iam:RemoveMember`.
- `iam:ListMembers` to open **Members** in the console and to find the id with
  `dcloud iam members list`.
- To list a member's sessions, `iam:ListUserSessions`, and to sign them out,
  `iam:RevokeUserSessions`, both on the member's IAM user.

## Change a member's role

The organization role is a label for the member's standing in the organization. Changing it
attaches and detaches no policy: what the member may do stays what their IAM user's policies say.
To change that, see [Attach a policy](attach-a-policy.md).

**Console**
1. Open **Settings**, then choose **Members**.
2. In the member's **Role** column, choose **Admin**, **Member**, **Viewer** or **Billing**. The
   choice is saved at once.

The console offers no role list for a member who joined with no preset; give them a role with the
CLI or the API.

**CLI**
```sh
dcloud iam members set-role member-id --role viewer
```

**API**
```http
PATCH /iam/api/members/9b2e4c1a-7d3f-4e8a-b6c5-0a1b2c3d4e5f
{ "role": "viewer" }
```

The owner's role cannot be changed: 400 `Cannot change the role of the org owner`.

## Sign a member out everywhere

This ends every console session of the person's account, also the ones they use for their other
organizations, and disconnects the apps they connected to your organization. On the command line
it acts in your organization only: it ends their CLI sessions here and blocks every CLI device of
theirs here, which keep working in their other organizations (see
[Manage a member's CLI devices](manage-a-members-cli-devices.md) to unblock one). Their access keys are separate credentials and keep working; deactivate them under
**Access keys** (see [Manage access keys](manage-access-keys.md)). The member is sent an email, and
their browser is told an administrator signed them out.

**Console:** not available. The console has no control for this; use the CLI or the API.

**CLI**
```sh
dcloud iam members sessions member-id
dcloud iam members revoke-sessions member-id
```

**API**
```http
POST /iam/api/members/9b2e4c1a-7d3f-4e8a-b6c5-0a1b2c3d4e5f/revoke-sessions
```

The answer says how many sessions ended (`sessionsEnded`) and how many apps were disconnected
(`appsDisconnected`). An id that is not a member of your organization answers 404 `Member not
found`.

## Remove a member

**Warning:**
The member loses all access to the organization at once.

**Console**
1. Open **Settings**, then choose **Members**.
2. In the member's row menu, choose **Remove from organization**.
3. Choose **Remove**.

**CLI**
```sh
dcloud iam members remove member-id
```

**API**
```http
DELETE /iam/api/members/9b2e4c1a-7d3f-4e8a-b6c5-0a1b2c3d4e5f
```

### Result

- The membership is suspended and the member's IAM user becomes inactive; the IAM users list shows it
  as **Former member**.
- Its access keys are switched off, and so is any console password the IAM user had, whose sessions
  end. The apps the person connected to your organization are disconnected.
- Their own account and their other organizations are not affected.

To give the person access again, invite them again; see [Invite a person](invite-a-person.md).

The owner cannot be removed: 400 `Cannot remove the org owner`. An unknown member answers 404
`Member not found`.

## Related

- [Invite a person](invite-a-person.md)
- [Principals and policies](principals-and-policies.md)
- `dcloud iam members remove` · `iam.members.revoke-sessions`
