{"meta":{"title":"REST API endpoints for LDAP","intro":"Use the REST API to update account relationships between a GitHub Enterprise Server user or team and its linked LDAP entry or queue a new synchronization.","product":"REST API","breadcrumbs":[{"href":"/en/enterprise-server@3.22/rest","title":"REST API"},{"href":"/en/enterprise-server@3.22/rest/enterprise-admin","title":"Enterprise administration"},{"href":"/en/enterprise-server@3.22/rest/enterprise-admin/ldap","title":"LDAP"}],"documentType":"article"},"body":"# REST API endpoints for LDAP\n\nUse the REST API to update account relationships between a GitHub Enterprise Server user or team and its linked LDAP entry or queue a new synchronization.\n\n## About LDAP\n\nYou can use these endpoints to update the Distinguished Name (DN) that a user or team maps to. Note that in most cases, you must have [LDAP Sync enabled](/en/enterprise-server@3.22/admin/managing-iam/using-ldap-for-enterprise-iam/using-ldap) for your GitHub Enterprise Server appliance. The [Update LDAP mapping for a user](#update-ldap-mapping-for-a-user) endpoint can be used when LDAP is enabled, even if LDAP Sync is disabled.\n\n> \\[!NOTE]\n> These endpoints only support authentication using a personal access token (classic). For more information, see [Managing your personal access tokens](/en/enterprise-server@3.22/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-personal-access-token-classic).\n\n> \\[!NOTE]\n> Most endpoints use `Authorization: Bearer <YOUR-TOKEN>` and `Accept: application/vnd.github+json` headers, plus `X-GitHub-Api-Version: 2026-03-10`. Curl examples below omit these standard headers for brevity.\n\n## Update LDAP mapping for a team\n\n```\nPATCH /admin/ldap/teams/{team_id}/mapping\n```\n\nUpdates the distinguished name (DN) of the LDAP entry to map to a team. LDAP synchronization must be enabled to map LDAP entries to a team. Use the Create a team endpoint to create a team with LDAP mapping.\n\n### Parameters\n\n#### Headers\n\n* **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Path and query parameters\n\n* **`team_id`** (integer) (required)\n  The unique identifier of the team.\n\n#### Body parameters\n\n* **`ldap_dn`** (string) (required)\n  The distinguished name (DN) of the LDAP entry to map to a team.\n\n### HTTP response status codes\n\n* **200** - OK\n\n### Code examples\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X PATCH \\\n  http(s)://HOSTNAME/api/v3/admin/ldap/teams/TEAM_ID/mapping \\\n  -d '{\n  \"ldap_dn\": \"cn=Enterprise Ops,ou=teams,dc=github,dc=com\"\n}'\n```\n\n**Response schema (Status: 200):**\n\n* `ldap_dn`: string\n* `id`: integer\n* `node_id`: string\n* `url`: string\n* `html_url`: string\n* `name`: string\n* `slug`: string\n* `description`: string or null\n* `privacy`: string\n* `notification_setting`: string\n* `permission`: string\n* `members_url`: string\n* `repositories_url`: string\n* `parent`: null\n* `type`: string\n* `organization_id`: integer\n* `enterprise_id`: integer\n\n## Sync LDAP mapping for a team\n\n```\nPOST /admin/ldap/teams/{team_id}/sync\n```\n\nNote that this API call does not automatically initiate an LDAP sync. Rather, if a 201 is returned, the sync job is queued successfully, and is performed when the instance is ready.\n\n### Parameters\n\n#### Headers\n\n* **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Path and query parameters\n\n* **`team_id`** (integer) (required)\n  The unique identifier of the team.\n\n### HTTP response status codes\n\n* **201** - Created\n\n### Code examples\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X POST \\\n  http(s)://HOSTNAME/api/v3/admin/ldap/teams/TEAM_ID/sync\n```\n\n**Response schema (Status: 201):**\n\n* `status`: string\n\n## Update LDAP mapping for a user\n\n```\nPATCH /admin/ldap/users/{username}/mapping\n```\n\n### Parameters\n\n#### Headers\n\n* **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Path and query parameters\n\n* **`username`** (string) (required)\n  The handle for the GitHub user account.\n\n#### Body parameters\n\n* **`ldap_dn`** (string) (required)\n  The distinguished name (DN) of the LDAP entry to map to a team.\n\n### HTTP response status codes\n\n* **200** - OK\n\n### Code examples\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X PATCH \\\n  http(s)://HOSTNAME/api/v3/admin/ldap/users/USERNAME/mapping \\\n  -d '{\n  \"ldap_dn\": \"uid=asdf,ou=users,dc=github,dc=com\"\n}'\n```\n\n**Response schema (Status: 200):**\n\n* `ldap_dn`: string\n* `login`: required, string\n* `id`: required, integer, format: int64\n* `node_id`: required, string\n* `avatar_url`: required, string, format: uri\n* `gravatar_id`: required, string or null\n* `url`: required, string, format: uri\n* `html_url`: required, string, format: uri\n* `followers_url`: required, string, format: uri\n* `following_url`: required, string\n* `gists_url`: required, string\n* `starred_url`: required, string\n* `subscriptions_url`: required, string, format: uri\n* `organizations_url`: required, string, format: uri\n* `repos_url`: required, string, format: uri\n* `events_url`: required, string\n* `received_events_url`: required, string, format: uri\n* `type`: required, string\n* `site_admin`: required, boolean\n* `name`: required, string or null\n* `company`: required, string or null\n* `blog`: required, string or null\n* `location`: required, string or null\n* `email`: required, string or null, format: email\n* `hireable`: required, boolean or null\n* `bio`: required, string or null\n* `twitter_username`: string or null\n* `public_repos`: required, integer\n* `public_gists`: required, integer\n* `followers`: required, integer\n* `following`: required, integer\n* `created_at`: required, string, format: date-time\n* `updated_at`: required, string, format: date-time\n* `private_gists`: required, integer\n* `total_private_repos`: required, integer\n* `owned_private_repos`: required, integer\n* `disk_usage`: required, integer\n* `collaborators`: required, integer\n* `two_factor_authentication`: required, boolean\n* `plan`: object:\n  * `collaborators`: required, integer\n  * `name`: required, string\n  * `space`: required, integer\n  * `private_repos`: required, integer\n* `suspended_at`: string, format: date-time\n* `business_plus`: boolean\n* `user_view_type`: string\n\n## Sync LDAP mapping for a user\n\n```\nPOST /admin/ldap/users/{username}/sync\n```\n\nNote that this API call does not automatically initiate an LDAP sync. Rather, if a 201 is returned, the sync job is queued successfully, and is performed when the instance is ready.\n\n### Parameters\n\n#### Headers\n\n* **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Path and query parameters\n\n* **`username`** (string) (required)\n  The handle for the GitHub user account.\n\n### HTTP response status codes\n\n* **201** - Created\n\n### Code examples\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X POST \\\n  http(s)://HOSTNAME/api/v3/admin/ldap/users/USERNAME/sync\n```\n\n**Response schema (Status: 201):**\n\nSame response schema as [Sync LDAP mapping for a team](#sync-ldap-mapping-for-a-team)."}