---
title: "Members"
description: "`members.list`, `list_all`, `iterate`, `get`, `add`, `update`, `remove`, `grant_address`, `revoke_address`, and the invitation methods beside them."
url: "https://openemail.uk/docs/python/members"
area: "Python"
category: "Mailbox"
---

# Members

`members.list`, `list_all`, `iterate`, `get`, `add`, `update`, `remove`, `grant_address`, `revoke_address`, and the invitation methods beside them.

## Every method

**members.py**

```
from openemail import openemail

roles = openemail.roles.list_all()
support = next(role for role in roles if role['name'] == 'Support')
viewer = next(role for role in roles if role['builtin'] == 'viewer')

invitation = openemail.members.add({
    'email': 'sam@acme.com',
    'roleId': support['id'],
    'addressIds': ['2b81de07-…'],
    'access': 'member',
})

people = openemail.members.list_all()
sam = next(person for person in people if person['email'] == 'sam@acme.com')
member = openemail.members.get(sam['userId'])

openemail.members.update(sam['userId'], {'roleId': viewer['id']})

openemail.members.grant_address(sam['userId'], {
    'addressId': 'c40a95f2-…',
    'access': 'viewer',
})
openemail.members.revoke_address(sam['userId'], 'c40a95f2-…')

openemail.members.remove(sam['userId'])
```

Two grants per person and they must not be collapsed. `role` is what they may do; `addresses` is what they may do it to. Both have to agree: a role holding `emails:send` with `'access': 'viewer'` on invoices@ is somebody who may send mail and may not send it from that address. The exception is a role holding `addresses:all`, which reaches every address whatever `addresses` lists, because that array holds only direct grants, so check `permissions` before reading it as the whole of somebody’s reach.

Every method takes the `userId`, not the email. `add` is the one exception, because it invites an address: the person has a `userId` only once they accept, and `list_invitations` follows the invitation until then.

> `'implied': True` means nobody chose the role. They hold addresses and no role row, so it was inferred from the widest grant they have. Treat it as “not decided yet”, and `update` is what turns the inference into a decision. Until then, widening their address access silently widens what they may do.

> The workspace owner is the first row, marked `'isOwner': True`, while `add`, `update` and `remove` still refuse them with `member_is_owner`. An unshared workspace reports one member rather than none, so exclude `isOwner` when you are counting seats.

> `remove` takes both axes, the role AND every address grant on this workspace, and reports `addressesRevoked`. `revoke_address` is the narrow one, for somebody who moved team rather than somebody who left.

## Parameters

- `email` (str, required): Who to invite, trimmed and lower-cased. It does not need an account yet: everybody is invited, and the role and grants land when they accept. Somebody already in the workspace is `member_is_owner` (422).
- `roleId` (str, required): The role they will hold, 1 to 128 characters, and it must be a role on this workspace: an unknown id is `role_not_found` (404). The owner role cannot be handed out and comes back `role_immutable` (409), because making somebody an owner is a workspace transfer and there is no call for that here.
- `addressIds` (list[str]): Addresses the invitation carries, at most 64 ids of 1 to 128 characters each, granted when it is accepted. Every id is checked before anything is written, so one that is not an address on this workspace refuses the whole call with 422 `member_not_found` and nothing is sent. Inviting the same address again within ten minutes is 409 `invitation_too_soon`.
- `access` (Literal['member', 'viewer']): What they may do with every id in `addressIds`: `member` reads the address and sends as it, `viewer` only reads it. Defaults to `member`, the level the console and the older sharing path have always used, so the same call means the same thing from a script and from a screen; grant a mixture by calling `grant_address` afterwards for the ones that differ.

## Response

- `object` (Literal['member']): Always `member`. A removal answers with the same value, their `userId`, `'deleted': True` and `addressesRevoked`, and none of the other fields below.
- `userId` (str): Their account id, and the handle every other member call takes in the path: get, update, remove and both address calls. Adding somebody is the one call that works from an email instead, because whoever is adding a colleague knows their address and not their id.
- `email` (str): The email on their account, echoed as that row stores it. This resource never writes it, and the lower-casing on `add` applies to the address you send for the lookup rather than to what comes back. After the owner, the members list is sorted by it rather than by when people joined, because the list is read to find one person rather than to see what changed.
- `name` (str | None): Their display name, taken from their account, where the column is NOT NULL. The `None` in the type is defensive rather than a state this API has been seen to produce. It belongs to them rather than to the workspace, so nothing on this resource can set it.
- `image` (str | None): Their avatar, taken from their account, and null when they have not set one.
- `role.id` (str | None): The id of the role they hold, or null when nobody chose it. See `implied`. A null here is the one case where `role` reports an inference rather than a decision somebody made.
- `role.name` (str): The role's name. For an implied member it is the name of the built-in template their access resolved to, not a row on this workspace.
- `role.builtin` (Literal['owner', 'admin', 'member', 'viewer', 'developer', 'billing'] | None): Which built-in the role is, or null for a custom one. `owner` appears only on the owner's own row, alongside `'isOwner': True`; assigning that role to anybody is refused with `role_immutable` (409).
- `isOwner` (bool): True on exactly one row, the account the workspace is keyed on. They hold every permission whatever their role row says, they sort first, and `add`, `update` and `remove` all refuse them with `member_is_owner`. Exclude them when you are counting seats.
- `implied` (bool): True when this person has address grants and no member row, so their role was inferred rather than chosen: any grant of `member` resolves to the built-in Member, otherwise Viewer. Never true for the owner. Show it as "implied by access". Until a PATCH turns the inference into a decision, widening their address access silently widens what they may do.
- `permissions` (list[Permission]): The role's permissions flattened onto the member, so one read answers "may they?" without fetching the role. For an implied member they come from the built-in TEMPLATE rather than from this workspace's role row, so editing the built-in Member role does not change what an implied member holds.
- `addresses` (list[MemberAddressResource]): The addresses they have been given, sorted by address, each with its own access level. Empty for somebody holding a role and no grants, which is what a new member looks like until an address is granted, and is the right failure to have while you are still deciding what they should see.
- `addresses[].addressId` (str): The id of the address, and what `grant_address` and `revoke_address` take. An id that is not an address on this workspace is refused on both, rather than reporting a revocation that never happened.
- `addresses[].address` (str): The full address, lower-cased, rebuilt from its local part and its domain.
- `addresses[].access` (Literal['member', 'viewer']): What they may do with this one address: `member` reads it and sends as it, `viewer` only reads it. This and the role both have to allow a send before one happens, so a role holding `emails:send` over a `viewer` grant sends from nothing; the stored column is called `role`, and it is renamed here so one object does not carry two `role`s drawn from two vocabularies.
- `createdAt` (str | None): When their member row was written, ISO-8601, and null when there is no member row at all. That null describes the same population as `'implied': True`: people who hold addresses from before roles existed and whom nobody has since given a role.

## Invitations

**invitations.py**

```
from openemail import openemail

waiting = openemail.members.list_all_invitations()

for invitation in waiting:
    if invitation['expired']:
        openemail.members.resend_invitation(invitation['id'])

openemail.members.revoke_invitation('winv_6bb640f5b99e47deb758f1f5')
```

`add` answers with an invitation, and these are the calls that follow one up: `list_invitations`, `list_all_invitations` and `iterate_invitations` read the ones nobody has accepted yet, `resend_invitation` sends one again with a new link and fourteen more days, and `revoke_invitation` withdraws it. A waiting invitation grants nothing until it is accepted.

> `resend_invitation` refuses the same address twice within ten minutes with 409 `invitation_too_soon`, and `revoke_invitation` refuses one that was accepted first with 409 `invitation_accepted`.

## Verification codes

> `add`, `update`, `remove`, `grant_address` and `revoke_address` ask an OAuth access token for a verification code before they change anything, and `resend_invitation` and `revoke_invitation` do not. The call raises an `OpenEmailApiError` whose `is_step_up_required` is `True`: ask for a code with `security.begin_step_up()`, check the one the person gives you with `security.verify_step_up({'code': ...})`, then make the call again. One verification holds for 60 minutes, and an API key is never asked.

- [Configuration](https://openemail.uk/docs/python/configuration.md): Access tokens, and the verification codes they are asked for.

## Reference

- [`members.list()`](https://openemail.uk/docs/python/reference/members#list): full reference
- [`members.list_all()`](https://openemail.uk/docs/python/reference/members#listAll): full reference
- [`members.iterate()`](https://openemail.uk/docs/python/reference/members#iterate): full reference
- [`members.get()`](https://openemail.uk/docs/python/reference/members#get): full reference
- [`members.add()`](https://openemail.uk/docs/python/reference/members#add): full reference
- [`members.update()`](https://openemail.uk/docs/python/reference/members#update): full reference
- [`members.remove()`](https://openemail.uk/docs/python/reference/members#remove): full reference
- [`members.grant_address()`](https://openemail.uk/docs/python/reference/members#grantAddress): full reference
- [`members.revoke_address()`](https://openemail.uk/docs/python/reference/members#revokeAddress): full reference
- [`members.list_invitations()`](https://openemail.uk/docs/python/reference/members#listInvitations): full reference
- [`members.list_all_invitations()`](https://openemail.uk/docs/python/reference/members#listAllInvitations): full reference
- [`members.iterate_invitations()`](https://openemail.uk/docs/python/reference/members#iterateInvitations): full reference
- [`members.resend_invitation()`](https://openemail.uk/docs/python/reference/members#resendInvitation): full reference
- [`members.revoke_invitation()`](https://openemail.uk/docs/python/reference/members#revokeInvitation): full reference
