Retrieve the Email Folder Hierarchy

Marketing Cloud Engagement has a new model for storing, finding, managing, creating, sharing, and distributing all content-related objects. Access the objects created with the new Content Builder tools using the REST API. Your existing SOAP API integrations only function with the Classic tools.

This page contains information about retrieving the email folder hierarchy.

Why Retrieve the Email Folder Hierarchy 

This API call retrieves a collection of folders. Each folder has the following information:

  1. ID - The ID of the folder
  2. ParentID - The ID of the folder this folder is nested within (0 if this is a parent folder)
  3. Name - The name of the folder

This call retrieves only the email folder hierarchy, not the actual email messages.

Use these code examples as guides to construct your own API calls.

Sample .NET Code 

private void RetrieveDataFolder()
{
    SoapClient framework = new SoapClient();
    framework.ClientCredentials.UserName.UserName = "xxx";
    framework.ClientCredentials.UserName.Password = "xxx";
    String requestID;
    String status;
    APIObject[] results;
    SimpleFilterPart sfp = new SimpleFilterPart();
    sfp.Property = "ContentType";
    sfp.SimpleOperator = SimpleOperators.equals;
    sfp.Value = new string[] { "email" };
    RetrieveRequest rr = new RetrieveRequest();
    rr.ObjectType = "DataFolder";
    rr.Properties = new string[] { "ID", "Name", "ParentFolder.ID","ParentFolder.Name" };
    rr.Filter = sfp;
    status = framework.Retrieve(rr, out requestID, out results);
    Console.WriteLine(status);
    foreach (DataFolder df in results)
    {
Console.WriteLine("---------");
Console.WriteLine("Folder Name: " + df.Name);
Console.WriteLine("Folder ID: " + df.ID);
Console.WriteLine("Parent Folder Name: " + df.ParentFolder.Name);
Console.WriteLine("Parent Folder ID: " + df.ParentFolder.ID);
    }
}

SOAP Envelope 

<soap:Body>
  <RetrieveRequestMsg xmlns="http://exacttarget.com/wsdl/partnerAPI">
    <RetrieveRequest>
      <ObjectType>DataFolder</ObjectType>
      <Properties>Client.ID</Properties>
      <Properties>Name</Properties>
      <Properties>ID</Properties>
      <Properties>ObjectID</Properties>
      <Properties>ContentType</Properties>
      <!--Parent Details-->
      <Properties>ParentFolder.ContentType</Properties>
      <Properties>ParentFolder.ID</Properties>
      <Properties>ParentFolder.ObjectID</Properties>
      <Properties>ParentFolder.Name</Properties>
      <Filter xsi:type="SimpleFilterPart">
        <Property>ContentType</Property>
        <SimpleOperator>equals</SimpleOperator>
        <Value>email</Value>
      </Filter>
      <QueryAllAccounts>true</QueryAllAccounts>
    </RetrieveRequest>
  </RetrieveRequestMsg>
</soap:Body>

Related Items