Namespace: microsoft.graph
Important
APIs under the /beta version in Microsoft Graph are subject to change. Use of these APIs in production applications is not supported. To determine whether an API is available in v1.0, use the Version selector.
Delete a mailboxItem from a mailboxFolder in a mailbox.
Use the disposalType query parameter to specify whether to soft-delete or hard-delete the item.
This API is available in the following national cloud deployments.
| Global service |
US Government L4 |
US Government L5 (DOD) |
China operated by 21Vianet |
| ✅ |
❌ |
❌ |
❌ |
Permissions
Choose the permission or permissions marked as least privileged for this API. Use a higher privileged permission or permissions only if your app requires it. For details about delegated and application permissions, see Permission types. To learn more about these permissions, see the permissions reference.
| Permission type |
Least privileged permissions |
Higher privileged permissions |
| Delegated (work or school account) |
MailboxItem.ReadWrite |
Not available. |
| Delegated (personal Microsoft account) |
Not supported. |
Not supported. |
| Application |
MailboxItem.ReadWrite.All |
Not available. |
HTTP request
DELETE /admin/exchange/mailboxes/{mailboxId}/folders/{mailboxFolderId}/items/{mailboxItemId}?disposalType={disposalType}
Query parameters
In the request URL, provide the following required query parameter.
| Parameter |
Type |
Description |
| disposalType |
String |
Required. The type of delete operation to perform. The possible values are: softDelete, hardDelete. Use softDelete to follow Exchange soft-delete semantics, or hardDelete to permanently delete the item. |
Request body
Don't supply a request body for this method.
Response
If successful, this method returns a 204 No Content response code.
Note
When you use hardDelete, the Exchange service permanently deletes the item only when it's customer data that isn't protected by a legal hold, retention policy, audit, compliance, or system-item restriction. Otherwise, the request fails with a 403 Forbidden error.
Archive mailboxes with autoexpanded folders: When the target item physically resides in an auxiliary (autoexpanded) archive mailbox, this API might return a redirect response that points to the correct mailbox endpoint. For details, see Handle archive mailbox redirects.
Examples
Example 1: Soft-delete a mailbox item
The following example shows how to soft-delete a mailbox item in a folder by using disposalType=softDelete.
Request
The following example shows a request.
DELETE https://graph.microsoft.com/beta/admin/exchange/mailboxes/MBX:e0648f21@aab09c93/folders/inbox/items/AAMkADk0MzI?disposalType=softDelete
// Code snippets are only available for the latest version. Current version is 5.x
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
await graphClient.Admin.Exchange.Mailboxes["{mailbox-id}"].Folders["{mailboxFolder-id}"].Items["{mailboxItem-id}"].DeleteAsync((requestConfiguration) =>
{
requestConfiguration.QueryParameters.DisposalType = "softDelete";
});
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphadmin "github.com/microsoftgraph/msgraph-beta-sdk-go/admin"
//other-imports
)
requestDisposalType := "softDelete"
requestParameters := &graphadmin.ExchangeMailboxesItemFoldersItemItemsItemRequestBuilderDeleteQueryParameters{
DisposalType: &requestDisposalType,
}
configuration := &graphadmin.ExchangeMailboxesItemFoldersItemItemsItemRequestBuilderDeleteRequestConfiguration{
QueryParameters: requestParameters,
}
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
graphClient.Admin().Exchange().Mailboxes().ByMailboxId("mailbox-id").Folders().ByMailboxFolderId("mailboxFolder-id").Items().ByMailboxItemId("mailboxItem-id").Delete(context.Background(), configuration)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
graphClient.admin().exchange().mailboxes().byMailboxId("{mailbox-id}").folders().byMailboxFolderId("{mailboxFolder-id}").items().byMailboxItemId("{mailboxItem-id}").delete(requestConfiguration -> {
requestConfiguration.queryParameters.disposalType = "softDelete";
});
const options = {
authProvider,
};
const client = Client.init(options);
await client.api('/admin/exchange/mailboxes/MBX:e0648f21@aab09c93/folders/inbox/items/AAMkADk0MzI?disposalType=softDelete')
.version('beta')
.delete();
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Admin\Exchange\Mailboxes\Item\Folders\Item\Items\Item\MailboxItemItemRequestBuilderDeleteRequestConfiguration;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestConfiguration = new MailboxItemItemRequestBuilderDeleteRequestConfiguration();
$queryParameters = MailboxItemItemRequestBuilderDeleteRequestConfiguration::createQueryParameters();
$queryParameters->disposalType = "softDelete";
$requestConfiguration->queryParameters = $queryParameters;
$graphServiceClient->admin()->exchange()->mailboxes()->byMailboxId('mailbox-id')->folders()->byMailboxFolderId('mailboxFolder-id')->items()->byMailboxItemId('mailboxItem-id')->delete($requestConfiguration)->wait();
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.admin.exchange.mailboxes.item.folders.item.items.item.mailbox_item_item_request_builder import MailboxItemItemRequestBuilder
from kiota_abstractions.base_request_configuration import RequestConfiguration
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
query_params = MailboxItemItemRequestBuilder.MailboxItemItemRequestBuilderDeleteQueryParameters(
disposal_type = "softDelete",
)
request_configuration = RequestConfiguration(
query_parameters = query_params,
)
await graph_client.admin.exchange.mailboxes.by_mailbox_id('mailbox-id').folders.by_mailbox_folder_id('mailboxFolder-id').items.by_mailbox_item_id('mailboxItem-id').delete(request_configuration = request_configuration)
Response
The following example shows the response.
HTTP/1.1 204 No Content
Example 2: Hard-delete a mailbox item
The following example shows how to hard-delete an eligible mailbox item in Recoverable Items by using disposalType=hardDelete.
Request
The following example shows a request.
DELETE https://graph.microsoft.com/beta/admin/exchange/mailboxes/MBX:e0648f21@aab09c93/folders/recoverableitemsdeletions/items/AAMkADk0MzI?disposalType=hardDelete
// Code snippets are only available for the latest version. Current version is 5.x
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
await graphClient.Admin.Exchange.Mailboxes["{mailbox-id}"].Folders["{mailboxFolder-id}"].Items["{mailboxItem-id}"].DeleteAsync((requestConfiguration) =>
{
requestConfiguration.QueryParameters.DisposalType = "hardDelete";
});
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphadmin "github.com/microsoftgraph/msgraph-beta-sdk-go/admin"
//other-imports
)
requestDisposalType := "hardDelete"
requestParameters := &graphadmin.ExchangeMailboxesItemFoldersItemItemsItemRequestBuilderDeleteQueryParameters{
DisposalType: &requestDisposalType,
}
configuration := &graphadmin.ExchangeMailboxesItemFoldersItemItemsItemRequestBuilderDeleteRequestConfiguration{
QueryParameters: requestParameters,
}
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
graphClient.Admin().Exchange().Mailboxes().ByMailboxId("mailbox-id").Folders().ByMailboxFolderId("mailboxFolder-id").Items().ByMailboxItemId("mailboxItem-id").Delete(context.Background(), configuration)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
graphClient.admin().exchange().mailboxes().byMailboxId("{mailbox-id}").folders().byMailboxFolderId("{mailboxFolder-id}").items().byMailboxItemId("{mailboxItem-id}").delete(requestConfiguration -> {
requestConfiguration.queryParameters.disposalType = "hardDelete";
});
const options = {
authProvider,
};
const client = Client.init(options);
await client.api('/admin/exchange/mailboxes/MBX:e0648f21@aab09c93/folders/recoverableitemsdeletions/items/AAMkADk0MzI?disposalType=hardDelete')
.version('beta')
.delete();
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Admin\Exchange\Mailboxes\Item\Folders\Item\Items\Item\MailboxItemItemRequestBuilderDeleteRequestConfiguration;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestConfiguration = new MailboxItemItemRequestBuilderDeleteRequestConfiguration();
$queryParameters = MailboxItemItemRequestBuilderDeleteRequestConfiguration::createQueryParameters();
$queryParameters->disposalType = "hardDelete";
$requestConfiguration->queryParameters = $queryParameters;
$graphServiceClient->admin()->exchange()->mailboxes()->byMailboxId('mailbox-id')->folders()->byMailboxFolderId('mailboxFolder-id')->items()->byMailboxItemId('mailboxItem-id')->delete($requestConfiguration)->wait();
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.admin.exchange.mailboxes.item.folders.item.items.item.mailbox_item_item_request_builder import MailboxItemItemRequestBuilder
from kiota_abstractions.base_request_configuration import RequestConfiguration
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
query_params = MailboxItemItemRequestBuilder.MailboxItemItemRequestBuilderDeleteQueryParameters(
disposal_type = "hardDelete",
)
request_configuration = RequestConfiguration(
query_parameters = query_params,
)
await graph_client.admin.exchange.mailboxes.by_mailbox_id('mailbox-id').folders.by_mailbox_folder_id('mailboxFolder-id').items.by_mailbox_item_id('mailboxItem-id').delete(request_configuration = request_configuration)
Response
The following example shows the response.
HTTP/1.1 204 No Content