Skip to the documentation
Java

client.workspaces()

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

Methods

The workspaces the person behind the key or the app can open: list them, create one, choose the one the app opens, offer the workspace the app belongs to to one of its members, and delete it. An API key acts for the workspace owner, and an app for the person who connected it.

workspaces().list

List your workspaces

Scopesaccount:read
Signature
Map<String, Object> list(RequestOptions options)

Returns every workspace the person behind the client can open, the ones they own first, as the workspace switcher of the app lists them. It is about the person, not the workspace the key belongs to. An API key answers for the workspace owner, and an app for the person who connected it.

activeWorkspaceId is the workspace the app opens for them, and primaryWorkspaceId the first one they made, which can never be deleted.

Parameters

options.apiKeyString

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

Returns

A map with data, a list of maps, one per workspace, and activeWorkspaceId and primaryWorkspaceId.

Example

Map<String, Object> result = client.workspaces().list(); System.out.println(result.get("object") + " " + result.get("activeWorkspaceId"));

Notes

  • The key or the app still acts for its own workspace in every other call.

Also available in

API
GET /workspaces
TypeScript
workspaces.list()
Python
workspaces.list()
Ruby
workspaces.list
PHP
workspaces->list
Go
Workspaces.List
C#
Workspaces.ListAsync
CLI
nextmail workspaces list

workspaces().create

Create a workspace

Scopesaccount:write
Signature
Map<String, Object> create(Map<String, Object> body, RequestOptions options)

Makes a new workspace owned by the person, on the Starter plan, and makes it the workspace the app opens for them, as creating one in the app does. The key or the app making the call keeps acting for its own workspace.

An account can own one workspace on the Starter plan. While it owns one, the call is refused with 403 workspace_allowance_reached and the message names that workspace: upgrade it first.

Pass idempotencyKey to make a retry safe. A retry with the same key and the same body returns the workspace the first call made, with replayed set to true, and makes nothing new. The same key with a different body is a 422 idempotency_key_reuse. keys().create with workspaceId then gives the new workspace a key of its own.

Parameters

body.nameStringRequired

Up to 64 characters. Leading and trailing spaces are trimmed.

options.idempotencyKeyString

Makes a retry safe: the same key with the same body returns the workspace the first call made, with replayed set to true. 1 to 255 letters, digits, _, ., : or -, and the same key with a different body is a 422 idempotency_key_reuse.

options.apiKeyString

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

Returns

A map with id, name, slug, active, true for a new workspace and on a replay while the app still opens it, and replayed.

Example

Map<String, Object> workspace = client.workspaces().create(Body.of("name", "Acme Support")); System.out.println(workspace.get("id") + " " + workspace.get("slug"));

Notes

  • Retried on network failure only when idempotencyKey is given, because a retry can then only replay the first workspace. Without one it is not retried, and the same name sent twice within ten seconds still returns the workspace the first call made.

Also available in

API
POST /workspaces
TypeScript
workspaces.create()
Python
workspaces.create()
Ruby
workspaces.create
PHP
workspaces->create
Go
Workspaces.Create
C#
Workspaces.CreateAsync
CLI
nextmail workspaces create

workspaces().getActive

Read the workspace the app opens

Scopesaccount:read
Signature
Map<String, Object> getActive(RequestOptions options)

Returns the workspace the app opens for the person when they sign in, or the one it falls back to when they never chose one. It is not the workspace the key or the app acts on, which never changes.

Parameters

options.apiKeyString

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

Returns

A map with id, name, slug, email, isOwner and createdAt.

Example

Map<String, Object> opened = client.workspaces().getActive(); System.out.println(opened.get("name") + " " + (Boolean.TRUE.equals(opened.get("isOwner")) ? "owner" : "member"));

Also available in

API
GET /workspaces/active
TypeScript
workspaces.getActive()
Python
workspaces.get_active()
Ruby
workspaces.get_active
PHP
workspaces->getActive
Go
Workspaces.GetActive
C#
Workspaces.GetActiveAsync
CLI
nextmail workspaces get-active

workspaces().setActive

Choose the workspace the app opens

Scopesaccount:write
Signature
Map<String, Object> setActive(String workspaceId, RequestOptions options)

Switches the workspace the app opens for the person, as the workspace switcher does, to any workspace they can open. It changes nothing for the key or the app making the call, which keeps acting for its own workspace.

Parameters

workspaceIdStringRequired

A workspace id from list.

options.apiKeyString

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

Returns

The same map as workspaces().getActive, for the workspace the app opens now.

Example

Map<String, Object> result = client.workspaces().setActive("10417196-e324-4283-af98-66ec62167c47"); System.out.println(result.get("id") + " " + result.get("email"));

Notes

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

  • Retried automatically on network failure, since choosing the same workspace twice changes nothing.

Also available in

API
PUT /workspaces/active
TypeScript
workspaces.setActive()
Python
workspaces.set_active()
Ruby
workspaces.set_active
PHP
workspaces->setActive
Go
Workspaces.SetActive
C#
Workspaces.SetActiveAsync
CLI
nextmail workspaces set-active

workspaces().delete

Delete a workspace

Scopesaccount:write
Signature
Map<String, Object> delete(String id, RequestOptions options)

Deletes a workspace the account owns, with its domains, addresses, mail and members, and cancels its plan. It cannot be undone. id is the workspace the key or the app belongs to, or another one the account owns, such as one create made. confirm has to be the name of the workspace, as list shows it, the same way the app asks the person to type it.

Only the owner may do it. An access token acting for a member is refused with 403 owner_only, and a key or an app limited to particular addresses or domains with 422 capability_unsupported. Another workspace takes a key with no role and no address or domain limit, made by the owner it acts for, or an app the owner connected with every address, or the call is 403 beyond_caller_authority on id. That workspace keeps its own rules: one that requires two-factor sign-in while the owner has neither an authenticator app nor a passkey is 403 two_factor_required, a suspended one 403 workspace_suspended, and a workspace the account does not own a 404. The first workspace an account made is refused with 409 first_workspace, and one with a domain being moved in or out with 409 domain_moving.

Parameters

idStringRequired

The workspace to delete: the one the key or the app belongs to, which me().get reports as workspaceId, or another one the account owns, by the id list or create returns.

options.confirmStringRequired

The name of the workspace. Letter case and the spaces around it do not matter. Sent as a query parameter.

options.apiKeyString

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

Returns

A map with id, deleted set to true and activeWorkspaceId, the workspace the app opens from now on.

Example

Map<String, Object> key = client.me().get(); Map<String, Object> result = client.workspaces().delete((String) key.get("workspaceId"), RequestOptions.of("confirm", "Acme Support")); System.out.println(result.get("id"));

Notes

  • 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. isStepUpRequired() on the error says so. An API key is never asked for a code.

  • The key or the app that deletes its own workspace loses it, so every later call with it is refused. Deleting another workspace leaves the calling key as it was, and the keys of the deleted workspace stop working.

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

Also available in

API
DELETE /workspaces/{id}
TypeScript
workspaces.delete()
Python
workspaces.delete()
Ruby
workspaces.delete
PHP
workspaces->delete
Go
Workspaces.Delete
C#
Workspaces.DeleteAsync
CLI
nextmail workspaces delete

workspaces().getOwnershipOffer

Read the offer to hand the workspace over

Scopesaccount:read
Signature
Map<String, Object> getOwnershipOffer(String id, RequestOptions options)

Returns the offer the owner made to hand the workspace to one of its members, while it waits: who it went to, when it was made, and when it ends unanswered, 7 days after it was made.

The app shows the offer to the owner alone, so it is a 404 ownership_offer_not_found when no offer is waiting and for anybody but the owner.

Parameters

idStringRequired

The id of the workspace the key or the app belongs to, which me().get reports as workspaceId. Any other id is a 404.

options.apiKeyString

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

Returns

A map with object set to ownership_offer, workspaceId, to, a map with the userId, name and email of the member it went to, offeredAt and expiresAt.

Example

Map<String, Object> key = client.me().get(); Map<String, Object> offer = client.workspaces().getOwnershipOffer((String) key.get("workspaceId"));Object to = offer.get("to") instanceof Map<?, ?> member ? member.get("email") : null; System.out.println("Offered to " + to + " until " + offer.get("expiresAt"));

Notes

  • An API key acts for the workspace owner, so it reads the offer the owner made.

Also available in

API
GET /workspaces/{id}/ownership-offer
TypeScript
workspaces.getOwnershipOffer()
Python
workspaces.get_ownership_offer()
Ruby
workspaces.get_ownership_offer
PHP
workspaces->getOwnershipOffer
Go
Workspaces.GetOwnershipOffer
C#
Workspaces.GetOwnershipOfferAsync
CLI
nextmail workspaces get-ownership-offer

workspaces().offerOwnership

Offer the workspace to a member

Scopesaccount:write
Signature
Map<String, Object> offerOwnership(String id, String userId, RequestOptions options)

Offers the workspace to one of its members, so they can become its owner and take over its plan and billing, as the owner can in the app. They are told by email and have 7 days to accept with account().acceptOwnershipOffer. Nothing changes until they do, and the owner then stays in the workspace as an admin.

A new offer replaces one that is waiting, and the person that one went to is told. The member has to have confirmed their email address and may not be a password sign-in for one address.

Only the workspace owner may make it, through an app they connected: an API key is refused with 403 console_only, an access token acting for a member with 403 owner_only, and an app limited to particular addresses or domains with 422 capability_unsupported, because the owner holds every address.

Parameters

idStringRequired

The id of the workspace the key or the app belongs to, which me().get reports as workspaceId. Any other id is a 404.

userIdStringRequired

The account id of the member who would become the owner, as members().list names it, not the email address.

options.apiKeyString

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

Returns

The same map as getOwnershipOffer, with to, offeredAt and expiresAt.

Example

Map<String, Object> key = client.me().get(); Map<String, Object> offer = client.workspaces().offerOwnership((String) key.get("workspaceId"), "q7Vd3kX9mT2pLw8RzN4bYc6HfJ1sGa5E");Object to = offer.get("to") instanceof Map<?, ?> member ? member.get("email") : null; System.out.println(to + " has until " + offer.get("expiresAt") + " to accept");

Notes

  • Somebody who is not a member is 422 member_not_found on userId, and the owner themselves 422 invalid_parameter. A member who has not confirmed their email address, or whose account is suspended, is 409 ownership_not_eligible, and a password sign-in for one address is 403 mailbox_login. While a domain is being moved into or out of the workspace the call is 409 domain_moving.

  • 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. isStepUpRequired() on the error says so. A key cannot give a code, which is why an API key is refused with 403 console_only and the change is made in the console.

  • Not retried automatically, since every attempt emails the member. The success status is 201.

Also available in

API
POST /workspaces/{id}/ownership-offer
TypeScript
workspaces.offerOwnership()
Python
workspaces.offer_ownership()
Ruby
workspaces.offer_ownership
PHP
workspaces->offerOwnership
Go
Workspaces.OfferOwnership
C#
Workspaces.OfferOwnershipAsync
CLI
nextmail workspaces offer-ownership

workspaces().withdrawOwnershipOffer

Withdraw the offer to hand the workspace over

Scopesaccount:write
Signature
Map<String, Object> withdrawOwnershipOffer(String id, RequestOptions options)

Withdraws the offer before it is answered, and the person it went to is told. withdrawn is false when no offer was waiting, and then nothing changes.

Only the workspace owner may withdraw it, through an app they connected: an API key is refused with 403 console_only, an access token acting for a member with 403 owner_only, and an app limited to particular addresses or domains with 422 capability_unsupported, because the owner holds every address.

Parameters

idStringRequired

The id of the workspace the key or the app belongs to, which me().get reports as workspaceId. Any other id is a 404.

options.apiKeyString

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

Returns

A map with object set to ownership_offer, workspaceId and withdrawn.

Example

Map<String, Object> key = client.me().get(); Map<String, Object> result = client.workspaces().withdrawOwnershipOffer((String) key.get("workspaceId")); System.out.println(Boolean.TRUE.equals(result.get("withdrawn")) ? "Offer withdrawn" : "No offer was waiting");

Notes

  • An access token is asked for no verification code here, since withdrawing an offer only keeps the workspace with its owner. An API key is refused with 403 console_only all the same, as it is for offering, accepting and declining.

  • Not retried automatically. A second call after a lost response answers with withdrawn set to false and changes nothing.

Also available in

API
DELETE /workspaces/{id}/ownership-offer
TypeScript
workspaces.withdrawOwnershipOffer()
Python
workspaces.withdraw_ownership_offer()
Ruby
workspaces.withdraw_ownership_offer
PHP
workspaces->withdrawOwnershipOffer
Go
Workspaces.WithdrawOwnershipOffer
C#
Workspaces.WithdrawOwnershipOfferAsync
CLI
nextmail workspaces withdraw-ownership-offer

Give it an address.
Watch it work.

MCP, the API and the command line come with every plan, the free one included. Connect a client and approve exactly what it reaches.

Read https://nextmail.sh/agent.md and follow it. Then tell me what I need to do to sign you in to my Nextmail mailbox. If I have no account yet, create one with my address and ask me for the code that arrives. Wait for my go-ahead before you send anything.

© 2026 Nextmail. All rights reserved.