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.
Caution
Existing apps that use this feature with baseTask or baseTaskList should be updated, as the to-do API set built on these resources is deprecated as of May 31, 2022. That API set will stop returning data on August 31, 2022. Please use the API set built on todoTask.
Delete an open extension (openTypeExtension object) from the specified instance of a resource.
For the list of resources that support open extensions, see the table in the Permissions section.
This API is available in the following national cloud deployments.
| Global service |
US Government L4 |
US Government L5 (DOD) |
China operated by 21Vianet |
| ✅ |
✅ |
✅ |
✅ |
Permissions
Depending on the resource you're deleting the extension from and the permission type (delegated or application) requested, the permission specified in the following table is the least privileged required to call this API. To learn more, including taking caution before choosing more privileged permissions, search for the following permissions in Permissions.
| Supported resource |
Delegated (work or school account) |
Delegated (personal Microsoft account) |
Application |
| device |
Directory.AccessAsUser.All |
Not supported. |
Device.ReadWrite.All |
| driveItem |
Files.ReadWrite |
Files.ReadWrite |
Not supported. |
| event |
Calendars.ReadWrite |
Calendars.ReadWrite |
Calendars.ReadWrite |
| group |
Group.ReadWrite.All |
Not supported. |
Group.ReadWrite.All |
| group event |
Group.ReadWrite.All |
Not supported. |
Not supported |
| group post |
Group.ReadWrite.All |
Not supported. |
Group.ReadWrite.All |
| message |
Mail.ReadWrite |
Mail.ReadWrite |
Mail.ReadWrite |
| organization |
Organization.ReadWrite.All |
Not supported. |
Organization.ReadWrite.All |
| personal contact |
Contacts.ReadWrite |
Contacts.ReadWrite |
Contacts.ReadWrite |
| site |
Sites.ReadWrite.All |
Not supported. |
Not supported. |
| todoTask |
Tasks.ReadWrite |
Tasks.ReadWrite |
Tasks.ReadWrite.All |
| todoTasklist |
Tasks.ReadWrite |
Tasks.ReadWrite |
Tasks.ReadWrite.All |
| user |
User.ReadWrite |
Not supported. |
User.ReadWrite.All |
| baseTask (deprecated) |
Tasks.ReadWrite |
Tasks.ReadWrite |
Tasks.ReadWrite.All |
| baseTasklist (deprecated) |
Tasks.ReadWrite |
Tasks.ReadWrite |
Tasks.ReadWrite.All |
HTTP request
In the request, identify the resource instance, use the extensions
navigation property of that instance to identify the extension, and do a DELETE on that extension instance.
DELETE /administrativeUnits/{administrativeUnitId}/extensions/{extensionId}
DELETE /devices/{deviceId}/extensions/{extensionId}
DELETE /users/{userId|userPrincipalName}/events/{eventId}/extensions/{extensionId}
DELETE /groups/{groupId}/extensions/{extensionId}
DELETE /groups/{groupId}/events/{eventId}/extensions/{extensionId}
DELETE /groups/{groupId}/threads/{threadIid}/posts/{postId}/extensions/{extensionId}
DELETE /users/{userIid|userPrincipalName}/messages/{messageId}/extensions/{extensionId}
DELETE /organization/{organizationId}/extensions/{extensionId}
DELETE /users/{userId|userPrincipalName}/contacts/{contactId}/extensions/{extensionId}
DELETE /users/{userId|userPrincipalName}/extensions/{extensionId}
DELETE /users/me/todo/lists/{listId}/extensions/{extensionId}
DELETE /users/me/todo/lists/{listId}/tasks/{taskId}/extensions/{extensionId}
DELETE /users/me/tasks/lists/{listId}/extensions/{extensionId}
DELETE /users/me/tasks/lists/{listId}/tasks/{taskId}/extensions/{extensionId}
DELETE /drive/items/{itemId}/extensions/{extensionId}
DELETE /sites/{site-id}/extensions/{extensionId}
Note: The previous syntax shows some common ways to identify a resource instance, in order to delete an extension from it.
All other syntax that allows you to identify these resource instances supports deleting open extensions from them in a similar way.
Request body
Don't supply a request body for this method.
Response
If successful, this method returns 204 No Content response code. It doesn't return anything in the response body.
Example
Request 1
The first example references an extension by its name and deletes the extension in the specified message.
DELETE https://graph.microsoft.com/beta/me/messages/AAMkAGE1M2IyNGNmLTI5MTktNDUyZi1iOTVl===/extensions/Com.Contoso.Referral/
// Code snippets are only available for the latest version. Current version is 5.x
// To initialize your graphClient, see https://dori-uw-1.kuma-moon.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
await graphClient.Me.Messages["{message-id}"].Extensions["{extension-id}"].DeleteAsync();
// 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"
//other-imports
)
// To initialize your graphClient, see https://dori-uw-1.kuma-moon.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
graphClient.Me().Messages().ByMessageId("message-id").Extensions().ByExtensionId("extension-id").Delete(context.Background(), nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
graphClient.me().messages().byMessageId("{message-id}").extensions().byExtensionId("{extension-id}").delete();
const options = {
authProvider,
};
const client = Client.init(options);
await client.api('/me/messages/AAMkAGE1M2IyNGNmLTI5MTktNDUyZi1iOTVl===/extensions/Com.Contoso.Referral/')
.version('beta')
.delete();
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$graphServiceClient->me()->messages()->byMessageId('message-id')->extensions()->byExtensionId('extension-id')->delete()->wait();
Import-Module Microsoft.Graph.Beta.Mail
# A UPN can also be used as -UserId.
Remove-MgBetaUserMessageExtension -UserId $userId -MessageId $messageId -ExtensionId $extensionId
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
# To initialize your graph_client, see https://dori-uw-1.kuma-moon.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
await graph_client.me.messages.by_message_id('message-id').extensions.by_extension_id('extension-id').delete()
Response 1
The following example shows the response.
HTTP/1.1 204 No Content
Request 2
The second example deletes an extension in the specified group event.
DELETE https://graph.microsoft.com/beta/groups/f5480dfd-7d77-4d0b-ba2e-3391953cc74a/events/AAMkADVlN17IsAAA=/extensions/Com.Contoso.Referral
Response 2
The following example shows the response.
HTTP/1.1 204 No Content
Request 3
The following example shows how to delete an extension by its name from the specified driveItem.
DELETE https://graph.microsoft.com/beta/drive/items/01FWCEC553UUOHTOAGBVE2IXBQTIZY3JZQ/extensions/Com.Contoso.Referral
// Code snippets are only available for the latest version. Current version is 5.x
// To initialize your graphClient, see https://dori-uw-1.kuma-moon.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
await graphClient.Drives["{drive-id}"].Items["{driveItem-id}"].Extensions["{extension-id}"].DeleteAsync();
// 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"
//other-imports
)
// To initialize your graphClient, see https://dori-uw-1.kuma-moon.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
graphClient.Drives().ByDriveId("drive-id").Items().ByDriveItemId("driveItem-id").Extensions().ByExtensionId("extension-id").Delete(context.Background(), nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
graphClient.drives().byDriveId("{drive-id}").items().byDriveItemId("{driveItem-id}").extensions().byExtensionId("{extension-id}").delete();
const options = {
authProvider,
};
const client = Client.init(options);
await client.api('/drive/items/01FWCEC553UUOHTOAGBVE2IXBQTIZY3JZQ/extensions/Com.Contoso.Referral')
.version('beta')
.delete();
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$graphServiceClient->drives()->byDriveId('drive-id')->items()->byDriveItemId('driveItem-id')->extensions()->byExtensionId('extension-id')->delete()->wait();
Import-Module Microsoft.Graph.Beta.Files
Remove-MgBetaDriveItemExtension -DriveId $driveId -DriveItemId $driveItemId -ExtensionId $extensionId
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
# To initialize your graph_client, see https://dori-uw-1.kuma-moon.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
await graph_client.drives.by_drive_id('drive-id').items.by_drive_item_id('driveItem-id').extensions.by_extension_id('extension-id').delete()
Response 3
The following example shows the response.
HTTP/1.1 204 No Content
Request 4
The following example shows how to delete an extension by its name from the specified site.
DELETE https://graph.microsoft.com/beta/sites/8f52f9ad-4f4f-4739-b682-7c0283207937/extensions/Com.Contoso.Referral
// Code snippets are only available for the latest version. Current version is 5.x
// To initialize your graphClient, see https://dori-uw-1.kuma-moon.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
await graphClient.Sites["{site-id}"].Extensions["{extension-id}"].DeleteAsync();
// 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"
//other-imports
)
// To initialize your graphClient, see https://dori-uw-1.kuma-moon.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
graphClient.Sites().BySiteId("site-id").Extensions().ByExtensionId("extension-id").Delete(context.Background(), nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
graphClient.sites().bySiteId("{site-id}").extensions().byExtensionId("{extension-id}").delete();
const options = {
authProvider,
};
const client = Client.init(options);
await client.api('/sites/8f52f9ad-4f4f-4739-b682-7c0283207937/extensions/Com.Contoso.Referral')
.version('beta')
.delete();
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$graphServiceClient->sites()->bySiteId('site-id')->extensions()->byExtensionId('extension-id')->delete()->wait();
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
# To initialize your graph_client, see https://dori-uw-1.kuma-moon.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
await graph_client.sites.by_site_id('site-id').extensions.by_extension_id('extension-id').delete()
Response 4
The following example shows the response.
HTTP/1.1 204 No Content