> ## 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 Kotlin, and transfer ownership.

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

Members control who can administer the account. That is separate from [who can sign](/docs/kotlin/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.

```kotlin theme={"system"}
import com.dynamic.sdk.android.DynamicSDK
import com.dynamic.sdk.android.Models.BusinessAccountMemberRole
import com.dynamic.sdk.android.Models.BusinessAccountSignerIdentifierType

val sdk = DynamicSDK.getInstance()

val member = sdk.businessAccounts.addMember(
    businessAccountId = account.id,
    identifier = "admin@acme.com",
    identifierType = BusinessAccountSignerIdentifierType.email,
    role = BusinessAccountMemberRole.admin
)

println(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.

```kotlin theme={"system"}
val detail = sdk.businessAccounts.get(businessAccountId = account.id)

detail.members.forEach { member ->
    println("${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.

```kotlin theme={"system"}
val updated = sdk.businessAccounts.updateMemberRole(
    businessAccountId = account.id,
    userId = member.userId,
    role = BusinessAccountMemberRole.viewer
)
```

## Remove a member

```kotlin theme={"system"}
val removed = sdk.businessAccounts.removeMember(
    businessAccountId = account.id,
    userId = member.userId
)
```

<Tip>
  Removing a member also tears down any [signer](/docs/kotlin/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.

```kotlin theme={"system"}
val detail = 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/kotlin/business-accounts/manage-signers">
    Grant and revoke signing access per wallet.
  </Card>

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