Skip to the documentation
API

Directory sync

Every operation in this group: what it accepts, what it returns and the errors it can answer with.

Operations

Directory sync (SCIM) lets a company directory, such as Okta or Microsoft Entra, add people to the workspace and take them out again. These calls are the settings the owner sees on the Privacy tab: turn it on and off, read where it stands and who it synced, and choose the roles it gives. The directory itself calls the SCIM endpoints under /scim/v2 with the token. Reading needs members:read and every change needs members:write. Only the workspace owner, or a member whose role holds workspace:manage, may call it: an access token acting for anybody else is refused with 403 insufficient_authority.

GET/directory-sync

Read directory sync

Scopesmembers:readReads

Whether directory sync is on, the base URL to give the 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. Only the workspace owner, or a member whose role holds workspace:manage, may call it: an access token acting for anybody else is refused with 403 insufficient_authority.

Requires the members:read scope.

Returns

Where directory sync stands.

Errors

The errors every operation can return400401403404422429500Error catalog

Also available in

TypeScript
members.getDirectorySync()
Python
members.get_directory_sync()
Ruby
members.get_directory_sync
PHP
members->getDirectorySync
Go
Members.GetDirectorySync
Java
members().getDirectorySync
C#
Members.GetDirectorySyncAsync
CLI
nextmail members get-directory-sync
MCP
getDirectorySync

POST/directory-sync

Turn on directory sync

Scopesmembers:writeChanges data
Asks for a verification code

Turns directory sync on and returns the token the directory sends as its bearer token. 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. Directory sync comes with the Business and Enterprise plans: on any other plan the call is a 403 plan_required. Only the workspace owner, or a member whose role holds workspace:manage, may call 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, because the people it changes reach beyond them.

Requires the members:write scope.

Returns

Directory sync is on, with a new token.

Errors

403

The key lacks the scope, or may not send as that address.

step_up_required: the call was made with an OAuth access token that has not been verified in the last 60 minutes. Ask for a code with POST /security/step-up, send it to POST /security/step-up/verify, then repeat the call. The person can also choose Allow changes for 60 minutes on the app in Account settings, Connected apps, on the Nextmail website. An API key is never asked for a code.

The errors every operation can return400401404422429500Error catalog

Also available in

TypeScript
members.connectDirectorySync()
Python
members.connect_directory_sync()
Ruby
members.connect_directory_sync
PHP
members->connectDirectorySync
Go
Members.ConnectDirectorySync
Java
members().connectDirectorySync
C#
Members.ConnectDirectorySyncAsync
CLI
nextmail members connect-directory-sync
MCP
connectDirectorySync

DELETE/directory-sync

Turn off directory sync

Scopesmembers:writeDeletes
Asks for a verification code

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. Turning it off when it is off changes nothing. Only the workspace owner, or a member whose role holds workspace:manage, may call 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, because the people it changes reach beyond them.

Requires the members:write scope.

Returns

Directory sync is off.

Errors

403

The key lacks the scope, or may not send as that address.

step_up_required: the call was made with an OAuth access token that has not been verified in the last 60 minutes. Ask for a code with POST /security/step-up, send it to POST /security/step-up/verify, then repeat the call. The person can also choose Allow changes for 60 minutes on the app in Account settings, Connected apps, on the Nextmail website. An API key is never asked for a code.

The errors every operation can return400401404422429500Error catalog

Also available in

TypeScript
members.disconnectDirectorySync()
Python
members.disconnect_directory_sync()
Ruby
members.disconnect_directory_sync
PHP
members->disconnectDirectorySync
Go
Members.DisconnectDirectorySync
Java
members().disconnectDirectorySync
C#
Members.DisconnectDirectorySyncAsync
CLI
nextmail members disconnect-directory-sync
MCP
disconnectDirectorySync

GET/directory-sync/people

List the people the directory synced

Scopesmembers:readReads

The people the directory synced into the workspace, a page at a time and 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: pass startIndex plus the number of people returned for the next one, while that is at most total. Only the workspace owner, or a member whose role holds workspace:manage, may call it: an access token acting for anybody else is refused with 403 insufficient_authority.

Requires the members:read scope.

Query parameters

startIndexinteger

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

At least 1
countinteger

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

At least 1At most 100

Returns

A page of people.

Errors

The errors every operation can return400401403404422429500Error catalog

Also available in

TypeScript
members.listDirectoryPeople()
Python
members.list_directory_people()
Ruby
members.list_directory_people
PHP
members->listDirectoryPeople
Go
Members.ListDirectoryPeople
Java
members().listDirectoryPeople
C#
Members.ListDirectoryPeopleAsync
CLI
nextmail members list-directory-people
MCP
listDirectoryPeople

PUT/directory-sync/default-role

Choose the default role of directory sync

Scopesmembers:writeChanges data
Asks for a verification code

Chooses the role directory sync gives somebody that none of their groups gives a role. null goes back to the built-in Member role. The owner role cannot be given out this way (422 invalid_parameter), a role that is not in the workspace is a 422 role_not_found, and anybody but the owner can only give a role that holds nothing they lack themselves (403 insufficient_authority). It answers 409 directory_sync_not_connected while directory sync is off. Only the workspace owner, or a member whose role holds workspace:manage, may call 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, because the people it changes reach beyond them.

Requires the members:write scope.

Request body

roleIdstringRequired

The id of a role in this workspace, as the roles list names it, or null to give no role from the directory. The owner role can never be given out this way, and anybody but the owner can only give a role that holds nothing they lack themselves.

Can be null1 to 128 characters

Returns

Where directory sync stands now.

Errors

403

The key lacks the scope, or may not send as that address.

step_up_required: the call was made with an OAuth access token that has not been verified in the last 60 minutes. Ask for a code with POST /security/step-up, send it to POST /security/step-up/verify, then repeat the call. The person can also choose Allow changes for 60 minutes on the app in Account settings, Connected apps, on the Nextmail website. An API key is never asked for a code.

409

directory_sync_not_connected: directory sync is off.

The errors every operation can return400401404422429500Error catalog

Also available in

TypeScript
members.setDirectoryDefaultRole()
Python
members.set_directory_default_role()
Ruby
members.set_directory_default_role
PHP
members->setDirectoryDefaultRole
Go
Members.SetDirectoryDefaultRole
Java
members().setDirectoryDefaultRole
C#
Members.SetDirectoryDefaultRoleAsync
CLI
nextmail members set-directory-default-role
MCP
setDirectoryDefaultRole

PUT/directory-sync/groups/{groupId}/role

Choose the role of a directory group

Scopesmembers:writeChanges data
Asks for a verification code

Chooses the role a group the directory synced gives its people, and moves everyone in it to that role now. null stops the group giving a role, so its people fall back to the default role. The same rules about roles apply as for the default role, a group that is not in the workspace is a 404, and it answers 409 directory_sync_not_connected while directory sync is off. Only the workspace owner, or a member whose role holds workspace:manage, may call 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, because the people it changes reach beyond them.

Requires the members:write scope.

Path parameters

groupIdstringRequired

A group the directory synced, as GET /directory-sync lists it in groups.

Request body

roleIdstringRequired

The id of a role in this workspace, as the roles list names it, or null to give no role from the directory. The owner role can never be given out this way, and anybody but the owner can only give a role that holds nothing they lack themselves.

Can be null1 to 128 characters

Returns

Where directory sync stands now.

Errors

403

The key lacks the scope, or may not send as that address.

step_up_required: the call was made with an OAuth access token that has not been verified in the last 60 minutes. Ask for a code with POST /security/step-up, send it to POST /security/step-up/verify, then repeat the call. The person can also choose Allow changes for 60 minutes on the app in Account settings, Connected apps, on the Nextmail website. An API key is never asked for a code.

409

directory_sync_not_connected: directory sync is off.

The errors every operation can return400401404422429500Error catalog

Also available in

TypeScript
members.setDirectoryGroupRole()
Python
members.set_directory_group_role()
Ruby
members.set_directory_group_role
PHP
members->setDirectoryGroupRole
Go
Members.SetDirectoryGroupRole
Java
members().setDirectoryGroupRole
C#
Members.SetDirectoryGroupRoleAsync
CLI
nextmail members set-directory-group-role
MCP
setDirectoryGroupRole

Objects

DirectoryPersonobject

objectstringRequired
One of"directory_person"
idstringRequired

The person as the directory sync knows them.

userNamestringRequired

The user name the directory sent.

emailstringRequired

The email address the directory sent, or null when it sent none.

Can be null
namestringRequired

The name the directory sent, or null when it sent none.

Can be null
statestringRequired

member once they joined, invited while an invitation waits, waiting before one is sent, inactive when the directory switched them off.

One of"member""invited""waiting""inactive"
groupsstring[]Required

The names of the groups they are in.

updatedAtstringRequired

When the directory last changed them.

Formatdate-time

DirectoryPersonListobject

objectstringRequired
One of"list"
dataDirectoryPerson[]Required
totalintegerRequired

How many people the directory synced in all.

startIndexintegerRequired

Where this page starts, counted from 1.

DirectorySyncobject

objectstringRequired
One of"directory_sync"
connectedbooleanRequired

Whether directory sync is on.

availablebooleanRequired

Whether the plan of the workspace includes directory sync.

baseUrlstringRequired

The SCIM base URL to give the directory, the same for every workspace.

tokenLast4stringRequired

The last four characters of the token, to tell it apart. Null while it is off.

Can be null
tokenRotatedAtstringRequired

When the token in use was made. Null while it is off.

Can be nullFormatdate-time
lastSeenAtstringRequired

When the directory last called with the token, to the minute, or null if it never has.

Can be nullFormatdate-time
connectedAtstringRequired

When directory sync was turned on. Null while it is off.

Can be nullFormatdate-time
defaultRoleIdstringRequired

The role given to somebody that none of their groups gives a role, or null for the built-in Member role.

Can be null
usersobjectRequired

How many people the directory synced, and where they stand.

totalintegerRequired

Everybody the directory synced.

membersintegerRequired

Those who joined the workspace.

invitedintegerRequired

Those with an invitation waiting.

waitingintegerRequired

Those not invited yet.

inactiveintegerRequired

Those the directory switched off.

groupsobject[]Required

The groups the directory synced, oldest first.

idstringRequired

The group, as the role of a group is changed by.

displayNamestringRequired

Its name in the directory.

membersintegerRequired

How many synced people are in it.

roleIdstringRequired

The role it gives its people, or null when it gives none.

Can be null

DirectorySyncDisconnectedobject

objectstringRequired
One of"directory_sync"
disconnectedbooleanRequired

True when directory sync was on and is off now, false when it was already off.

DirectorySyncTokenobject

objectstringRequired
One of"directory_sync_token"
tokenstringRequired

The bearer token the directory sends. It is shown here only and can never be read again.

statusDirectorySyncRequired