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.GetNotificationsAccount.SetEmailNotificationAccount.SetPushMutedAccount.SetPhotoAccount.RemovePhotoAccount.GetUsernameAccount.CheckUsernameAccount.SetUsernameAccount.ListConnectedAppsAccount.ListConnectedAppRequestsAccount.ListAllConnectedAppRequestsAccount.IterateConnectedAppRequestsAccount.RevokeConnectedAppAccount.ListSessionsAccount.RevokeSessionAccount.RevokeSessionsAccount.ListSecurityEventsAccount.ListAllSecurityEventsAccount.IterateSecurityEventsAccount.ListPasskeysAccount.RenamePasskeyAccount.RemovePasskeyAccount.ListInvitationsAccount.AcceptInvitationAccount.DeclineInvitation
Account.GetNotifications
Read your notification settings
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.WithAPIKeystringOverrides 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
accountandbillingemail are always on, andrequiredsays so.
Also available in
Account.SetEmailNotification
Turn a kind of email on or off
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
categorystringRequiredaccount,billing,activityorproduct.enabledboolRequiredTrue to receive that email, false to stop it.
nextmail.WithAPIKeystringOverrides 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
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
workspaceIDstringRequiredA workspace id from
Workspaces.List.mutedboolRequiredTrue to mute it, false to let it notify again.
nextmail.WithAPIKeystringOverrides 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
Account.SetPhoto
Set your profile photo
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.ReaderRequiredThe image, as an
io.Reader.nextmail.WithContentTypestringimage/png,image/jpeg,image/webporimage/gif. The server needs it to accept the image.nextmail.WithAPIKeystringOverrides 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
Account.RemovePhoto
Remove your profile photo
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.WithAPIKeystringOverrides 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
Account.GetUsername
Read your username
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.WithAPIKeystringOverrides 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
Account.CheckUsername
Check a username
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
usernamestringRequiredUp to 60 characters before it is tidied.
nextmail.WithAPIKeystringOverrides 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
statusiscurrentfor the username the person already has, andavailableis false for it.
Also available in
Account.SetUsername
Choose your username
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
usernamestringRequired3 to 30 lowercase letters, numbers and single dots once it is tidied.
nextmail.WithAPIKeystringOverrides 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
Account.ListConnectedApps
List your connected apps
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.WithAPIKeystringOverrides 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 incliDevice.
Also available in
Account.ListConnectedAppRequests
Read the request log of a connected app
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
clientIDstringRequiredThe app's
clientIdfromListConnectedApps.nextmail.WithFailedOnlyboolOnly calls answered with a status of 400 or more.
nextmail.WithStatusCodes...intOnly calls answered with one of these HTTP status codes, such as
401and403. At most 20, each from 100 to 599, sent comma-separated asstatus.nextmail.WithSincetime.TimeOnly calls at or after this instant. A
time.Time, sent as an ISO 8601 instant.nextmail.WithUntiltime.TimeOnly calls before this instant. It has to be later than
since, or the server answers 400invalid_parameter.nextmail.WithLimitintCalls per page, a whole number from 1 to 100. The server defaults to 25.
nextmail.WithCursorstringThe
NextCursorof the previous page, passed back unchanged. Leave it out for the first page.nextmail.WithAPIKeystringOverrides 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 400invalid_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
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
clientIDstringRequiredThe app's
clientIdfromListConnectedApps.nextmail.WithFailedOnlyboolOnly calls answered with a status of 400 or more.
nextmail.WithStatusCodes...intOnly calls answered with one of these HTTP status codes, such as
401and403. At most 20, each from 100 to 599, sent comma-separated asstatus.nextmail.WithSincetime.TimeOnly calls at or after this instant. A
time.Time, sent as an ISO 8601 instant.nextmail.WithUntiltime.TimeOnly calls before this instant. It has to be later than
since, or the server answers 400invalid_parameter.nextmail.WithLimitintPage size for each request, 1 to 100. The server defaults to 25.
nextmail.WithCursorstringStarts the walk from this cursor instead of the newest call.
nextmail.WithAPIKeystringOverrides 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
IterateConnectedAppRequests(ctx context.Context, clientID string, opts ...nextmail.RequestOption) *nextmail.IteratorAn iterator over ListConnectedAppRequests under the same filters, fetching a page only when the one before is drained.
Parameters
clientIDstringRequiredThe app's
clientIdfromListConnectedApps.nextmail.WithFailedOnlyboolOnly calls answered with a status of 400 or more.
nextmail.WithStatusCodes...intOnly calls answered with one of these HTTP status codes, such as
401and403. At most 20, each from 100 to 599, sent comma-separated asstatus.nextmail.WithSincetime.TimeOnly calls at or after this instant. A
time.Time, sent as an ISO 8601 instant.nextmail.WithUntiltime.TimeOnly calls before this instant. It has to be later than
since, or the server answers 400invalid_parameter.nextmail.WithLimitintPage size for each request, 1 to 100. The server defaults to 25.
nextmail.WithCursorstringStarts the walk from this cursor instead of the newest call.
nextmail.WithAPIKeystringOverrides 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
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
clientIDstringRequiredThe app's
clientIdfromListConnectedApps.nextmail.WithAPIKeystringOverrides 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
Account.ListSessions
List your signed-in devices
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.WithAPIKeystringOverrides 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
lastActiveAtis accurate to within ten minutes.authMethodis null for a device that signed in before it was recorded. Its values are inconstants.SessionAuthMethodsValues, and the kinds of device inconstants.SessionDeviceKindsValues.
Also available in
Account.RevokeSession
Sign out one device
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
sessionIDstringRequiredThe device's
idfromListSessions.nextmail.WithAPIKeystringOverrides 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
Account.RevokeSessions
Sign out everywhere
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.WithConnectedAppsboolAlso removes every connected app, apart from the one making the call. Left out, apps stay.
nextmail.WithAPIKeystringOverrides 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
Account.ListSecurityEvents
Read your security log
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.WithLimitintPage size, from 1 to 100. The server defaults to 25.
nextmail.WithCursorstringThe
NextCursorof the previous page. Leave it out for the first page.nextmail.WithAPIKeystringOverrides 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
kindis inconstants.SecurityEventKindsValues.A cursor that names nothing in this list is 400
invalid_cursor.
Also available in
Account.ListAllSecurityEvents
Collect your whole security log into one slice
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.WithLimitintPage size for each request, 1 to 100. The server defaults to 25.
nextmail.WithCursorstringStarts the walk from this cursor instead of the newest entry.
nextmail.WithAPIKeystringOverrides 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
Account.IterateSecurityEvents
Stream your security log one entry at a time
IterateSecurityEvents(ctx context.Context, opts ...nextmail.RequestOption) *nextmail.IteratorAn iterator over ListSecurityEvents, fetching a page only when the one before is drained.
Parameters
nextmail.WithLimitintPage size for each request, 1 to 100. The server defaults to 25.
nextmail.WithCursorstringStarts the walk from this cursor instead of the newest entry.
nextmail.WithAPIKeystringOverrides 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
Account.ListPasskeys
List your passkeys
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.WithAPIKeystringOverrides 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.
lastUsedAtis null for a passkey that was never used, and every value oftransportsis inconstants.PasskeyTransportsValues.
Also available in
Account.RenamePasskey
Rename a passkey
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
passkeyIDstringRequiredThe passkey's
idfromListPasskeys.namestringRequiredThe new name, 1 to 60 characters.
nextmail.WithAPIKeystringOverrides 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
A passkey that is not on the account is a 404
resource_not_found.A name that is empty or longer than 60 characters is a 422
invalid_parameter.
Also available in
Account.RemovePasskey
Remove a passkey
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
passkeyIDstringRequiredThe passkey's
idfromListPasskeys.nextmail.WithAPIKeystringOverrides 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
Account.ListInvitations
List your invitations
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.WithAPIKeystringOverrides 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
addressescounts the addresses and the whole domains the invitation gives together.
Also available in
Account.AcceptInvitation
Accept an invitation
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
invitationIDstringRequiredAn invitation id from
ListInvitations.nextmail.WithActivateboolTrue to make it the workspace the app opens. Defaults to false.
nextmail.WithAPIKeystringOverrides 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
Account.DeclineInvitation
Decline an invitation
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
invitationIDstringRequiredAn invitation id from
ListInvitations.nextmail.WithAPIKeystringOverrides 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.
Google Workspace