Skip to the documentation
Go

client.Account

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

Methods

The account of the person behind the key or the app: the email notifications they get and the workspaces muted on their phone, their profile photo and username, the apps they connected, the invitations waiting for them, the devices they are signed in on, their passkeys and their security log. An API key acts for the workspace owner, and an app for the person who connected it.

Account.GetNotifications

Read your notification settings

Scopesaccount:read
Signature
GetNotifications(ctx context.Context, opts ...nextmail.RequestOption) (nextmail.Object, error)

Returns which kinds of email Nextmail sends the person, as Account, Notifications shows them, and the workspaces whose notifications are muted on their phone. An API key answers for the workspace owner, and an app for the person who connected it.

Parameters

nextmail.WithAPIKeystring

Overrides the client's API key for this call only.

Returns

The nextmail.Object with email, one EmailNotificationSetting for each kind of email, and mutedWorkspaces.

Example

settings, err := client.Account.GetNotifications(ctx)if err != nil {	return err} fmt.Println(settings.String("object"))

Notes

  • account and billing email are always on, and required says so.

Also available in

API
GET /account/notifications
TypeScript
nextmail.account.getNotifications()
Python
account.get_notifications()
Ruby
account.get_notifications
PHP
account->getNotifications
Java
account().getNotifications
C#
Account.GetNotificationsAsync
CLI
nextmail account get-notifications

Account.SetEmailNotification

Turn a kind of email on or off

Scopesaccount:write
Signature
SetEmailNotification(ctx context.Context, category string, body nextmail.Body, opts ...nextmail.RequestOption) (nextmail.Object, error)

enabled: false stops Nextmail sending the person that kind of email, and true starts it again. activity and product can be turned off. account and billing cannot, and asking to is a 422 invalid_parameter on category.

Parameters

categorystringRequired

account, billing, activity or product.

enabledboolRequired

True to receive that email, false to stop it.

nextmail.WithAPIKeystring

Overrides the client's API key for this call only.

Returns

The nextmail.Object as it is after the change.

Example

settings, err := client.Account.SetEmailNotification(ctx, "product", nextmail.Body{"enabled": false})if err != nil {	return err} fmt.Println(settings.String("object"))

Notes

  • Retried automatically on network failure, since the same setting sent twice changes nothing.

Also available in

API
PUT /account/notifications/email/{category}
TypeScript
nextmail.account.setEmailNotification()
Python
account.set_email_notification()
Ruby
account.set_email_notification
PHP
account->setEmailNotification
Java
account().setEmailNotification
C#
Account.SetEmailNotificationAsync
CLI
nextmail account set-email-notification

Account.SetPushMuted

Mute a workspace on your phone

Scopesaccount:write
Signature
SetPushMuted(ctx context.Context, workspaceID string, body nextmail.Body, opts ...nextmail.RequestOption) (nextmail.Object, error)

muted: true stops the phone app notifying the person about the mail of one workspace, on every phone they signed in on, and false lets it notify them again.

Parameters

workspaceIDstringRequired

A workspace id from Workspaces.List.

mutedboolRequired

True to mute it, false to let it notify again.

nextmail.WithAPIKeystring

Overrides the client's API key for this call only.

Returns

The nextmail.Object with the new mutedWorkspaces.

Example

settings, err := client.Account.SetPushMuted(ctx, "10417196-e324-4283-af98-66ec62167c47", nextmail.Body{"muted": true})if err != nil {	return err} fmt.Println(settings.String("object"))

Notes

  • A workspace the person cannot open is a 404 resource_not_found.

  • Retried automatically on network failure, since the same setting sent twice changes nothing.

Also available in

API
PUT /account/notifications/push/{workspaceId}
TypeScript
nextmail.account.setPushMuted()
Python
account.set_push_muted()
Ruby
account.set_push_muted
PHP
account->setPushMuted
Java
account().setPushMuted
C#
Account.SetPushMutedAsync
CLI
nextmail account set-push-muted

Account.SetPhoto

Set your profile photo

Scopesaccount:write
Signature
SetPhoto(ctx context.Context, data io.Reader, opts ...nextmail.RequestOption) (nextmail.Object, error)

Sends the image bytes as the request body, replacing the person's profile photo, as Account, Profile does. PNG, JPEG, WebP and GIF are accepted, up to 5 MB. The server fits the image into a 512 pixel square, stores it as WebP and keeps the first frame of an animation.

data is an io.Reader. The type is read from nextmail.WithContentType. Without either the bytes go as application/octet-stream and the server refuses them with 422 invalid_image.

Parameters

dataio.ReaderRequired

The image, as an io.Reader.

nextmail.WithContentTypestring

image/png, image/jpeg, image/webp or image/gif. The server needs it to accept the image.

nextmail.WithAPIKeystring

Overrides the client's API key for this call only.

Returns

The nextmail.Object with the new url.

Example

source, err := os.Open("photo.jpg")if err != nil {	return err} defer source.Close() photo, err := client.Account.SetPhoto(ctx, source, nextmail.WithContentType("image/jpeg"))if err != nil {	return err} fmt.Println(photo.String("url"))

Notes

  • A busy image service answers 503 image_busy, which the SDK retries like any other 503.

  • Every upload gets a new URL, so a cached old photo never shows under the new one.

Also available in

API
PUT /account/photo
TypeScript
nextmail.account.setPhoto()
Python
account.set_photo()
Ruby
account.set_photo
PHP
account->setPhoto
Java
account().setPhoto
C#
Account.SetPhotoAsync
CLI
nextmail account set-photo

Account.RemovePhoto

Remove your profile photo

Scopesaccount:write
Signature
RemovePhoto(ctx context.Context, opts ...nextmail.RequestOption) (nextmail.Object, error)

Removes the profile photo and deletes the stored image, so the app shows the person's initials again. Removing it when there is none changes nothing.

Parameters

nextmail.WithAPIKeystring

Overrides the client's API key for this call only.

Returns

The nextmail.Object with url null.

Example

photo, err := client.Account.RemovePhoto(ctx)if err != nil {	return err} fmt.Println(photo.String("object"))

Notes

  • Safe to replay, so the SDK retries it after a network failure.

Also available in

API
DELETE /account/photo
TypeScript
nextmail.account.removePhoto()
Python
account.remove_photo()
Ruby
account.remove_photo
PHP
account->removePhoto
Java
account().removePhoto
C#
Account.RemovePhotoAsync
CLI
nextmail account remove-photo

Account.GetUsername

Read your username

Scopesaccount:read
Signature
GetUsername(ctx context.Context, opts ...nextmail.RequestOption) (nextmail.Object, error)

Returns the person's username, whether they chose it or it was made for them from their name, and the free address that comes with it, when there is one. A username the person chose never changes.

Parameters

nextmail.WithAPIKeystring

Overrides the client's API key for this call only.

Returns

The nextmail.Object with username, chosen and address.

Example

username, err := client.Account.GetUsername(ctx)if err != nil {	return err} fmt.Println(username.String("username"), username.Bool("chosen"), username.String("address"))

Notes

  • The first read makes a username for an account that has none.

Also available in

API
GET /account/username
TypeScript
nextmail.account.getUsername()
Python
account.get_username()
Ruby
account.get_username
PHP
account->getUsername
Java
account().getUsername
C#
Account.GetUsernameAsync
CLI
nextmail account get-username

Account.CheckUsername

Check a username

Scopesaccount:read
Signature
CheckUsername(ctx context.Context, username string, opts ...nextmail.RequestOption) (nextmail.Object, error)

Says whether the person could choose a username, without choosing it, and why not when they could not. The username is lowercased and its spaces become dots before it is checked, as the app does, and username in the answer is the form that was checked.

Parameters

usernamestringRequired

Up to 60 characters before it is tidied.

nextmail.WithAPIKeystring

Overrides the client's API key for this call only.

Returns

The nextmail.Object with status, available and a message that says why.

Example

check, err := client.Account.CheckUsername(ctx, "ada.lovelace")if err != nil {	return err} fmt.Println(check.Bool("available"), check.String("message"))

Notes

  • status is current for the username the person already has, and available is false for it.

Also available in

API
GET /account/username/availability
TypeScript
nextmail.account.checkUsername()
Python
account.check_username()
Ruby
account.check_username
PHP
account->checkUsername
Java
account().checkUsername
C#
Account.CheckUsernameAsync
CLI
nextmail account check-username

Account.SetUsername

Choose your username

Scopesaccount:write
Signature
SetUsername(ctx context.Context, username string, opts ...nextmail.RequestOption) (nextmail.Object, error)

Sets the person's username for good, and with it their free address. Once chosen it never changes: a second choice is refused with 409 username_locked. A username another account has is a 409 username_taken, and one that is too short, too long, reserved or not lowercase letters, numbers and single dots is a 422 invalid_parameter on username. Check one first with CheckUsername.

Parameters

usernamestringRequired

3 to 30 lowercase letters, numbers and single dots once it is tidied.

nextmail.WithAPIKeystring

Overrides the client's API key for this call only.

Returns

The nextmail.Object with chosen: true.

Example

username, err := client.Account.SetUsername(ctx, "ada.lovelace")if err != nil {	return err} fmt.Println(username.String("address"), username.String("object"))

Notes

  • Not retried automatically: a retry after a lost response would be refused with username_locked, because the first call already chose it.

Also available in

API
PUT /account/username
TypeScript
nextmail.account.setUsername()
Python
account.set_username()
Ruby
account.set_username
PHP
account->setUsername
Java
account().setUsername
C#
Account.SetUsernameAsync
CLI
nextmail account set-username

Account.ListConnectedApps

List your connected apps

Scopesaccount:read
Signature
ListConnectedApps(ctx context.Context, opts ...nextmail.RequestOption) ([]nextmail.Object, error)

Returns every app the person connected with OAuth, as Account, Connected apps lists them: the workspace and the permissions each may reach, until when, how many tokens it holds, and until when it may make changes that ask for a verification code without one. current marks the app making the call.

What an app may reach is changed in the app, never through an app.

Parameters

nextmail.WithAPIKeystring

Overrides the client's API key for this call only.

Returns

A []nextmail.Object, each with clientId, name, kind, status, grant and tokenCount.

Example

apps, err := client.Account.ListConnectedApps(ctx)if err != nil {	return err} for _, app := range apps {	fmt.Println(app.String("name"), app.String("status"), app.Bool("current"))}

Notes

  • A sign-in of the command line tool shows as kind: 'cli', with its device in cliDevice.

Also available in

API
GET /account/connected-apps
TypeScript
nextmail.account.listConnectedApps()
Python
account.list_connected_apps()
Ruby
account.list_connected_apps
PHP
account->listConnectedApps
Java
account().listConnectedApps
C#
Account.ListConnectedAppsAsync
CLI
nextmail account list-connected-apps

Account.ListConnectedAppRequests

Read the request log of a connected app

Scopesaccount:readPages through results
Signature
ListConnectedAppRequests(ctx context.Context, clientID string, opts ...nextmail.RequestOption) (*nextmail.Page, error)

Returns one page of the REST calls an app the person connected made with the access they gave it, newest first, as Request log in the menu of the app under Account, Connected apps shows them. Each call has its method, path, status, how long it took and the error code of a refusal, and never a body, a query string or the address it came from. The command line tool signed in from a browser is in it too. Calls made under an earlier connection of the same app are not: connecting it again starts a new log. nextmail.WithFailedOnly, nextmail.WithStatusCodes, nextmail.WithSince and nextmail.WithUntil narrow it, and they combine.

Parameters

clientIDstringRequired

The app's clientId from ListConnectedApps.

nextmail.WithFailedOnlybool

Only calls answered with a status of 400 or more.

nextmail.WithStatusCodes...int

Only calls answered with one of these HTTP status codes, such as 401 and 403. At most 20, each from 100 to 599, sent comma-separated as status.

nextmail.WithSincetime.Time

Only calls at or after this instant. A time.Time, sent as an ISO 8601 instant.

nextmail.WithUntiltime.Time

Only calls before this instant. It has to be later than since, or the server answers 400 invalid_parameter.

nextmail.WithLimitint

Calls per page, a whole number from 1 to 100. The server defaults to 25.

nextmail.WithCursorstring

The NextCursor of the previous page, passed back unchanged. Leave it out for the first page.

nextmail.WithAPIKeystring

Overrides the client's API key for this call only.

Returns

The *nextmail.Page with Items, HasMore and NextCursor. Each item has id, clientId, workspaceId, requestId, method, path, status, errorCode, durationMs, userAgent and createdAt.

Example

page, err := client.Account.ListConnectedAppRequests(ctx, "app_3f9c2a7b1e4d8f60", nextmail.WithFailedOnly(true), nextmail.WithLimit(50))if err != nil {	return err} for _, request := range page.Items {	fmt.Println(request.String("createdAt"), request.String("method"), request.String("path"), request.Int("status"), request.String("errorCode"))} fmt.Println(page.HasMore, page.NextCursor)

Notes

  • An app the person never connected is a 404 resource_not_found, and a cursor this log did not hand out is a 400 invalid_cursor.

  • Calls made with an API key are in the request log of that key, Keys.ListRequests, not here.

Also available in

API
GET /account/connected-apps/{clientId}/requests
TypeScript
nextmail.account.listConnectedAppRequests()
Python
account.list_connected_app_requests()
Ruby
account.list_connected_app_requests
PHP
account->listConnectedAppRequests
Java
account().listConnectedAppRequests
C#
Account.ListConnectedAppRequestsAsync
CLI
nextmail account list-connected-app-requests

Account.ListAllConnectedAppRequests

Collect the whole request log of a connected app into one slice

Scopesaccount:readPages through results
Signature
ListAllConnectedAppRequests(ctx context.Context, clientID string, opts ...nextmail.RequestOption) ([]nextmail.Object, error)

Walks every page of ListConnectedAppRequests under the same filters. The log is never pruned, so give it a window unless you mean to read a busy app's whole history, or use IterateConnectedAppRequests to stop early.

Parameters

clientIDstringRequired

The app's clientId from ListConnectedApps.

nextmail.WithFailedOnlybool

Only calls answered with a status of 400 or more.

nextmail.WithStatusCodes...int

Only calls answered with one of these HTTP status codes, such as 401 and 403. At most 20, each from 100 to 599, sent comma-separated as status.

nextmail.WithSincetime.Time

Only calls at or after this instant. A time.Time, sent as an ISO 8601 instant.

nextmail.WithUntiltime.Time

Only calls before this instant. It has to be later than since, or the server answers 400 invalid_parameter.

nextmail.WithLimitint

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

nextmail.WithCursorstring

Starts the walk from this cursor instead of the newest call.

nextmail.WithAPIKeystring

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

Returns

A []nextmail.Object, newest first.

Example

today, err := client.Account.ListAllConnectedAppRequests(ctx, "app_3f9c2a7b1e4d8f60", nextmail.WithSince(time.Now().Add(-24*time.Hour)), nextmail.WithLimit(100))if err != nil {	return err} fmt.Println(len(today), "calls in the last day")

Notes

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

Also available in

API
GET /account/connected-apps/{clientId}/requests
TypeScript
nextmail.account.listAllConnectedAppRequests()
Python
account.list_all_connected_app_requests()
Ruby
account.list_all_connected_app_requests
PHP
account->listAllConnectedAppRequests
Java
account().listAllConnectedAppRequests
C#
Account.ListAllConnectedAppRequestsAsync

Account.IterateConnectedAppRequests

Stream the request log of a connected app one call at a time

Scopesaccount:readPages through results
Signature
IterateConnectedAppRequests(ctx context.Context, clientID string, opts ...nextmail.RequestOption) *nextmail.Iterator

An iterator over ListConnectedAppRequests under the same filters, fetching a page only when the one before is drained.

Parameters

clientIDstringRequired

The app's clientId from ListConnectedApps.

nextmail.WithFailedOnlybool

Only calls answered with a status of 400 or more.

nextmail.WithStatusCodes...int

Only calls answered with one of these HTTP status codes, such as 401 and 403. At most 20, each from 100 to 599, sent comma-separated as status.

nextmail.WithSincetime.Time

Only calls at or after this instant. A time.Time, sent as an ISO 8601 instant.

nextmail.WithUntiltime.Time

Only calls before this instant. It has to be later than since, or the server answers 400 invalid_parameter.

nextmail.WithLimitint

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

nextmail.WithCursorstring

Starts the walk from this cursor instead of the newest call.

nextmail.WithAPIKeystring

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

Returns

The *nextmail.Iterator yielding one call per step, newest first.

Example

for request, err := range client.Account.IterateConnectedAppRequests(ctx, "app_3f9c2a7b1e4d8f60", nextmail.WithFailedOnly(true)).All() {	if err != nil {		return err	} 	fmt.Println("Latest refused call at", request.String("createdAt"), request.String("path")) 	break}

Notes

  • Breaking out of the loop stops the walk, and no further page is fetched.

Also available in

API
GET /account/connected-apps/{clientId}/requests
TypeScript
nextmail.account.iterateConnectedAppRequests()
Python
account.iterate_connected_app_requests()
Ruby
account.iterate_connected_app_requests
PHP
account->iterateConnectedAppRequests
Java
account().iterateConnectedAppRequests
C#
Account.IterateConnectedAppRequestsAsync

Account.RevokeConnectedApp

Remove a connected app

Scopesaccount:write
Signature
RevokeConnectedApp(ctx context.Context, clientID string, opts ...nextmail.RequestOption) (nextmail.Object, error)

Deletes every token the app holds and the access the person gave it, so its next call is refused and it has to ask again, as removing it in Account, Connected apps does. Removing the app making the call disconnects it.

Parameters

clientIDstringRequired

The app's clientId from ListConnectedApps.

nextmail.WithAPIKeystring

Overrides the client's API key for this call only.

Returns

The nextmail.Object with revoked: true and tokensRevoked.

Example

app, err := client.Account.RevokeConnectedApp(ctx, "app_3f9c2a7b1e4d8f60")if err != nil {	return err} fmt.Println(app.String("object"))

Notes

  • An app the person never connected is a 404 resource_not_found.

  • Not retried automatically. A retry after a lost response is a 404, since the app is already gone.

Also available in

API
DELETE /account/connected-apps/{clientId}
TypeScript
nextmail.account.revokeConnectedApp()
Python
account.revoke_connected_app()
Ruby
account.revoke_connected_app
PHP
account->revokeConnectedApp
Java
account().revokeConnectedApp
C#
Account.RevokeConnectedAppAsync
CLI
nextmail account revoke-connected-app

Account.ListSessions

List your signed-in devices

Scopesaccount:read
Signature
ListSessions(ctx context.Context, opts ...nextmail.RequestOption) ([]nextmail.Object, error)

Returns every browser and phone the person is signed in on, as Account, Security lists them, most recently used first: the browser and system, the country and city it was last used from, how it signed in and when.

No address is ever recorded, only the place. A key or an app is not a signed-in device, so current is always false here.

Parameters

nextmail.WithAPIKeystring

Overrides the client's API key for this call only.

Returns

A []nextmail.Object, each with id, device, authMethod, country, city, createdAt, lastActiveAt and expiresAt.

Example

sessions, err := client.Account.ListSessions(ctx)if err != nil {	return err} for _, session := range sessions {	device := session.Object("device") 	fmt.Println(device.String("browser"), device.String("os"), session.String("city"), session.String("lastActiveAt"))}

Notes

  • lastActiveAt is accurate to within ten minutes.

  • authMethod is null for a device that signed in before it was recorded. Its values are in constants.SessionAuthMethodsValues, and the kinds of device in constants.SessionDeviceKindsValues.

Also available in

API
GET /account/sessions
TypeScript
nextmail.account.listSessions()
Python
account.list_sessions()
Ruby
account.list_sessions
PHP
account->listSessions
Java
account().listSessions
C#
Account.ListSessionsAsync
CLI
nextmail account list-sessions

Account.RevokeSession

Sign out one device

Scopesaccount:write
Signature
RevokeSession(ctx context.Context, sessionID string, opts ...nextmail.RequestOption) (nextmail.Object, error)

Signs one browser or phone out, as Sign out next to it in Account, Security does. Its next request is refused at once, and a phone stops getting notifications. It is written to the person's security log.

Parameters

sessionIDstringRequired

The device's id from ListSessions.

nextmail.WithAPIKeystring

Overrides the client's API key for this call only.

Returns

The nextmail.Object with the device id and revoked: true.

Example

sessions, err := client.Account.ListSessions(ctx)if err != nil {	return err} for _, session := range sessions {	if session.Object("device").String("kind") != "browser" {		continue	} 	revoked, err := client.Account.RevokeSession(ctx, session.ID())	if err != nil {		return err	} 	fmt.Println(revoked.ID(), revoked.Bool("revoked"))}

Notes

  • A device that is not signed in to the account is a 404 resource_not_found.

  • Not retried automatically. A retry after a lost response is a 404, since the device is already signed out.

Also available in

API
DELETE /account/sessions/{sessionId}
TypeScript
nextmail.account.revokeSession()
Python
account.revoke_session()
Ruby
account.revoke_session
PHP
account->revokeSession
Java
account().revokeSession
C#
Account.RevokeSessionAsync
CLI
nextmail account revoke-session

Account.RevokeSessions

Sign out everywhere

Scopesaccount:write
Signature
RevokeSessions(ctx context.Context, opts ...nextmail.RequestOption) (nextmail.Object, error)

Signs the person out of every browser and phone at once, for when a device is lost or a password may have leaked. Each one is refused on its next request.

With nextmail.WithConnectedApps(true) every connected app is removed as well, except the app making the call. A key or an app is not a signed-in device, so the call never ends its own access.

Parameters

nextmail.WithConnectedAppsbool

Also removes every connected app, apart from the one making the call. Left out, apps stay.

nextmail.WithAPIKeystring

Overrides the client's API key for this call only.

Returns

The nextmail.Object with sessionsRevoked and appsRevoked.

Example

swept, err := client.Account.RevokeSessions(ctx, nextmail.WithConnectedApps(true))if err != nil {	return err} fmt.Println(swept.Int("sessionsRevoked"), "devices and", swept.Int("appsRevoked"), "apps signed out")

Notes

  • Safe to repeat: a second call finds nothing left and answers zero for both counts.

Also available in

API
DELETE /account/sessions
TypeScript
nextmail.account.revokeSessions()
Python
account.revoke_sessions()
Ruby
account.revoke_sessions
PHP
account->revokeSessions
Java
account().revokeSessions
C#
Account.RevokeSessionsAsync
CLI
nextmail account revoke-sessions

Account.ListSecurityEvents

Read your security log

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

Returns one page of what happened to the sign-in of the account, newest first: each sign-in with its device and place, devices signed out, password changes and resets, two-factor turned on or off, and passkeys added or removed. Nothing is ever removed from it.

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's API key for this call only.

Returns

The *nextmail.Page with Items, HasMore and NextCursor. Each item has kind, at, device, country, city, authMethod and detail.

Example

page, err := client.Account.ListSecurityEvents(ctx, nextmail.WithLimit(50))if err != nil {	return err} for _, event := range page.Items {	fmt.Println(event.String("at"), event.String("kind"), event.String("city"))} fmt.Println(page.HasMore, page.NextCursor)

Notes

  • A sign-in from a device not seen before has detail.newDevice: true, and the person is told by email.

  • Every kind is in constants.SecurityEventKindsValues.

  • A cursor that names nothing in this list is 400 invalid_cursor.

Also available in

API
GET /account/security-events
TypeScript
nextmail.account.listSecurityEvents()
Python
account.list_security_events()
Ruby
account.list_security_events
PHP
account->listSecurityEvents
Java
account().listSecurityEvents
C#
Account.ListSecurityEventsAsync
CLI
nextmail account list-security-events

Account.ListAllSecurityEvents

Collect your whole security log into one slice

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

Walks every page of ListSecurityEvents. The log is never pruned, so use IterateSecurityEvents to stop early on an old account.

Parameters

nextmail.WithLimitint

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

nextmail.WithCursorstring

Starts the walk from this cursor instead of the newest entry.

nextmail.WithAPIKeystring

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

Returns

A []nextmail.Object, newest first.

Example

events, err := client.Account.ListAllSecurityEvents(ctx, nextmail.WithLimit(100))if err != nil {	return err} signIns := 0 for _, event := range events {	if event.String("kind") == "sign-in" {		signIns++	}} fmt.Println(signIns, "sign-ins on record")

Notes

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

Also available in

API
GET /account/security-events
TypeScript
nextmail.account.listAllSecurityEvents()
Python
account.list_all_security_events()
Ruby
account.list_all_security_events
PHP
account->listAllSecurityEvents
Java
account().listAllSecurityEvents
C#
Account.ListAllSecurityEventsAsync

Account.IterateSecurityEvents

Stream your security log one entry at a time

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

An iterator over ListSecurityEvents, fetching a page only when the one before is drained.

Parameters

nextmail.WithLimitint

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

nextmail.WithCursorstring

Starts the walk from this cursor instead of the newest entry.

nextmail.WithAPIKeystring

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

Returns

The *nextmail.Iterator yielding one entry per step, newest first.

Example

for event, err := range client.Account.IterateSecurityEvents(ctx).All() {	if err != nil {		return err	} 	if event.String("kind") == "password-changed" {		fmt.Println("Password last changed", event.String("at")) 		break	}}

Notes

  • Breaking out of the loop stops the walk, and no further page is fetched.

Also available in

API
GET /account/security-events
TypeScript
nextmail.account.iterateSecurityEvents()
Python
account.iterate_security_events()
Ruby
account.iterate_security_events
PHP
account->iterateSecurityEvents
Java
account().iterateSecurityEvents
C#
Account.IterateSecurityEventsAsync

Account.ListPasskeys

List your passkeys

Scopesaccount:read
Signature
ListPasskeys(ctx context.Context, opts ...nextmail.RequestOption) ([]nextmail.Object, error)

Returns the passkeys that can sign in to the account, oldest first, each with its name, whether it is synced between the person's devices and when it was last used.

A passkey is added on the device that holds it, in Account, Security, never through the API.

Parameters

nextmail.WithAPIKeystring

Overrides the client's API key for this call only.

Returns

A []nextmail.Object, each with id, name, synced, transports, createdAt and lastUsedAt.

Example

passkeys, err := client.Account.ListPasskeys(ctx)if err != nil {	return err} for _, passkey := range passkeys {	fmt.Println(passkey.String("name"), passkey.Bool("synced"), passkey.String("lastUsedAt"))}

Notes

  • The key itself is never returned, only its name and when it was used.

  • lastUsedAt is null for a passkey that was never used, and every value of transports is in constants.PasskeyTransportsValues.

Also available in

API
GET /account/passkeys
TypeScript
nextmail.account.listPasskeys()
Python
account.list_passkeys()
Ruby
account.list_passkeys
PHP
account->listPasskeys
Java
account().listPasskeys
C#
Account.ListPasskeysAsync
CLI
nextmail account list-passkeys

Account.RenamePasskey

Rename a passkey

Scopesaccount:write
Signature
RenamePasskey(ctx context.Context, passkeyID string, name string, opts ...nextmail.RequestOption) (nextmail.Object, error)

Gives a passkey a name the person will recognise, such as the device that holds it.

Parameters

passkeyIDstringRequired

The passkey's id from ListPasskeys.

namestringRequired

The new name, 1 to 60 characters.

nextmail.WithAPIKeystring

Overrides the client's API key for this call only.

Returns

The nextmail.Object with its new name.

Example

passkey, err := client.Account.RenamePasskey(ctx, "pk_8d2f6a1c-4b7e-4c35-9a10-6e3f5b2d7c84", "Work laptop")if err != nil {	return err} fmt.Println(passkey.ID(), passkey.String("name"))

Notes

Also available in

API
PATCH /account/passkeys/{passkeyId}
TypeScript
nextmail.account.renamePasskey()
Python
account.rename_passkey()
Ruby
account.rename_passkey
PHP
account->renamePasskey
Java
account().renamePasskey
C#
Account.RenamePasskeyAsync
CLI
nextmail account rename-passkey

Account.RemovePasskey

Remove a passkey

Scopesaccount:write
Signature
RemovePasskey(ctx context.Context, passkeyID string, opts ...nextmail.RequestOption) (nextmail.Object, error)

Removes a passkey, so it can no longer sign in or confirm a change. The person is told by email, and it is written to their security log. The passkey stays on the device until they delete it there.

Parameters

passkeyIDstringRequired

The passkey's id from ListPasskeys.

nextmail.WithAPIKeystring

Overrides the client's API key for this call only.

Returns

The nextmail.Object with the passkey id and removed: true.

Example

removed, err := client.Account.RemovePasskey(ctx, "pk_8d2f6a1c-4b7e-4c35-9a10-6e3f5b2d7c84")if err != nil {	return err} fmt.Println(removed.ID(), removed.Bool("removed"))

Notes

  • A passkey that is not on the account is a 404 resource_not_found.

  • Not retried automatically. A retry after a lost response is a 404, since the passkey is already gone.

Also available in

API
DELETE /account/passkeys/{passkeyId}
TypeScript
nextmail.account.removePasskey()
Python
account.remove_passkey()
Ruby
account.remove_passkey
PHP
account->removePasskey
Java
account().removePasskey
C#
Account.RemovePasskeyAsync
CLI
nextmail account remove-passkey

Account.ListInvitations

List your invitations

Scopesaccount:read
Signature
ListInvitations(ctx context.Context, opts ...nextmail.RequestOption) ([]nextmail.Object, error)

Returns the invitations to join a workspace that are waiting for the address the person signs in with, oldest first. Expired, accepted and withdrawn ones are left out. The invitations a workspace sent are Members.ListInvitations instead.

Parameters

nextmail.WithAPIKeystring

Overrides the client's API key for this call only.

Returns

A []nextmail.Object, each with id, workspaceName, roleName, inviterName, addresses and expiresAt.

Example

invitations, err := client.Account.ListInvitations(ctx)if err != nil {	return err} for _, invitation := range invitations {	fmt.Println(invitation.String("workspaceName"), invitation.String("roleName"))}

Notes

  • addresses counts the addresses and the whole domains the invitation gives together.

Also available in

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

Account.AcceptInvitation

Accept an invitation

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

Joins the workspace with the role and the addresses the invitation gives, as accepting it in the app or from its link does. nextmail.WithActivate also makes it the workspace the app opens for the person.

A workspace that asks everyone in it to sign in with two-factor authentication is refused with 403 two_factor_required until the person turns it on. An invitation that expired, was withdrawn or went to another address is a 422, and one that is not waiting any more a 404 invitation_not_found.

Parameters

invitationIDstringRequired

An invitation id from ListInvitations.

nextmail.WithActivatebool

True to make it the workspace the app opens. Defaults to false.

nextmail.WithAPIKeystring

Overrides the client's API key for this call only.

Returns

The nextmail.Object with workspaceId, workspaceName, addressesGranted, domainsGranted and activated.

Example

joined, err := client.Account.AcceptInvitation(ctx, "winv_6bb640f5b99e47deb758f1f5", nextmail.WithActivate(true))if err != nil {	return err} fmt.Println(joined.String("workspaceName"))

Notes

  • Retried automatically on network failure, since accepting an invitation the person already accepted succeeds again and changes nothing.

Also available in

API
POST /account/invitations/{invitationId}/accept
TypeScript
nextmail.account.acceptInvitation()
Python
account.accept_invitation()
Ruby
account.accept_invitation
PHP
account->acceptInvitation
Java
account().acceptInvitation
C#
Account.AcceptInvitationAsync
CLI
nextmail account accept-invitation

Account.DeclineInvitation

Decline an invitation

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

Turns the invitation down, so its link stops working, and tells whoever sent it. It cannot be taken back: they have to invite the person again. An invitation the person already accepted is refused with 409 invitation_accepted.

Parameters

invitationIDstringRequired

An invitation id from ListInvitations.

nextmail.WithAPIKeystring

Overrides the client's API key for this call only.

Returns

The nextmail.Object with declined: true.

Example

invitation, err := client.Account.DeclineInvitation(ctx, "winv_6bb640f5b99e47deb758f1f5")if err != nil {	return err} fmt.Println(invitation.String("id"), invitation.String("object"))

Notes

  • Retried automatically on network failure, since declining twice changes nothing.

Also available in

API
POST /account/invitations/{invitationId}/decline
TypeScript
nextmail.account.declineInvitation()
Python
account.decline_invitation()
Ruby
account.decline_invitation
PHP
account->declineInvitation
Java
account().declineInvitation
C#
Account.DeclineInvitationAsync
CLI
nextmail account decline-invitation