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
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
POST/directory-sync
Turn on directory sync
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 withPOST /security/step-up, send it toPOST /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
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 withPOST /security/step-up, send it toPOST /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
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
startIndexintegerWhere the page starts, counted from 1. Leave it out for the first page.
At least 1countintegerHow 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
PUT/directory-sync/default-role
Choose the default role of directory sync
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
roleIdstringRequiredThe 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 withPOST /security/step-up, send it toPOST /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
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
groupIdstringRequiredA group the directory synced, as
GET /directory-synclists it ingroups.
Request body
roleIdstringRequiredThe 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 withPOST /security/step-up, send it toPOST /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" idstringRequiredThe person as the directory sync knows them.
userNamestringRequiredThe user name the directory sent.
emailstringRequiredThe email address the directory sent, or null when it sent none.
Can be nullnamestringRequiredThe name the directory sent, or null when it sent none.
Can be nullstatestringRequiredmemberonce they joined,invitedwhile an invitation waits,waitingbefore one is sent,inactivewhen the directory switched them off.One of"member""invited""waiting""inactive"groupsstring[]RequiredThe names of the groups they are in.
updatedAtstringRequiredWhen the directory last changed them.
Formatdate-time
DirectoryPersonListobject
objectstringRequired- One of
"list" dataDirectoryPerson[]RequiredtotalintegerRequiredHow many people the directory synced in all.
startIndexintegerRequiredWhere this page starts, counted from 1.
DirectorySyncobject
objectstringRequired- One of
"directory_sync" connectedbooleanRequiredWhether directory sync is on.
availablebooleanRequiredWhether the plan of the workspace includes directory sync.
baseUrlstringRequiredThe SCIM base URL to give the directory, the same for every workspace.
tokenLast4stringRequiredThe last four characters of the token, to tell it apart. Null while it is off.
Can be nulltokenRotatedAtstringRequiredWhen the token in use was made. Null while it is off.
Can be nullFormatdate-timelastSeenAtstringRequiredWhen the directory last called with the token, to the minute, or null if it never has.
Can be nullFormatdate-timeconnectedAtstringRequiredWhen directory sync was turned on. Null while it is off.
Can be nullFormatdate-timedefaultRoleIdstringRequiredThe role given to somebody that none of their groups gives a role, or null for the built-in Member role.
Can be nullusersobjectRequiredHow many people the directory synced, and where they stand.
totalintegerRequiredEverybody the directory synced.
membersintegerRequiredThose who joined the workspace.
invitedintegerRequiredThose with an invitation waiting.
waitingintegerRequiredThose not invited yet.
inactiveintegerRequiredThose the directory switched off.
groupsobject[]RequiredThe groups the directory synced, oldest first.
idstringRequiredThe group, as the role of a group is changed by.
displayNamestringRequiredIts name in the directory.
membersintegerRequiredHow many synced people are in it.
roleIdstringRequiredThe role it gives its people, or null when it gives none.
Can be null
DirectorySyncDisconnectedobject
objectstringRequired- One of
"directory_sync" disconnectedbooleanRequiredTrue when directory sync was on and is off now, false when it was already off.
DirectorySyncTokenobject
objectstringRequired- One of
"directory_sync_token" tokenstringRequiredThe bearer token the directory sends. It is shown here only and can never be read again.
statusDirectorySyncRequired
Google Workspace