> ## Documentation Index
> Fetch the complete documentation index at: https://developer.rocket.chat/llms.txt
> Use this file to discover all available pages before exploring further.
# LDAP Sync
>
Syncs your LDAP data based on the data sync configurations. This endpoint requires 2FA.
Make sure LDAP is enabled before using this endpoint.
Permission required: `sync-auth-services-users`.
### Changelog
| Version | Description |
| ---------------- | ------------|
|9.0.0 | Moved to premium plans. Added the `LDAP_Background_Sync_disabled` and `LDAP_Sync_failed` errors. |
|5.2.0 | Include `syncAvatars` |
|4.0.0 | Added |
## OpenAPI
````json POST /api/v1/ldap.syncNow
{
"openapi": "3.0.0",
"info": {
"version": "1.0.0",
"title": "User Management"
},
"servers": [
{
"url": "https://apiexplorer.support.rocket.chat"
}
],
"tags": [
{
"name": "LDAP"
},
{
"name": "Permissions"
},
{
"name": "Roles"
},
{
"name": "Users"
},
{
"name": "SAML"
}
],
"paths": {
"/api/v1/ldap.syncNow": {
"post": {
"tags": [
"LDAP"
],
"summary": "LDAP Sync",
"description": "\n\nSyncs your LDAP data based on the data sync configurations. This endpoint requires 2FA.\n\nMake sure LDAP is enabled before using this endpoint.\n\nPermission required: `sync-auth-services-users`.\n\n### Changelog\n| Version | Description |\n| ---------------- | ------------|\n|9.0.0 | Moved to premium plans. Added the `LDAP_Background_Sync_disabled` and `LDAP_Sync_failed` errors. |\n|5.2.0 | Include `syncAvatars` |\n|4.0.0 | Added |",
"operationId": "post-api-v1-ldap.syncNow",
"parameters": [
{
"$ref": "#/components/parameters/Auth-Token"
},
{
"$ref": "#/components/parameters/UserId"
},
{
"$ref": "#/components/parameters/x-2fa-code"
},
{
"$ref": "#/components/parameters/x-2fa-method"
}
],
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
},
"success": {
"type": "boolean"
}
}
},
"examples": {
"Success Example": {
"value": {
"message": "Sync_in_progress",
"success": true
}
}
}
}
}
},
"400": {
"description": "Bad Request",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"success": {
"type": "boolean"
},
"error": {
"type": "string"
},
"errorType": {
"type": "string"
},
"details": {
"type": "object",
"properties": {
"method": {
"type": "string"
},
"codeGenerated": {
"type": "boolean"
},
"availableMethods": {
"type": "array",
"items": {
"type": "string"
}
},
"error": {
"type": "string",
"description": "The error that stopped the sync. Returned with `LDAP_Sync_failed`."
}
}
}
}
},
"examples": {
"2FA Required": {
"summary": "2FA code missing",
"description": "The request has no valid `x-2fa-code` and `x-2fa-method` headers. `details.method` shows the 2FA method to use.",
"value": {
"success": false,
"error": "TOTP Required [totp-required]",
"errorType": "totp-required",
"details": {
"method": "totp",
"codeGenerated": false,
"availableMethods": [
"totp"
]
}
}
},
"LDAP Disabled": {
"summary": "LDAP is disabled",
"description": "LDAP is not enabled in the workspace (`LDAP_Enable` is off).",
"value": {
"success": false,
"error": "LDAP_disabled"
}
},
"Not Authorized": {
"summary": "Missing permission",
"description": "The user doesn't have the `sync-auth-services-users` permission.",
"value": {
"success": false,
"error": "error-not-authorized"
}
},
"Background Sync Disabled": {
"summary": "Background sync is disabled",
"description": "None of the background sync settings is enabled (`LDAP_Background_Sync`, `LDAP_Background_Sync_Avatars`, or `LDAP_Background_Sync_ABAC_Attributes` with ABAC enabled).",
"value": {
"success": false,
"error": "LDAP_Background_Sync_disabled"
}
},
"License Required": {
"summary": "Premium license required",
"description": "The workspace doesn't have a premium license with the `ldap-enterprise` module.",
"value": {
"success": false,
"error": "This is an enterprise feature [error-action-not-allowed]",
"errorType": "error-action-not-allowed"
}
},
"Sync Failed": {
"summary": "Sync could not run",
"description": "The sync could not run, for example because the LDAP server is unreachable. `details.error` contains the cause, for example `Timeout`.",
"value": {
"success": false,
"error": "LDAP_Sync_failed",
"details": {
"error": "Timeout"
}
}
}
}
}
}
},
"401": {
"$ref": "#/components/responses/authorizationError"
}
}
}
}
},
"components": {
"parameters": {
"Auth-Token": {
"name": "X-Auth-Token",
"in": "header",
"description": "The authenticated user token.",
"required": true,
"schema": {
"type": "string"
},
"example": "RScctEHSmLGZGywfIhWyRpyofhKOiMoUIpimhvheU3f"
},
"UserId": {
"name": "X-User-Id",
"in": "header",
"description": "The authenticated user ID.",
"required": true,
"schema": {
"type": "string"
},
"example": "rbAXPnMktTFbNpwtJ"
},
"x-2fa-code": {
"name": "x-2fa-code",
"in": "header",
"description": "Enter the 2FA code. This parameter is required if 2FA is enabled in your workspace. See the Introduction to Two-Factor Authentication document for details.",
"schema": {
"type": "string"
},
"example": "148750"
},
"x-2fa-method": {
"name": "x-2fa-method",
"in": "header",
"schema": {
"type": "string"
},
"description": "Enter the method with which you get the 2FA code. It can be `email`, `totp`, or `password`. This parameter is required if 2FA is enabled in your workspace."
}
},
"responses": {
"authorizationError": {
"description": "Unauthorized",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"success": {
"type": "boolean"
},
"error": {
"type": "string"
}
}
},
"examples": {
"Authorization Error": {
"value": {
"success": false,
"error": "You must be logged in to do this."
}
}
}
}
}
}
}
}
}
````