Delete a domain using an asynchronous long-running operation.
Before performing this operation, you must update or remove any references to Exchange as the provisioning service.
The following actions are performed as part of this operation:
Updates the userPrincipalName, mail, and proxyAddresses properties of users with references to the deleted domain to use the initial onmicrosoft.com domain.
Updates the mail property of groups with references to the deleted domain to use the initial onmicrosoft.com domain.
Updates the identifierUris property of applications with references to the deleted domain to use the initial onmicrosoft.com domain.
If the number of objects to be renamed is greater than 1000, an error is returned.
If one of the applications to be renamed is a multitenant app, an error is returned.
After the domain deletion completes, API operations for the deleted domain return an HTTP 404 status code. To verify deletion of a domain, you can perform a get domain operation.
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)
Domain.ReadWrite.All
Not available.
Delegated (personal Microsoft account)
Not supported.
Not supported.
Application
Domain.ReadWrite.All
Not available.
Important
In delegated scenarios with work or school accounts, the signed-in user must be assigned a supported Microsoft Entra role or a custom role with a supported role permission. Domain Name Administrator is the least privileged role supported for this operation.
HTTP request
POST /domains/{id}/forceDelete
For {id}, specify the domain with its fully qualified domain name.
In the request body, provide a JSON object with the following parameters.
Parameter
Type
Description
disableUserAccounts
Boolean
Option to disable user accounts that are renamed. If a user account is disabled, the user isn't allowed to sign in. If set to true the users updated as part of this operation are disabled. Default value is true.
Response body
If successful, this method returns HTTP/1.1 204 OK status code.
POST https://graph.microsoft.com/v1.0/domains/{id}/forceDelete
Content-type: application/json
{
"disableUserAccounts": true
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Domains.Item.ForceDelete;
var requestBody = new ForceDeletePostRequestBody
{
DisableUserAccounts = true,
};
// To initialize your graphClient, see https://zcusa.951200.xyz/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
await graphClient.Domains["{domain-id}"].ForceDelete.PostAsync(requestBody);
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphdomains "github.com/microsoftgraph/msgraph-sdk-go/domains"
//other-imports
)
requestBody := graphdomains.NewForceDeletePostRequestBody()
disableUserAccounts := true
requestBody.SetDisableUserAccounts(&disableUserAccounts)
// To initialize your graphClient, see https://zcusa.951200.xyz/en-us/graph/sdks/create-client?from=snippets&tabs=go
graphClient.Domains().ByDomainId("domain-id").ForceDelete().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
com.microsoft.graph.domains.item.forcedelete.ForceDeletePostRequestBody forceDeletePostRequestBody = new com.microsoft.graph.domains.item.forcedelete.ForceDeletePostRequestBody();
forceDeletePostRequestBody.setDisableUserAccounts(true);
graphClient.domains().byDomainId("{domain-id}").forceDelete().post(forceDeletePostRequestBody);
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Domains\Item\ForceDelete\ForceDeletePostRequestBody;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new ForceDeletePostRequestBody();
$requestBody->setDisableUserAccounts(true);
$graphServiceClient->domains()->byDomainId('domain-id')->forceDelete()->post($requestBody)->wait();
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.domains.item.force_delete.force_delete_post_request_body import ForceDeletePostRequestBody
# To initialize your graph_client, see https://zcusa.951200.xyz/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = ForceDeletePostRequestBody(
disable_user_accounts = True,
)
await graph_client.domains.by_domain_id('domain-id').force_delete.post(request_body)