Skip to the documentation
Go

client.Members

Every method in this namespace: its signature, its parameters, what it returns and an example.

Methods

People who share the workspace, their role and the addresses they may use, the invitations still waiting, and directory sync, through which a company directory adds people and takes them out again.

Members.List

List everybody with access to the workspace

Scopesmembers:readPages through results
Signature
List(ctx context.Context, opts ...nextmail.RequestOption) (*nextmail.Page, error)

Returns one page of the workspace's members, the owner first and the rest by email. ListAll collects every page and Iterate walks them lazily. Each row carries two axes that a client must not merge: role and permissions say what the person may do, and addresses and domains say what they may do it to, each with its own access. A whole domain reaches every address on it, including ones made later. A send needs both axes, so emails:send with nothing granted sends from nothing.

The one exception is addresses:all. When permissions holds it, the person reaches every address on every domain of the workspace, including ones added later, and sends as any of them when permissions also holds emails:send. addresses and domains still list only the grants made to them directly, which they may have kept from before or been given since, or none at all. Read reach from permissions first, and from those two arrays only when it lacks addresses:all.

The list is a union of people with a membership row and people who only hold address or domain grants and no membership row. The second group comes back with implied: true, role.id null and createdAt null, and their role is inferred from their grants: Member if any grant has access: 'member', Viewer otherwise. Until someone calls Update for them, widening their addresses silently widens what they may do.

The workspace owner is the FIRST row, marked isOwner: true, so an unshared workspace returns one member rather than an empty page. They hold every permission by definition, and Add, Update and Remove refuse them with member_is_owner. Exclude isOwner when counting seats.

Parameters

nextmail.WithLimitint

Page size, from 1 to 100. The server defaults to 25.

nextmail.WithCursorstring

The NextCursor of the previous page. Leave it out for the first page.

nextmail.WithQstring

Narrows to people whose name, email, user id, role, or one of the addresses and domains they were given matches, up to 200 characters. Every word has to appear in one of them, ignoring case and accents, and when nothing matches exactly the search allows for a typo instead.

nextmail.WithAPIKeystring

Overrides the client API key for this call only.

Returns

The *nextmail.Page with Items, HasMore and NextCursor. Each item has userId, email, name, image, isOwner, role, implied, permissions, addresses, domains and createdAt.

Example

page, err := client.Members.List(ctx)if err != nil {	return err} for _, member := range page.Items {	fmt.Println(member.String("name"), member.String("email"))} fmt.Println(page.HasMore, page.NextCursor)

Notes

  • Every other method here takes userId, the account id, not the email address.

  • An access token acting for the member who connected a mailbox, whose role lacks members:read but whose app was given it, gets only the people that member can give the mailbox to: userId, email, name and image, with the role, permissions, addresses and domains empty and without the owner.

  • access: 'viewer' on an address blocks sending from it even when the role holds emails:send, unless the role also holds addresses:all. Otherwise the two axes are ANDed, never added.

  • The cursor is opaque and holds where the last row sat in this order, so a row deleted or edited between pages never breaks the walk: the next page starts at the first row that sorts after it. A cursor this list did not hand out is a 400 invalid_cursor.

Also available in

API
GET /members
TypeScript
members.list()
Python
members.list()
Ruby
members.list
PHP
members->list
Java
members().list
C#
Members.ListAsync
CLI
nextmail members list

Members.ListAll

Collect every member into one slice

Scopesmembers:readPages through results
Signature
ListAll(ctx context.Context, opts ...nextmail.RequestOption) ([]nextmail.Object, error)

Walks every page of List and returns with all members, the owner first and the rest by email. One request per page.

Parameters

nextmail.WithLimitint

Page size for each request, from 1 to 100. The server defaults to 25.

nextmail.WithCursorstring

Starts the walk after this cursor instead of the first page.

nextmail.WithQstring

Narrows to people whose name, email, user id, role, or one of the addresses and domains they were given matches, up to 200 characters. Every word has to appear in one of them, ignoring case and accents, and when nothing matches exactly the search allows for a typo instead.

nextmail.WithAPIKeystring

Overrides the client API key for every page of this walk.

Returns

A []nextmail.Object holding every member.

Example

all, err := client.Members.ListAll(ctx, nextmail.WithLimit(100))if err != nil {	return err} for _, member := range all {	fmt.Println(member.String("name"), member.String("email"))}

Notes

  • If any page fails the call fails and the members already fetched are discarded.

Also available in

API
GET /members
TypeScript
members.listAll()
Python
members.list_all()
Ruby
members.list_all
PHP
members->listAll
Java
members().listAll
C#
Members.ListAllAsync

Members.Iterate

Stream the members one at a time

Scopesmembers:readPages through results
Signature
Iterate(ctx context.Context, opts ...nextmail.RequestOption) *nextmail.Iterator

Returns an iterator that yields members individually, the owner first and the rest by email, and requests the next page only once the current one is drained. Nothing is fetched until you consume it, and breaking out of the loop stops the requests.

Parameters

nextmail.WithLimitint

Page size for each request, from 1 to 100. The server defaults to 25.

nextmail.WithCursorstring

Starts the walk after this cursor instead of the first page.

nextmail.WithQstring

Narrows to people whose name, email, user id, role, or one of the addresses and domains they were given matches, up to 200 characters. Every word has to appear in one of them, ignoring case and accents, and when nothing matches exactly the search allows for a typo instead. Sent with every page.

nextmail.WithAPIKeystring

Overrides the client API key for every page of this walk.

Returns

The *nextmail.Iterator yielding one member per step.

Example

for member, err := range client.Members.Iterate(ctx).All() {	if err != nil {		return err	} 	fmt.Println(member.String("name"), member.String("email"))}

Notes

  • The iterator is lazy, so an abandoned loop costs only the pages you consumed.

Also available in

API
GET /members
TypeScript
members.iterate()
Python
members.iterate()
Ruby
members.iterate
PHP
members->iterate
Java
members().iterate
C#
Members.IterateAsync

Members.Get

Read one member by account id

Scopesmembers:read
Signature
Get(ctx context.Context, userID string, opts ...nextmail.RequestOption) (nextmail.Object, error)

Returns a single member with their role, resolved permissions and address grants. The lookup runs over the same union as List, so a legacy grant holder with no membership row is found here too, with implied: true.

The path takes the account id from List, not an email. An email can change on the account, and a stale one would point at the wrong person. The owner is not a member, so their account id answers 404 like any unknown one.

Parameters

userIDstringRequired

The account id from List, not the email address.

nextmail.WithAPIKeystring

Overrides the client API key for this call only.

Returns

The nextmail.Object with role (id, name, builtin), implied, the resolved permissions, and addresses holding addressId, address and access.

Example

member, err := client.Members.Get(ctx, "q7Vd3kX9mT2pLw8RzN4bYc6HfJ1sGa5E")if err != nil {	return err} fmt.Println(member.Object("role").String("name"), member.Bool("implied"))

Notes

  • A missing member is 404 resource_not_found.

  • For an implied member, permissions are the Member or Viewer template permissions, not a stored role that Roles.Get could read.

Also available in

API
GET /members/{userId}
TypeScript
members.get()
Python
members.get()
Ruby
members.get
PHP
members->get
Java
members().get
C#
Members.GetAsync
CLI
nextmail members get

Members.Add

Invite somebody to the workspace with a role

Scopesmembers:write
Signature
Add(ctx context.Context, body nextmail.Body, opts ...nextmail.RequestOption) (nextmail.Object, error)

Sends an invitation to join the workspace. Whether or not the address already has an account on Nextmail, the answer is an invitation rather than a member: nobody is put into a workspace without accepting, and this method is held to the same rule as the app.

The invitation carries the role, the addresses and the whole domains you name, and grants exactly those the moment it is accepted. Nothing is granted before that. Calling it again for the same address within ten minutes is refused with 409 invitation_too_soon; after that it refreshes the one outstanding invitation rather than sending a second.

Somebody already in the workspace is refused with 422 member_is_owner. Change what an existing member may do with Update, GrantAddress and RevokeAddress, which only work on people already in.

Role and grants are separate axes. access applies to every id in addressIds and domainIds, and it never widens the role: access: 'member' under a role without emails:send still cannot send. A role holding addresses:all reaches every address without any ids, and no key or access token can invite with one, because none of them holds that console-only permission.

Parameters

emailstringRequired

Who to invite. Trimmed and lowercased. It does not need to have an account yet.

roleIdstringRequired

Role id from Roles.List. The owner role is refused with 409 role_immutable, and a role holding more than the key itself holds is refused with 403 insufficient_authority. That covers every role with a console-only permission in it, such as addresses:all.

addressIds[]string

Up to 64 address ids on this workspace the invitation carries, all at access.

domainIds[]string

Up to 64 domain ids on this workspace the invitation carries, all at access. A whole domain covers every address on it, including ones made later.

accessstring

member reads and sends as the granted addresses, viewer only reads them. Defaults to member.

nextmail.WithAPIKeystring

Overrides the client API key for this call only.

Returns

The nextmail.Object with a 202: the invitation id, what it carries, when it expires, and delivered, which is false when the email did not leave the mail server.

Example

invitation, err := client.Members.Add(ctx, nextmail.Body{	"email":     "[email protected]",	"roleId":    "role_8b1f4c2e9a7d3b60e5f1a2c4",	"domainIds": []string{"93542ff8-2baa-4f2f-841d-5ceaa074ab0d"},	"access":    "member",})if err != nil {	return err} fmt.Println(invitation.String("id"), invitation.Bool("delivered"), invitation.String("expiresAt"))

Notes

  • An unknown roleId is 404 role_not_found with param set to roleId. An address or domain id that is not on this workspace is 422 member_not_found with param set to addressId or domainId.

  • The workspace owner, and anybody already in the workspace, is refused with 422 member_is_owner.

  • delivered: false means the invitation exists but the email did not go out. It can be sent again from the app once the ten minute cooldown has passed.

  • Not retried automatically. Re-posting the same body inside ten minutes is 409 rather than a duplicate.

Also available in

API
POST /members
TypeScript
members.add()
Python
members.add()
Ruby
members.add
PHP
members->add
Java
members().add
C#
Members.AddAsync
CLI
nextmail members add

Members.Update

Change the role a member holds

Scopesmembers:write
Signature
Update(ctx context.Context, userID string, patch nextmail.Body, opts ...nextmail.RequestOption) (nextmail.Object, error)

Moves a member to a different role and changes nothing else, for somebody ALREADY in the workspace. Their address and domain grants are untouched, and grants cannot be patched here at all: GrantAddress and RevokeAddress change one grant at a time.

This is also how a legacy grant holder stops being implied. They have address or domain grants and no membership row, this writes one, and from then on implied is false and their permissions come from a role someone chose rather than from what their access implied.

Nobody joins through Update. An account that is not in the workspace is 422 member_not_found: invite them with Add and they are in once they accept. The owner role cannot be handed out, which is 409 role_immutable, and the workspace owner cannot be given a role, which is 422 member_is_owner.

Parameters

userIDstringRequired

The account id from List, not the email address.

roleIdstringRequired

Id of the role to move them to.

nextmail.WithAPIKeystring

Overrides the client API key for this call only.

Returns

The nextmail.Object with the new role and permissions, and implied set to false.

Example

member, err := client.Members.Update(ctx, "q7Vd3kX9mT2pLw8RzN4bYc6HfJ1sGa5E", nextmail.Body{"roleId": "role_2c7e9a1f4b8d3e60c5a7f1b9"})if err != nil {	return err} fmt.Println(member.Object("role").String("name"), member.Bool("implied"))

Notes

  • The account has to be in the workspace already, by membership row or by a grant. Anybody else is 422 member_not_found; use Add to invite them.

  • An unknown roleId is 404 role_not_found, and a user id with no Nextmail account behind it is 404 user_not_found.

  • A role holding more than the key itself holds is 403 insufficient_authority. No key or access token holds a console-only permission, so a role with addresses:all, billing or workspace:manage in it is handed out only in the app. That includes the seeded Admin, which holds billing.

  • Retried automatically on network failure, since it names the role it wants and a replay lands on the same row.

Also available in

API
PATCH /members/{userId}
TypeScript
members.update()
Python
members.update()
Ruby
members.update
PHP
members->update
Java
members().update
C#
Members.UpdateAsync
CLI
nextmail members update

Members.Remove

Remove a member and every address grant they hold

Scopesmembers:write
Signature
Remove(ctx context.Context, userID string, opts ...nextmail.RequestOption) (nextmail.Object, error)

Takes somebody out of the workspace entirely: the membership row and every address grant they hold on it. Removing only the row would drop them from the list while they kept reading the mail, so both go together.

It does not 404 for somebody who is not a member. The people this most needs to reach are legacy grant holders with no membership row, so there is no existence check, and addressesRevoked reports what actually happened. Zero is the honest answer for a no-op.

Their account, their sent mail and anything they wrote are untouched. Only their access to this workspace ends.

Parameters

userIDstringRequired

The account id from List, not the email address.

nextmail.WithAPIKeystring

Overrides the client API key for this call only.

Returns

The nextmail.Object with object set to member, the userId, deleted: true and addressesRevoked.

Example

removed, err := client.Members.Remove(ctx, "q7Vd3kX9mT2pLw8RzN4bYc6HfJ1sGa5E")if err != nil {	return err} fmt.Println(removed.Bool("deleted"), removed.Int("addressesRevoked"))

Notes

  • Idempotent on the server, but the SDK does not retry it automatically, so repeat it yourself after a network failure.

  • The workspace owner is refused with 422 member_is_owner, because their access never came from a membership.

Also available in

API
DELETE /members/{userId}
TypeScript
members.remove()
Python
members.remove()
Ruby
members.remove
PHP
members->remove
Java
members().remove
C#
Members.RemoveAsync
CLI
nextmail members remove

Members.GrantAddress

Grant a member one address or change their access to it

Scopesmembers:write
Signature
GrantAddress(ctx context.Context, userID string, body nextmail.Body, opts ...nextmail.RequestOption) (nextmail.Object, error)

Gives one person one address on this workspace, or changes the access they already have to it. It is an upsert: there is one grant per person and address, so posting again with a different access turns a viewer into a member rather than adding a second grant.

This is the address axis and it cannot widen the role. access: 'member' lets somebody send as the address only if their role also holds emails:send, and otherwise it lets them read.

Granting an address to an account with no membership row makes them appear in List as an implied member whose role is inferred from their grants, so call Update as well if the role should be a decision. The whole member comes back, which lets a client redraw the row without another read.

Parameters

userIDstringRequired

The account id from List, not the email address.

addressIdstringRequired

Id of an address on this workspace.

accessstring

member reads and sends as the address, viewer only reads it. Defaults to member.

nextmail.WithAPIKeystring

Overrides the client API key for this call only.

Returns

The nextmail.Object with the grant applied, including the full addresses list.

Example

member, err := client.Members.GrantAddress(	ctx,	"q7Vd3kX9mT2pLw8RzN4bYc6HfJ1sGa5E",	nextmail.Body{"addressId": "4f0c1b6e-2d7a-4a9e-8c35-91b2e7d4f6a0", "access": "viewer"},)if err != nil {	return err} fmt.Println(member.String("name"), member.String("email"))

Notes

  • An address id that is not on this workspace is 422 with code member_not_found and param set to addressId.

  • The workspace owner is refused with 422 member_is_owner, since they already reach every address, and the member who connected a mailbox at the address with 422 member_is_connector, since they already have it in full. A user id with no Nextmail account behind it is 404 user_not_found.

  • Gated on members:write rather than on owning the address, so an admin who owns nothing can still manage grants.

  • The member who connected a mailbox may give its address without members:write in their role, through an access token whose app was given members:write. That token reaches the connected address alone.

  • A workspace whose plan has no team access is refused with 403 plan_required, and an access token acting for a member can only give an address that member reaches, at the level they reach it, or it is refused with 403 insufficient_authority. A grant that changes the access is written to the workspace security log as address-access-granted.

  • Retried automatically on network failure, since replaying the same grant lands on the same row.

Also available in

API
POST /members/{userId}/addresses
TypeScript
members.grantAddress()
Python
members.grant_address()
Ruby
members.grant_address
PHP
members->grantAddress
Java
members().grantAddress
C#
Members.GrantAddressAsync
CLI
nextmail members grant-address

Members.RevokeAddress

Take one address back from a member

Scopesmembers:write
Signature
RevokeAddress(ctx context.Context, userID string, addressID string, opts ...nextmail.RequestOption) (nextmail.Object, error)

Removes one address grant and leaves the person in the workspace with their role and their other addresses. This is the narrow revocation to use when somebody changes team.

An address id that is not on this workspace is refused with 422 member_not_found rather than ignored, so a typo cannot report a revocation that never happened. An address that is on the workspace but was never granted to this person is a silent no-op, and the member comes back unchanged.

The member is returned rather than a tombstone, because the useful answer is what they can still reach.

Parameters

userIDstringRequired

The account id from List, not the email address.

addressIDstringRequired

Id of an address on this workspace.

nextmail.WithAPIKeystring

Overrides the client API key for this call only.

Returns

The nextmail.Object with the remaining addresses.

Example

member, err := client.Members.RevokeAddress(ctx, "q7Vd3kX9mT2pLw8RzN4bYc6HfJ1sGa5E", "4f0c1b6e-2d7a-4a9e-8c35-91b2e7d4f6a0")if err != nil {	return err} fmt.Println(member.String("name"), member.String("email"))

Notes

  • Revoking the last grant of an implied member removes them from the workspace entirely. The call still succeeds and returns the member as they stood, without that address.

  • Somebody who is not a member of this workspace is a 404.

  • The member who connected a mailbox at the address keeps it while they are in the workspace, so taking it from them is refused with 422 member_is_connector. Disconnect the mailbox with ConnectedMailboxes.Disconnect, or remove them with Remove, instead.

  • The member who connected a mailbox may take its address back from anybody else without members:write in their role, through an access token whose app was given members:write.

  • An access token acting for a member can only take back a grant that member reaches at the same level, or it is refused with 403 insufficient_authority. A revocation that removed a grant is written to the workspace security log as address-access-revoked.

  • Not retried automatically by the SDK.

Also available in

API
DELETE /members/{userId}/addresses/{addressId}
TypeScript
members.revokeAddress()
Python
members.revoke_address()
Ruby
members.revoke_address
PHP
members->revokeAddress
Java
members().revokeAddress
C#
Members.RevokeAddressAsync
CLI
nextmail members revoke-address

Members.GrantDomain

Grant a member a whole domain or change their access to it

Scopesmembers:write
Signature
GrantDomain(ctx context.Context, userID string, body nextmail.Body, opts ...nextmail.RequestOption) (nextmail.Object, error)

Gives one person every address on one domain of this workspace, including addresses added after the grant, or changes the access they already have to it. It is an upsert: there is one grant per person and domain, so calling it again with a different access turns a viewer into a member rather than adding a second grant.

This is the address axis and it cannot widen the role. access: 'member' lets somebody send from the domain only if their role also holds emails:send, and otherwise it lets them read.

The person has to be in the workspace already, so invite them with Add first. The whole member comes back, with the grant in domains.

Parameters

userIDstringRequired

The account id from List, not the email address.

domainIdstringRequired

Id of a domain on this workspace, as Domains.List returns it.

accessstring

member reads and sends from the domain, viewer only reads it. Defaults to member.

nextmail.WithAPIKeystring

Overrides the client API key for this call only.

Returns

The nextmail.Object with the grant applied, including the full domains list.

Example

member, err := client.Members.GrantDomain(	ctx,	"q7Vd3kX9mT2pLw8RzN4bYc6HfJ1sGa5E",	nextmail.Body{"domainId": "7d2a9c41-5b3e-4f8a-9c06-1e2b3c4d5e6f", "access": "viewer"},)if err != nil {	return err} fmt.Println(member.String("name"), member.String("email"))

Notes

  • A domain id that is not on this workspace is 422 with code member_not_found and param set to domainId. Somebody who is not in the workspace yet is refused the same way with param set to userId.

  • The workspace owner is refused with 422 member_is_owner, since they already reach every domain. A user id with no Nextmail account behind it is 404 user_not_found.

  • A workspace whose plan has no team access is refused with 403 plan_required. A key or an access token limited to particular addresses or domains is refused with 422 capability_unsupported, and an access token acting for a member can only give a domain that member reaches, or it is refused with 403 insufficient_authority. A grant that changes the access is written to the workspace security log as domain-access-granted.

  • An OAuth access token needs a verification code for this call, and is refused with 403 step_up_required until the app has verified one in the last 60 minutes. The error matches nextmail.ErrStepUpRequired. An API key is never asked for a code.

  • Retried automatically on network failure, since replaying the same grant lands on the same row.

Also available in

API
POST /members/{userId}/domains
TypeScript
members.grantDomain()
Python
members.grant_domain()
Ruby
members.grant_domain
PHP
members->grantDomain
Java
members().grantDomain
C#
Members.GrantDomainAsync
CLI
nextmail members grant-domain

Members.RevokeDomain

Take a whole domain back from a member

Scopesmembers:write
Signature
RevokeDomain(ctx context.Context, userID string, domainID string, opts ...nextmail.RequestOption) (nextmail.Object, error)

Removes one domain grant and leaves the person in the workspace with their role and their other grants. Addresses on that domain that were granted to them one by one stay granted.

A domain id that is not on this workspace is refused with 422 member_not_found rather than ignored, so a typo cannot report a revocation that never happened. A domain that is on the workspace but was never granted to this person is a silent no-op, and the member comes back unchanged.

The member is returned rather than a tombstone, because the useful answer is what they can still reach.

Parameters

userIDstringRequired

The account id from List, not the email address.

domainIDstringRequired

Id of a domain on this workspace.

nextmail.WithAPIKeystring

Overrides the client API key for this call only.

Returns

The nextmail.Object with the remaining domains.

Example

member, err := client.Members.RevokeDomain(ctx, "q7Vd3kX9mT2pLw8RzN4bYc6HfJ1sGa5E", "7d2a9c41-5b3e-4f8a-9c06-1e2b3c4d5e6f")if err != nil {	return err} fmt.Println(member.String("name"), member.String("email"))

Notes

  • Somebody who is not a member of this workspace is a 404.

  • A key or an access token limited to particular addresses or domains is refused with 422 capability_unsupported, and an access token acting for a member can only take back a grant that member reaches at the same level, or it is refused with 403 insufficient_authority. A revocation that removed a grant is written to the workspace security log as domain-access-revoked.

  • An OAuth access token needs a verification code for this call, and is refused with 403 step_up_required until the app has verified one in the last 60 minutes. The error matches nextmail.ErrStepUpRequired. An API key is never asked for a code.

  • Not retried automatically by the SDK.

Also available in

API
DELETE /members/{userId}/domains/{domainId}
TypeScript
members.revokeDomain()
Python
members.revoke_domain()
Ruby
members.revoke_domain
PHP
members->revokeDomain
Java
members().revokeDomain
C#
Members.RevokeDomainAsync
CLI
nextmail members revoke-domain

Members.ListInvitations

List the invitations nobody has accepted yet

Scopesmembers:readPages through results
Signature
ListInvitations(ctx context.Context, opts ...nextmail.RequestOption) (*nextmail.Page, error)

Returns one page of the invitations to this workspace that are still waiting, by email: the role and the addresses and whole domains each one grants once accepted, when it expires, and whether the last email reached them. ListAllInvitations collects every page and IterateInvitations walks them lazily.

A waiting invitation grants nothing. It becomes access only at the moment somebody accepts it, which is why it is listed apart from List. An expired one stays on the list with expired: true until it is sent again or withdrawn.

Parameters

nextmail.WithLimitint

Page size, from 1 to 100. The server defaults to 25.

nextmail.WithCursorstring

The NextCursor of the previous page. Leave it out for the first page.

nextmail.WithAPIKeystring

Overrides the client API key for this call only.

Returns

The *nextmail.Page with Items, HasMore and NextCursor. Each item has id, email, role, addresses, domains, expiresAt, expired, lastSentAt, delivered, deliveryError and createdAt.

Example

page, err := client.Members.ListInvitations(ctx)if err != nil {	return err} for _, invitation := range page.Items {	fmt.Println(invitation.Bool("expired"))} fmt.Println(page.HasMore, page.NextCursor)

Notes

  • delivered is null when no send outcome was recorded, false when the email did not leave the mail server, with the reason in deliveryError.

  • A key limited to particular addresses or domains lists only the invitations that grant nothing outside them.

Also available in

API
GET /members/invitations
TypeScript
members.listInvitations()
Python
members.list_invitations()
Ruby
members.list_invitations
PHP
members->listInvitations
Java
members().listInvitations
C#
Members.ListInvitationsAsync
CLI
nextmail members list-invitations

Members.ListAllInvitations

Collect every waiting invitation into one slice

Scopesmembers:readPages through results
Signature
ListAllInvitations(ctx context.Context, opts ...nextmail.RequestOption) ([]nextmail.Object, error)

Walks every page of ListInvitations and returns with every waiting invitation, by email. One request per page, with the same filters on each.

Parameters

nextmail.WithLimitint

Page size for each request, from 1 to 100. The server defaults to 25.

nextmail.WithCursorstring

Starts the walk after this cursor instead of the first page.

nextmail.WithAPIKeystring

Overrides the client API key for every page of this walk.

Returns

A []nextmail.Object holding every waiting invitation.

Example

all, err := client.Members.ListAllInvitations(ctx)if err != nil {	return err} for _, invitation := range all {	fmt.Println(invitation.String("email"), invitation.Object("role").String("name"))}

Notes

  • If any page fails the call fails and the rows already fetched are discarded.

Also available in

API
GET /members/invitations
TypeScript
members.listAllInvitations()
Python
members.list_all_invitations()
Ruby
members.list_all_invitations
PHP
members->listAllInvitations
Java
members().listAllInvitations
C#
Members.ListAllInvitationsAsync

Members.IterateInvitations

Stream the waiting invitations one at a time

Scopesmembers:readPages through results
Signature
IterateInvitations(ctx context.Context, opts ...nextmail.RequestOption) *nextmail.Iterator

Returns an iterator that yields one invitation at a time, by email, and requests the next page only once the current one is drained. Nothing is fetched until you consume it, and breaking out of the loop stops the requests.

Parameters

nextmail.WithLimitint

Page size for each request, from 1 to 100. The server defaults to 25.

nextmail.WithCursorstring

Starts the walk after this cursor instead of the first page.

nextmail.WithAPIKeystring

Overrides the client API key for every page of this walk.

Returns

The *nextmail.Iterator yielding one invitation per step.

Example

for invitation, err := range client.Members.IterateInvitations(ctx).All() {	if err != nil {		return err	} 	fmt.Println(invitation.Bool("delivered"), invitation.String("email"), invitation.String("deliveryError"))}

Notes

  • The iterator is lazy, so an abandoned loop costs only the pages you consumed.

Also available in

API
GET /members/invitations
TypeScript
members.iterateInvitations()
Python
members.iterate_invitations()
Ruby
members.iterate_invitations
PHP
members->iterateInvitations
Java
members().iterateInvitations
C#
Members.IterateInvitationsAsync

Members.RevokeInvitation

Withdraw an invitation

Scopesmembers:write
Signature
RevokeInvitation(ctx context.Context, invitationID string, opts ...nextmail.RequestOption) (nextmail.Object, error)

Withdraws an invitation nobody has accepted. Its link stops working at once and nothing it would have granted is granted. It is Withdraw on the members screen. Inviting the same address later with Add sends a new one.

Parameters

invitationIDstringRequired

The invitation id from ListInvitations.

nextmail.WithAPIKeystring

Overrides the client API key for this call only.

Returns

The nextmail.Object with object set to invitation, id, email and revoked set to true.

Example

invitation, err := client.Members.RevokeInvitation(ctx, "winv_6bb640f5b99e47deb758f1f5")if err != nil {	return err} fmt.Println(invitation.String("id"), invitation.String("email"))

Notes

  • An invitation that was accepted first answers 409 invitation_accepted: remove the member instead. One that is unknown or already withdrawn answers 404.

  • A key limited to particular addresses or domains can withdraw only an invitation that grants nothing outside them.

Also available in

API
DELETE /members/invitations/{invitationId}
TypeScript
members.revokeInvitation()
Python
members.revoke_invitation()
Ruby
members.revoke_invitation
PHP
members->revokeInvitation
Java
members().revokeInvitation
C#
Members.RevokeInvitationAsync
CLI
nextmail members revoke-invitation

Members.ResendInvitation

Send an invitation again

Scopesmembers:write
Signature
ResendInvitation(ctx context.Context, invitationID string, opts ...nextmail.RequestOption) (nextmail.Object, error)

Sends a waiting invitation again: a new link, fourteen more days, and the old link retired, so only the newest email works. It is Send again on the members screen, and it renews an expired invitation too.

Parameters

invitationIDstringRequired

The invitation id from ListInvitations.

nextmail.WithAPIKeystring

Overrides the client API key for this call only.

Returns

The nextmail.Object with the new expiresAt and lastSentAt, and delivered for this send.

Example

invitation, err := client.Members.ResendInvitation(ctx, "winv_6bb640f5b99e47deb758f1f5")if err != nil {	return err} fmt.Println(invitation.String("expiresAt"), invitation.Bool("delivered"))

Notes

  • The same address cannot be sent to twice within ten minutes: that is 409 invitation_too_soon. The daily limit on invitations is 409 invitation_limit_reached.

  • The invitation's role cannot hold more than the key does, the rule Add applies too: a role with a permission the key or access token lacks, any console-only one such as addresses:all included, is 403 insufficient_authority. An access token acting for a member is also refused with it when the invitation carries addresses or domains that member does not reach.

  • The SDK does not retry it, because each call sends an email.

Also available in

API
POST /members/invitations/{invitationId}/resend
TypeScript
members.resendInvitation()
Python
members.resend_invitation()
Ruby
members.resend_invitation
PHP
members->resendInvitation
Java
members().resendInvitation
C#
Members.ResendInvitationAsync
CLI
nextmail members resend-invitation

Members.GetDirectorySync

Read directory sync

Scopesmembers:read
Signature
GetDirectorySync(ctx context.Context, opts ...nextmail.RequestOption) (nextmail.Object, error)

Returns where directory sync (SCIM) stands, as the owner sees it on the Privacy tab: whether it is on, whether the plan includes it, the base URL to give the company directory, the last four characters of its token and when the directory last used it, how many people it synced and where each stands, and the groups it synced with the role each gives.

Directory sync lets a company directory, such as Okta or Microsoft Entra, add people to the workspace and take them out again. The directory calls the SCIM endpoints itself with the token ConnectDirectorySync returns.

Parameters

nextmail.WithAPIKeystring

Overrides the client API key for this call only.

Returns

The nextmail.Object with object: 'directory_sync', connected, available, baseUrl, tokenLast4, tokenRotatedAt, lastSeenAt, connectedAt, defaultRoleId, users (total, members, invited, waiting and inactive) and groups, each with id, displayName, members and roleId.

Example

sync, err := client.Members.GetDirectorySync(ctx)if err != nil {	return err} users := sync.Object("users") fmt.Println(sync.Bool("connected"), users.Int("members"), "of", users.Int("total"), "synced people joined, last seen", sync.String("lastSeenAt"))

Notes

  • Only the workspace owner, or a member whose role holds workspace:manage, may read it: an access token acting for anybody else is refused with 403 insufficient_authority. An API key acts for the owner.

  • tokenLast4, tokenRotatedAt and connectedAt are null while directory sync is off, and lastSeenAt is null until the directory first calls with the token.

Also available in

API
GET /directory-sync
TypeScript
members.getDirectorySync()
Python
members.get_directory_sync()
Ruby
members.get_directory_sync
PHP
members->getDirectorySync
Java
members().getDirectorySync
C#
Members.GetDirectorySyncAsync
CLI
nextmail members get-directory-sync

Members.ConnectDirectorySync

Turn on directory sync

Scopesmembers:write
Signature
ConnectDirectorySync(ctx context.Context, opts ...nextmail.RequestOption) (nextmail.Object, error)

Turns directory sync on and returns with the token the company directory sends as its bearer token, with status, where directory sync stands now. When it is already on, this makes a new token and the old one stops working at once.

The token is in this answer only and can never be read again, so store it in the directory straight away, with status.baseUrl as the SCIM base URL.

Directory sync comes with the Max and Enterprise plans: on any other plan the call is refused with 403 plan_required, and available on GetDirectorySync says which applies.

Parameters

nextmail.WithAPIKeystring

Overrides the client API key for this call only.

Returns

The nextmail.Object with object: 'directory_sync_token', token, shown this once, and status, the directory sync object GetDirectorySync returns.

Example

connected, err := client.Members.ConnectDirectorySync(ctx)if err != nil {	return err} status := connected.Object("status") fmt.Println("SCIM base URL", status.String("baseUrl"), "token ending", status.String("tokenLast4"))fmt.Println(connected.String("token"))

Notes

  • Only the workspace owner, or a member whose role holds workspace:manage, may turn it on: an access token acting for anybody else is refused with 403 insufficient_authority. A key limited to particular addresses or domains is refused with 422 capability_unsupported, because the people it changes reach beyond them.

  • An OAuth access token needs a verification code for this call, and is refused with 403 step_up_required until the app has verified one in the last 60 minutes. The error matches nextmail.ErrStepUpRequired. An API key is never asked for a code.

  • Not retried automatically, since every call replaces the token: a retry after a lost response would leave the directory holding a token that no longer works. The success status is 201.

Also available in

API
POST /directory-sync
TypeScript
members.connectDirectorySync()
Python
members.connect_directory_sync()
Ruby
members.connect_directory_sync
PHP
members->connectDirectorySync
Java
members().connectDirectorySync
C#
Members.ConnectDirectorySyncAsync
CLI
nextmail members connect-directory-sync

Members.DisconnectDirectorySync

Turn off directory sync

Scopesmembers:write
Signature
DisconnectDirectorySync(ctx context.Context, opts ...nextmail.RequestOption) (nextmail.Object, error)

Turns directory sync off. Its token stops working at once and the people and groups it synced are forgotten, while everyone who already joined stays a member with the role they hold. Turning it off when it is off changes nothing, and disconnected is then false.

Parameters

nextmail.WithAPIKeystring

Overrides the client API key for this call only.

Returns

The nextmail.Object with object: 'directory_sync' and disconnected, true when directory sync was on and is off now.

Example

result, err := client.Members.DisconnectDirectorySync(ctx)if err != nil {	return err} if result.Bool("disconnected") {	fmt.Println("Directory sync is off")} else {	fmt.Println("It was already off")}

Notes

  • Only the workspace owner, or a member whose role holds workspace:manage, may turn it off: an access token acting for anybody else is refused with 403 insufficient_authority. A key limited to particular addresses or domains is refused with 422 capability_unsupported.

  • An OAuth access token needs a verification code for this call, and is refused with 403 step_up_required until the app has verified one in the last 60 minutes. The error matches nextmail.ErrStepUpRequired. An API key is never asked for a code.

  • Not retried automatically. A second call after a lost response answers disconnected: false and changes nothing.

Also available in

API
DELETE /directory-sync
TypeScript
members.disconnectDirectorySync()
Python
members.disconnect_directory_sync()
Ruby
members.disconnect_directory_sync
PHP
members->disconnectDirectorySync
Java
members().disconnectDirectorySync
C#
Members.DisconnectDirectorySyncAsync
CLI
nextmail members disconnect-directory-sync

Members.ListDirectoryPeople

List the people the directory synced

Scopesmembers:read
Signature
ListDirectoryPeople(ctx context.Context, opts ...nextmail.RequestOption) (nextmail.Object, error)

Returns one page of the people the company directory synced into the workspace, in the order it sent them, with where each stands: member once they joined, invited while an invitation waits, waiting before one is sent, and inactive when the directory switched them off.

Pages are counted from 1, as SCIM pages are: for the next page, pass nextmail.WithStartIndex with startIndex plus the number of people returned, while that is at most total.

Parameters

nextmail.WithStartIndexint

Where the page starts, counted from 1. Leave it out for the first page.

nextmail.WithCountint

How many people to return, from 1 to 100. Leave it out for 100.

nextmail.WithAPIKeystring

Overrides the client API key for this call only.

Returns

The nextmail.Object with object: 'list', data, total, how many people the directory synced in all, and startIndex. Each person has id, userName, email, name, state, groups, the names of the groups they are in, and updatedAt.

Example

for startIndex := 1; ; {	page, err := client.Members.ListDirectoryPeople(ctx, nextmail.WithStartIndex(startIndex), nextmail.WithCount(100))	if err != nil {		return err	} 	people := page.Objects("data") 	for _, person := range people {		fmt.Println(person.String("userName"), person.String("state"), person.Strings("groups"))	} 	startIndex += len(people) 	if len(people) == 0 || startIndex > page.Int("total") {		return nil	}}

Notes

  • Only the workspace owner, or a member whose role holds workspace:manage, may read it: an access token acting for anybody else is refused with 403 insufficient_authority. An API key acts for the owner.

  • While directory sync is off, or before the directory synced anybody, the list is empty and total is 0.

Also available in

API
GET /directory-sync/people
TypeScript
members.listDirectoryPeople()
Python
members.list_directory_people()
Ruby
members.list_directory_people
PHP
members->listDirectoryPeople
Java
members().listDirectoryPeople
C#
Members.ListDirectoryPeopleAsync
CLI
nextmail members list-directory-people

Members.SetDirectoryDefaultRole

Choose the default role of directory sync

Scopesmembers:write
Signature
SetDirectoryDefaultRole(ctx context.Context, roleID *string, opts ...nextmail.RequestOption) (nextmail.Object, error)

Chooses the role directory sync gives somebody that none of their groups gives a role, and returns with where directory sync stands now. A nil roleID goes back to the built-in Member role.

The owner role cannot be given out this way, which is 422 invalid_parameter on roleId, and a role that is not in the workspace is 422 role_not_found. Anybody but the owner can only give a role that holds nothing they lack themselves, or the call is refused with 403 insufficient_authority. While directory sync is off the call is 409 directory_sync_not_connected.

Parameters

roleID*stringRequired

The id of a role in this workspace, as Roles.List returns it, or nil for the built-in Member role.

nextmail.WithAPIKeystring

Overrides the client API key for this call only.

Returns

The nextmail.Object with the new defaultRoleId.

Example

role := "role_2c7e9a1f4b8d3e60c5a7f1b9" sync, err := client.Members.SetDirectoryDefaultRole(ctx, &role)if err != nil {	return err} fmt.Println(sync.String("defaultRoleId"))

Notes

  • Only the workspace owner, or a member whose role holds workspace:manage, may change it: an access token acting for anybody else is refused with 403 insufficient_authority. A key limited to particular addresses or domains is refused with 422 capability_unsupported.

  • An OAuth access token needs a verification code for this call, and is refused with 403 step_up_required until the app has verified one in the last 60 minutes. The error matches nextmail.ErrStepUpRequired. An API key is never asked for a code.

  • Retried automatically on network failure, since it names the role it wants and a replay changes nothing.

Also available in

API
PUT /directory-sync/default-role
TypeScript
members.setDirectoryDefaultRole()
Python
members.set_directory_default_role()
Ruby
members.set_directory_default_role
PHP
members->setDirectoryDefaultRole
Java
members().setDirectoryDefaultRole
C#
Members.SetDirectoryDefaultRoleAsync
CLI
nextmail members set-directory-default-role

Members.SetDirectoryGroupRole

Choose the role of a directory group

Scopesmembers:write
Signature
SetDirectoryGroupRole(ctx context.Context, groupID string, roleID *string, opts ...nextmail.RequestOption) (nextmail.Object, error)

Chooses the role a group the company directory synced gives its people, moves everyone in it to that role now, and returns with where directory sync stands. A nil roleID stops the group giving a role, so its people fall back to the default role SetDirectoryDefaultRole chose.

The same rules about roles apply as for the default role: the owner role cannot be given out (422 invalid_parameter), a role that is not in the workspace is 422 role_not_found, and anybody but the owner can only give a role that holds nothing they lack themselves (403 insufficient_authority). A group that is not in the workspace is a 404, and while directory sync is off the call is 409 directory_sync_not_connected.

Parameters

groupIDstringRequired

A group the directory synced, as GetDirectorySync lists it in groups.

roleID*stringRequired

The id of a role in this workspace, as Roles.List returns it, or nil to give no role from this group.

nextmail.WithAPIKeystring

Overrides the client API key for this call only.

Returns

The nextmail.Object with the new roleId on the group in groups.

Example

sync, err := client.Members.GetDirectorySync(ctx)if err != nil {	return err} groups := sync.Objects("groups") if len(groups) == 0 {	return nil} role := "role_2c7e9a1f4b8d3e60c5a7f1b9" updated, err := client.Members.SetDirectoryGroupRole(ctx, groups[0].ID(), &role)if err != nil {	return err} for _, group := range updated.Objects("groups") {	fmt.Println(group.String("displayName"), group.String("roleId"))}

Notes

  • Only the workspace owner, or a member whose role holds workspace:manage, may change it: an access token acting for anybody else is refused with 403 insufficient_authority. A key limited to particular addresses or domains is refused with 422 capability_unsupported.

  • An OAuth access token needs a verification code for this call, and is refused with 403 step_up_required until the app has verified one in the last 60 minutes. The error matches nextmail.ErrStepUpRequired. An API key is never asked for a code.

  • Retried automatically on network failure, since it names the role it wants and a replay changes nothing.

Also available in

API
PUT /directory-sync/groups/{groupId}/role
TypeScript
members.setDirectoryGroupRole()
Python
members.set_directory_group_role()
Ruby
members.set_directory_group_role
PHP
members->setDirectoryGroupRole
Java
members().setDirectoryGroupRole
C#
Members.SetDirectoryGroupRoleAsync
CLI
nextmail members set-directory-group-role