---
schema_version: "1"
id: a2dabdaf6e7b39ec8774f8b608a3159c1655e09b17e727664fd15a3c6ffd6428
title: listMetadata()
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/api_meta/meta_listmetadata.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_listmetadata.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 18db6f805afd4efb900618a9ed2806558dabdd35c64740770f23fdd69a1f731e
description: "This call retrieves property information about metadata components in your organization. Data is returned for the components that match the criteria specified in the queries parameter. The queries array can contain up to three ListMetadataQuery queries for each call. This call supports every metadata type: both top-level, such as CustomObject and ApexClass, and child types, such as CustomField and RecordType."
---
# listMetadata()

This call retrieves property information about metadata components in your organization. Data is returned for the components that match the criteria specified in the queries parameter. The queries array can contain up to three ListMetadataQuery queries for each call. This call supports every metadata type: both top-level, such as CustomObject and ApexClass, and child types, such as CustomField and RecordType.

## Syntax

[FileProperties](https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_retrieveresult.htm#meta_retrieveresult_fileproperties)\[\] = metadataConnection.listMetadata([ListMetadataQuery](https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_listmetadataquery.htm "The ListMetadataQuery parameter represents a list of objects that specify which components you are interested in.")\[\] queries, double asOfVersion);

## Usage

This call is useful when you want to identify individual components in package.xml for a [retrieve()](https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_retrieve.htm "The retrieve() call retrieves XML file representations of components in an organization.") call or if you want a high-level view of particular metadata types in your organization. For example, you can use this call to return a list of names of all the [CustomObject](https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/customobject.htm "Represents a custom object that stores data unique to your org or an external object that maps to data stored outside your org.") or [Layout](https://developer.salesforce.com/docs/atlas.en-us.264.0.api_meta.meta/api_meta/meta_layouts.htm) components in your organization. You can use this information to make a subsequent [retrieve()](https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_retrieve.htm "The retrieve() call retrieves XML file representations of components in an organization.") call to return a subset of these components. For more information about working with package.xml, see [Declarative (File-Based) Metadata API Calls](https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/file_based.htm).

This call is synchronous, so the results are returned in one call. This call differs from asynchronous calls, such as [retrieve()](https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_retrieve.htm "The retrieve() call retrieves XML file representations of components in an organization."), where at least one subsequent call is required to get the results.

## Permissions

Your client application must be logged in with the Modify Metadata Through Metadata API Functions or Modify All Data permission.

![Note](https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/images/icon_note.png)

#### Note

If a user requires access to metadata but not to data, enable the [Modify Metadata Through Metadata API Functions](https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_metadata_perm.htm "To use Metadata API, a user must have these things.") permission. Otherwise, enable the Modify All Data permission.

## Sample Code—Java

This sample code lists information about your custom objects. The code assumes that the SOAP binding has already been established.

public void listMetadata() {
  try {
    ListMetadataQuery query = new ListMetadataQuery();
    query.setType("CustomObject");
    //query.setFolder(null);
    double asOfVersion = 68.0;
    // Assuming that the SOAP binding has already been established.
    FileProperties\[\] lmr = metadataConnection.listMetadata(
        new ListMetadataQuery\[\] {query}, asOfVersion);
    if (lmr != null) {
      for (FileProperties n : lmr) {
        System.out.println("Component fullName: " + n.getFullName());
        System.out.println("Component type: " + n.getType());
      }
    }            
  } catch (ConnectionException ce) {
    ce.printStackTrace();
  }
}

## Arguments

### queries

- **Type**: [ListMetadataQuery](https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_listmetadataquery.htm "The ListMetadataQuery parameter represents a list of objects that specify which components you are interested in.")\[\]
- **Description**: A list of objects that specify which components you’re interested in.

### asOfVersion

- **Type**: double
- **Description**: The API version for the metadata listing request. If you don't specify a value in this field, it defaults to the API version specified when you logged in. This field allows you to override the default and set another API version. For example, you can list the metadata for a metadata type that was added in a later version than the API version specified when you logged in. This field is available in API version 18.0 and later.

## Response

[FileProperties](https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_retrieveresult.htm#meta_retrieveresult_fileproperties)