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.
Get the folder collection under the specified folder. You can use the .../me/mailFolders
shortcut to get the top-level
folder collection and navigate to another folder.
By default, this operation does not return hidden folders. Use a query parameter includeHiddenFolders to include them in the response.
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) |
Mail.ReadBasic |
Mail.ReadWrite, Mail.Read |
Delegated (personal Microsoft account) |
Mail.ReadBasic |
Mail.ReadWrite, Mail.Read |
Application |
Mail.ReadBasic.All |
Mail.ReadWrite, Mail.Read |
HTTP request
To get all the child folders under the specified folder, excluding those that are hidden:
GET /me/mailFolders/{id}/childFolders
GET /users/{id | userPrincipalName}/mailFolders/{id}/childFolders
To include hidden child folders in the response:
GET /me/mailFolders/{id}/childFolders?includeHiddenFolders=true
GET /users/{id | userPrincipalName}/mailFolders/{id}/childFolders?includeHiddenFolders=true
Optional query parameters
To return a list of all childFolders including those that are hidden (their isHidden property is true), in the request URL, specify the includeHiddenFolders
query parameter as true
, as shown in the HTTP request section.
This method supports the OData Query Parameters to help customize the response.
Request body
Don't supply a request body for this method.
Response
If successful, this method returns a 200 OK
response code and collection of mailFolder objects in the response body.
Examples
Example 1: List mail folders
Request
The following example shows a request.
GET https://graph.microsoft.com/beta/me/mailFolders/AAMkAGVmMDEzM/childFolders
// 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
var result = await graphClient.Me.MailFolders["{mailFolder-id}"].ChildFolders.GetAsync();
mgc-beta users mail-folders child-folders list --user-id {user-id} --mail-folder-id {mailFolder-id}
// 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://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
childFolders, err := graphClient.Me().MailFolders().ByMailFolderId("mailFolder-id").ChildFolders().Get(context.Background(), nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
MailFolderCollectionResponse result = graphClient.me().mailFolders().byMailFolderId("{mailFolder-id}").childFolders().get();
const options = {
authProvider,
};
const client = Client.init(options);
let childFolders = await client.api('/me/mailFolders/AAMkAGVmMDEzM/childFolders')
.version('beta')
.get();
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$result = $graphServiceClient->me()->mailFolders()->byMailFolderId('mailFolder-id')->childFolders()->get()->wait();
Import-Module Microsoft.Graph.Beta.Mail
# A UPN can also be used as -UserId.
Get-MgBetaUserMailFolderChildFolder -UserId $userId -MailFolderId $mailFolderId
# 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://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
result = await graph_client.me.mail_folders.by_mail_folder_id('mailFolder-id').child_folders.get()
Response
The following example shows the response.
Note: The response object shown here might be shortened for readability.
HTTP/1.1 200 OK
Content-type: application/json
{
"value": [
{
"id": "AAMkAGVmMDEzA",
"displayName": "Internal Screens",
"parentFolderId": "AAMkAGVmMDEzM",
"childFolderCount": 0,
"unreadItemCount": 2,
"totalItemCount": 2,
"wellKnownName": null,
"isHidden": false
},
{
"id": "AAMkAGVmMDEzB",
"displayName": "Project Falcon",
"parentFolderId": "AAMkAGVmMDEzM",
"childFolderCount": 0,
"unreadItemCount": 5,
"totalItemCount": 5,
"wellKnownName": null,
"isHidden": false
},
{
"id": "AAMkAGVmMDEzMA",
"displayName": "Finder",
"parentFolderId": "AAMkAGVmMDEzM",
"childFolderCount": 4,
"unreadItemCount": 0,
"totalItemCount": 0,
"wellKnownName": "searchfolders",
"isHidden": false
}
]
}
Example 2: List mail search folders
Request
The following example shows a request.
GET https://graph.microsoft.com/beta/me/mailFolders/searchfolders/childFolders
// 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
var result = await graphClient.Me.MailFolders["{mailFolder-id}"].ChildFolders.GetAsync();
mgc-beta users mail-folders child-folders list --user-id {user-id} --mail-folder-id {mailFolder-id}
// 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://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
childFolders, err := graphClient.Me().MailFolders().ByMailFolderId("mailFolder-id").ChildFolders().Get(context.Background(), nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
MailFolderCollectionResponse result = graphClient.me().mailFolders().byMailFolderId("{mailFolder-id}").childFolders().get();
const options = {
authProvider,
};
const client = Client.init(options);
let childFolders = await client.api('/me/mailFolders/searchfolders/childFolders')
.version('beta')
.get();
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$result = $graphServiceClient->me()->mailFolders()->byMailFolderId('mailFolder-id')->childFolders()->get()->wait();
Import-Module Microsoft.Graph.Beta.Mail
# A UPN can also be used as -UserId.
Get-MgBetaUserMailFolderChildFolder -UserId $userId -MailFolderId $mailFolderId
# 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://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
result = await graph_client.me.mail_folders.by_mail_folder_id('mailFolder-id').child_folders.get()
Response
The following example shows the response.
Note: The response object shown here might be shortened for readability.
HTTP/1.1 200 OK
Content-type: application/json
{
"value": [
{
"@odata.type": "#microsoft.graph.mailSearchFolder",
"id": "AAMkAGE1NWMz",
"displayName": "Get MyAnalytics",
"parentFolderId": "AAMkAGE1NWMx",
"childFolderCount": 0,
"unreadItemCount": 6,
"totalItemCount": 6,
"isHidden": false,
"wellKnownName": null,
"isSupported": true,
"filterQuery": "contains(subject, 'MyAnalytics')"
},
{
"@odata.type": "#microsoft.graph.mailSearchFolder",
"id": "AAMkAGE1NWMy",
"displayName": "Action Required",
"parentFolderId": "AAMkAGE1NWMx",
"childFolderCount": 0,
"unreadItemCount": 2,
"totalItemCount": 4,
"isHidden": false,
"wellKnownName": null,
"isSupported": true,
"filterQuery": "contains(subject, 'ACTION REQUIRED')"
}
]
}
Example 3: Include hidden child folders under a specified mail folder
The next example uses the includeHiddenFolders
query parameter to get a list of child folders under a specified mail folder including hidden mail folders. The response includes the "Clutters" folder that has the isHidden set to true.
Request
The following example shows a request.
GET https://graph.microsoft.com/beta/me/mailFolders/AAMkAGVmMDEzM/childFolders?includeHiddenFolders=true
// 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
var result = await graphClient.Me.MailFolders["{mailFolder-id}"].ChildFolders.GetAsync((requestConfiguration) =>
{
requestConfiguration.QueryParameters.IncludeHiddenFolders = "true";
});
mgc-beta users mail-folders child-folders list --user-id {user-id} --mail-folder-id {mailFolder-id} --include-hidden-folders "true"
// 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"
graphusers "github.com/microsoftgraph/msgraph-beta-sdk-go/users"
//other-imports
)
requestIncludeHiddenFolders := "true"
requestParameters := &graphusers.MailFoldersItemChildFoldersRequestBuilderGetQueryParameters{
IncludeHiddenFolders: &requestIncludeHiddenFolders,
}
configuration := &graphusers.MailFoldersItemChildFoldersRequestBuilderGetRequestConfiguration{
QueryParameters: requestParameters,
}
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
childFolders, err := graphClient.Me().MailFolders().ByMailFolderId("mailFolder-id").ChildFolders().Get(context.Background(), configuration)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
MailFolderCollectionResponse result = graphClient.me().mailFolders().byMailFolderId("{mailFolder-id}").childFolders().get(requestConfiguration -> {
requestConfiguration.queryParameters.includeHiddenFolders = "true";
});
const options = {
authProvider,
};
const client = Client.init(options);
let childFolders = await client.api('/me/mailFolders/AAMkAGVmMDEzM/childFolders?includeHiddenFolders=true')
.version('beta')
.get();
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Users\Item\MailFolders\Item\ChildFolders\ChildFoldersRequestBuilderGetRequestConfiguration;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestConfiguration = new ChildFoldersRequestBuilderGetRequestConfiguration();
$queryParameters = ChildFoldersRequestBuilderGetRequestConfiguration::createQueryParameters();
$queryParameters->includeHiddenFolders = "true";
$requestConfiguration->queryParameters = $queryParameters;
$result = $graphServiceClient->me()->mailFolders()->byMailFolderId('mailFolder-id')->childFolders()->get($requestConfiguration)->wait();
Import-Module Microsoft.Graph.Beta.Mail
# A UPN can also be used as -UserId.
Get-MgBetaUserMailFolderChildFolder -UserId $userId -MailFolderId $mailFolderId -Includehiddenfolders true
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.users.item.mail_folders.item.child_folders.child_folders_request_builder import ChildFoldersRequestBuilder
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 = ChildFoldersRequestBuilder.ChildFoldersRequestBuilderGetQueryParameters(
include_hidden_folders = "true",
)
request_configuration = RequestConfiguration(
query_parameters = query_params,
)
result = await graph_client.me.mail_folders.by_mail_folder_id('mailFolder-id').child_folders.get(request_configuration = request_configuration)
Response
The following example shows the response.
Note: The response object shown here might be shortened for readability.
HTTP/1.1 200 OK
Content-type: application/json
{
"value": [
{
"id": "AAMkAGVmMDEzA",
"displayName": "Internal Screens",
"parentFolderId": "AAMkAGVmMDEzM",
"childFolderCount": 0,
"unreadItemCount": 2,
"totalItemCount": 2,
"wellKnownName": null,
"isHidden": false
},
{
"id": "AAMkAGVmMDEzB",
"displayName": "Clutters",
"parentFolderId": "AAMkAGVmMDEzM",
"childFolderCount": 0,
"unreadItemCount": 5,
"totalItemCount": 5,
"wellKnownName": null,
"isHidden": true
},
{
"id": "AAMkAGVmMDEzMA",
"displayName": "Finder",
"parentFolderId": "AAMkAGVmMDEzM",
"childFolderCount": 4,
"unreadItemCount": 0,
"totalItemCount": 0,
"wellKnownName": "searchfolders",
"isHidden": false
}
]
}