命名空间:microsoft.graph
重要
Microsoft Graph /beta 版本下的 API 可能会发生更改。 不支持在生产应用程序中使用这些 API。 若要确定 API 是否在 v1.0 中可用,请使用 版本 选择器。
从 已删除邮件中永久删除最近删除的目录对象。 支持以下类型:
- application
- agentIdentityBlueprint
- agentIdentity
- agentIdentityBlueprintPrincipal
- agentUser
- certificateBasedAuthPki
- certificateAuthorityDetail
- 设备
- externalUserProfile
- 组
- pendingExternalUserProfile
- servicePrincipal
- 用户
永久删除项目后, 无法 还原。
不能使用 deletedItems API 永久删除管理单元。 软删除的管理单元将在初始删除后 30 天永久删除,除非它们已还原。
重要
硬删除保护阻止永久删除受保护 的用户 (在软删除后的前 7 天内排除本地同步用户) 、仅云组、 应用程序或 servicePrincipal 。 通过在现有对象上将 isHardDeleteProtectionEnabled 设置为 true 来启用保护,并且无法禁用。
对象仍可软删除和 还原。 如果还原了受保护的对象,然后再次软删除,则新的 7 天保护期将开始。 保护期到期后,授权调用方可以永久删除对象。
此 API 可用于以下国家级云部署。
| 全局服务 | 美国政府 L4 | 美国政府 L5 (DOD) | 由世纪互联运营的中国 |
|---|---|---|---|
| ✅ | ✅ | ✅ | ✅ |
权限
下表显示了对每种受支持的资源类型调用此 API 所需的最低特权。 遵循 最佳做法 请求最低特权权限。 有关委派权限和应用程序权限的详细信息,请参阅权限类型。 要了解有关这些权限的详细信息,请参阅 权限参考。
| 支持的资源 | 委派(工作或学校帐户) | 委派(个人 Microsoft 帐户) | 应用程序 |
|---|---|---|---|
| application | Application.ReadWrite.All | 不支持。 | Application.ReadWrite.OwnedBy |
| agentIdentity | AgentIdentity.ReadWrite.All | 不支持。 | AgentIdentity.ReadWrite.All |
| agentIdentityBlueprint | AgentIdentityBlueprint.ReadWrite.All | 不支持。 | AgentIdentityBlueprint.ReadWrite.All |
| agentIdentityBlueprintPrincipal | AgentIdentityBlueprintPrincipal.ReadWrite.All | 不支持。 | AgentIdentityBlueprintPrincipal.ReadWrite.All |
| agentUser | AgentIdUser.ReadWrite.IdentityParentedBy | 不支持。 | AgentIdUser.ReadWrite.IdentityParentedBy |
| externalUserProfile | ExternalUserProfile.ReadWrite.All | 不支持 | ExternalUserProfile.ReadWrite.All |
| certificateBasedAuthPki | PublicKeyInfrastructure.Read.All | 不支持。 | PublicKeyInfrastructure.Read.All |
| certificateAuthorityDetail | PublicKeyInfrastructure.Read.All | 不支持。 | PublicKeyInfrastructure.Read.All |
| 设备 | Device.ReadWrite.All | 不支持。 | Device.ReadWrite.All |
| 组 | Group.ReadWrite.All | 不支持。 | 不支持。 |
| pendingExternalUserProfile | PendingExternalUserProfile.ReadWrite.All | 不支持 | PendingExternalUserProfile.ReadWrite.All |
| servicePrincipal | Application.ReadWrite.All | 不支持。 | Application.ReadWrite.OwnedBy |
| user | User.DeleteRestore.All | 不支持。 | User.DeleteRestore.All |
重要
对于使用工作或学校帐户的委派访问权限,必须为登录用户分配受支持的 Microsoft Entra 角色或授予此操作所需权限的自定义角色。 此操作支持以下内置角色,这些角色仅提供所需的最小权限:
- 代理标识、代理标识蓝图和代理标识蓝图主体: 代理 ID 管理员
- 管理单元:目录读取者 (只读) 、全局读取者 (只读) 、特权角色管理员
- 应用程序:混合标识管理员、云应用程序管理员、应用程序管理员
- 设备: 云设备管理员、Intune 管理员、Windows 365 管理员
- 外部用户配置文件:全局读取者 (只读) 、Skype for Business管理员、Teams 管理员
- 组:组管理员 ((角色可分配的组除外) )、用户管理员 ((角色可分配的组除外) )、特权角色管理员 (角色可分配组的最小特权角色)
- 挂起的外部用户配置文件: 全局读取者 (只读) 、Skype for Business 管理员、Teams 管理员
- 服务主体:混合标识管理员、云应用程序管理员、应用程序管理员
- 用户:身份验证管理员、特权身份验证管理员、用户管理员。 但是,要还原具有特权管理员角色的用户:
- 在委派方案中,必须为应用分配 Directory.AccessAsUser.All 委派的权限,并且还必须为调用用户分配更高特权的管理员角色,如 “谁可以执行敏感操作?”中所示。
- 在仅限应用的情况下,除了被授予 User.ReadWrite.All 应用程序权限外,还必须为应用分配更高特权的管理员角色,如“ 谁可以执行敏感操作?”中所示。
HTTP 请求
DELETE /directory/deletedItems/{id}
请求标头
| 名称 | 说明 |
|---|---|
| Authorization | 持有者 {token}。 必填。 详细了解 身份验证和授权。 |
| 接受 | application/json |
请求正文
请勿提供此方法的请求正文。
响应
如果成功,此方法返回 204 No Content 响应代码。 它不会返回响应正文中的任何内容。
如果启用了硬删除保护,并且对象仍在 7 天的保护期内,则此方法将返回 409 Conflict 错误 Request_ConflictingRequest 代码。 等到保护期到期后再尝试永久删除对象。
示例
示例 1:永久删除项
请求
DELETE https://graph.microsoft.com/beta/directory/deletedItems/46cc6179-19d0-473e-97ad-6ff84347bbbb
响应
HTTP/1.1 204 No Content
示例 2:尝试永久删除受保护的项
请求
以下请求尝试在 isHardDeleteProtectionEnabled 设置为 true 7 天保护期到期之前永久删除对象。
DELETE https://graph.microsoft.com/beta/directory/deletedItems/46cc6179-19d0-473e-97ad-6ff84347bbbb
响应
HTTP/1.1 409 Conflict
Content-Type: application/json
{
"error": {
"code": "Request_ConflictingRequest",
"message": "The object cannot be permanently deleted because isHardDeleteProtectionEnabled is set to true.",
"innerError": {
"date": "2026-10-30T12:00:00",
"request-id": "a9ee5607-56bd-4ce1-bcf5-66a11c8358b0",
"client-request-id": "7fc3fe7b-2070-4f3f-8b0c-949ae8c03509"
}
}
}