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

# Members and Roles

> Administer who can manage a business account from Flutter, and transfer ownership.

<Note>
  Business Accounts are in **early access**. See the [overview](/docs/flutter/business-accounts/overview) for the model.
</Note>

Members control who can administer the account. That is separate from [who can sign](/docs/flutter/business-accounts/manage-signers). `BusinessAccountMemberRole` has three values:

| Role     | Can do                                                                 |
| -------- | ---------------------------------------------------------------------- |
| `owner`  | Everything, including transferring ownership. Exactly one per account. |
| `admin`  | Add and remove members and signers, and link wallets.                  |
| `viewer` | Read-only access.                                                      |

<Info>
  Adding someone as a member does not let them sign, and adding a signer does not grant admin rights. Grant each explicitly.
</Info>

## Add a member

`addMember` adds a member as `admin` or `viewer` (it defaults to `viewer`). Identify them with a known `userId`, or with an `identifier` plus `identifierType`, in which case the user is created if they do not exist yet.

```dart theme={"system"}
import 'package:dynamic_sdk/dynamic_sdk.dart';

final sdk = DynamicSDK.instance;

final member = await sdk.businessAccounts.addMember(
  businessAccountId: account.id,
  identifier: 'admin@acme.com',
  identifierType: BusinessAccountSignerIdentifierType.email,
  role: BusinessAccountMemberRole.admin,
);

print(member.userId);
```

<ParamField path="businessAccountId" type="String" required>
  The account to add the member to.
</ParamField>

<ParamField path="userId" type="String?">
  A known Dynamic user ID. Use this instead of `identifier`.
</ParamField>

<ParamField path="identifier" type="String?">
  An email, phone number, or other identifier for the user.
</ParamField>

<ParamField path="identifierType" type="BusinessAccountSignerIdentifierType?">
  How to read `identifier`: `email`, `phoneNumber`, `externalUserId`, `socialUsername`, `socialAccountId`, or `id`.
</ParamField>

<ParamField path="role" type="BusinessAccountMemberRole?">
  `admin` or `viewer`. Defaults to `viewer`.
</ParamField>

## List members

`get` returns the account with its members, including each member's role.

```dart theme={"system"}
final detail = await sdk.businessAccounts.get(
  businessAccountId: account.id,
);

for (final member in detail.members) {
  print('${member.userId}: ${member.role.name}');
}
```

## Change a member's role

`updateMemberRole` moves a member between `admin` and `viewer`. To change who the owner is, transfer ownership instead.

```dart theme={"system"}
final updated = await sdk.businessAccounts.updateMemberRole(
  businessAccountId: account.id,
  userId: member.userId,
  role: BusinessAccountMemberRole.viewer,
);
```

## Remove a member

```dart theme={"system"}
final removed = await sdk.businessAccounts.removeMember(
  businessAccountId: account.id,
  userId: member.userId,
);
```

<Tip>
  Removing a member also tears down any [signer](/docs/flutter/business-accounts/manage-signers) entries they held on the account's wallets, so they lose signing access too, not just admin rights.
</Tip>

## Transfer ownership

`transferOwnership` promotes an existing member to owner and demotes the current owner to `admin` in the same operation. Owner only.

```dart theme={"system"}
final detail = await sdk.businessAccounts.transferOwnership(
  businessAccountId: account.id,
  newOwnerUserId: newOwnerUserId,
);
```

<Warning>
  Transferring ownership revokes the caller's session server-side, because their scope changed from owner to admin. The previous owner is signed out and must re-authenticate to pick up the new role. The new owner must already be a member.
</Warning>

## Next steps

<CardGroup cols={2}>
  <Card title="Manage signers" icon="key" href="/docs/flutter/business-accounts/manage-signers">
    Grant and revoke signing access per wallet.
  </Card>

  <Card title="Sign transactions" icon="signature" href="/docs/flutter/business-accounts/signing">
    Sign with a business-account wallet.
  </Card>
</CardGroup>
