---
schema_version: "1"
id: 55f509c896dc034311fe272047189e17daf7207ed7d2bbcb20b9cdcce7cb7517
title: Custom Metadata Types (CustomObject)
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/api_meta/meta_custommetadatatypes.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_custommetadatatypes.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 0e797aea53ef7f9b562b7553ec756f86b547e5355707121b125385f61ffa0435
description: Represents the metadata associated with a custom metadata type.
---
# Custom Metadata Types (CustomObject)

Represents the metadata associated with a custom metadata type.

For more information, see [Custom Metadata Types](https://help.salesforce.com/s/articleView?id=platform.custommetadatatypes_overview.htm&language=en_US "HTML (New Window)").

## File Suffix and Directory Location

A custom metadata type is defined as a custom object and is stored in the objects folder. Custom metadata types have a suffix of \_\_mdt (instead of \_\_c for custom objects). Custom metadata type field names have a suffix of \_\_c, like other custom fields. Custom metadata type field names must be dot-qualified with the name of the custom metadata type to which they belong.

Names of custom metadata types must be unique within their namespace. All custom metadata types belong to the CustomMetadata namespace and can optionally belong to a second namespace. In your organization, you can use custom metadata types with your namespace and also other organizations’ namespaces.

## Version

Custom metadata type components are available in API version 31.0 and later.

## Special Access Rules

To create custom metadata types, you must have the “Author Apex” permission. Apex code can create, read, and update (but not delete) custom metadata records, as long as the metadata is subscriber-controlled and visible from within the code's namespace. You can edit records in memory but not upsert or delete them. Apex code can deploy custom metadata records, but not via a DML operation. Moreover, DML operations aren’t allowed on custom metadata in the Partner or Enterprise APIs. Customers who install a managed custom metadata type can’t add new custom fields to it. With unpackaged metadata, both developer-controlled and subscriber-controlled access behave the same: like subscriber-controlled access. Refer to [Trust, but Verify: Apex Metadata API and Security](https://developer.salesforce.com/blogs/engineering/2017/06/apex-metadata-api-security.html) to learn more.

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

#### Note

Audit fields (CreatedDate, CreatedBy, LastModifiedDate, LastModifiedBy, SystemModStamp) remain uneditable.

## Fields

Custom metadata types can contain the following CustomObject fields.

To make the fields on your custom metadata types unique and indexable, mark your fields as Unique and ExternalId.

<table class="featureTable sort_table" summary="">



          <thead class="thead sorted" align="left">
            <tr>
              <th class="featureTableHeader  " id="d315419e142">Field Name</th>

              <th class="featureTableHeader  " id="d315419e145">Field Type</th>

              <th class="featureTableHeader  " id="d315419e148">Description</th>

            </tr>

          </thead>

          <tbody class="tbody">
            <tr>
              <td class="entry" headers="d315419e142" data-title="Field Name"><span class="keyword parmname">description</span></td>

              <td class="entry" headers="d315419e145" data-title="Field Type">string</td>

              <td class="entry" headers="d315419e148" data-title="Description">A description of the custom metadata type. This field can contain a maximum of
                1,000 characters.</td>

            </tr>

            <tr>
              <td class="entry" headers="d315419e142" data-title="Field Name"><span class="keyword parmname">fields</span></td>

              <td class="entry" headers="d315419e145" data-title="Field Type"><a class="xref" href="https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/customfield.htm" title="Represents the metadata associated with a field. Use this metadata type to create, update, or delete custom field definitions on standard, custom, and external objects or standard field definitions on standard objects.">CustomField[]</a></td>

              <td class="entry" headers="d315419e148" data-title="Description">Represents one or more custom fields in the custom metadata type.</td>

            </tr>

            <tr>
              <td class="entry" headers="d315419e142" data-title="Field Name"><span class="keyword parmname">gender</span></td>

              <td class="entry" headers="d315419e145" data-title="Field Type">Gender</td>

              <td class="entry" headers="d315419e148" data-title="Description">Indicates the gender of the noun that represents the object. This field is used
                for languages where words need different treatment depending on their
                gender.</td>

            </tr>

            <tr>
              <td class="entry" headers="d315419e142" data-title="Field Name"><span class="keyword parmname">label</span></td>

              <td class="entry" headers="d315419e145" data-title="Field Type">string</td>

              <td class="entry" headers="d315419e148" data-title="Description">A label that represents the object throughout the Salesforce Setup user
                interface. Custom metadata types are visible only through the recently used objects
                list on the Lightning Platform Home Page and in the packaging user
                interface.</td>

            </tr>

            <tr>
              <td class="entry" headers="d315419e142" data-title="Field Name"><span class="keyword parmname">pluralLabel</span></td>

              <td class="entry" headers="d315419e145" data-title="Field Type">string</td>

              <td class="entry" headers="d315419e148" data-title="Description">The plural version of the label value.</td>

            </tr>

            <tr>
              <td class="entry" headers="d315419e142" data-title="Field Name"><span class="keyword parmname">startsWith</span></td>

              <td class="entry" headers="d315419e145" data-title="Field Type">StartsWith (<a class="xref" href="https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_objects_intro.htm#enumeration_title">enumeration</a> of type
                string)</td>

              <td class="entry" headers="d315419e148" data-title="Description">Indicates whether the noun starts with a vowel, a consonant, or a special
                character. This field is used for languages where words need different treatment
                depending on their first character.</td>

            </tr>

            <tr>
              <td class="entry" headers="d315419e142" data-title="Field Name"><span class="keyword parmname">visibility</span></td>

              <td class="entry" headers="d315419e145" data-title="Field Type">SetupObjectVisibility (enumeration of type string)</td>

              <td class="entry" headers="d315419e148" data-title="Description">This field returns the visibility of a custom metadata type. The following
                values are valid:<ul class="ul bulletList">
                  <li class="li">
                    <samp class="codeph nolang">Public</samp>—If the custom setting or
                    custom metadata type is packaged, it’s accessible to all subscribing
                    organizations.
                  </li>

                  <li class="li">
                    <samp class="codeph nolang">Protected</samp>—If the custom object,
                    custom setting, or custom metadata type is in a managed package, it’s accessible
                    only to the developer org. Subscribing orgs can’t access it.
                  </li>

                  <li class="li">
                    <samp class="codeph nolang">PackageProtected</samp>—If the custom
                    metadata type is <samp class="codeph nolang">PackageProtected</samp>, it’s
                    only accessible by the custom Apex code in the package. Use this value to secure
                    secrets such as API access keys and security tokens. Available in API version
                    47.0 and later.
                  </li>

                </ul>
                <p class="p">The default value is <samp class="codeph nolang">Public</samp>.</p>
              </td>

            </tr>

          </tbody>

        </table>

## Declarative Metadata Sample Definition

In this example, Picklists R Us creates its Reusable Picklist custom metadata type by deploying a file in the objects folder, named ReusablePicklistOption\_\_mdt.object, with these contents.

<?xml version="1.0" encoding="UTF-8"?>
<CustomObject xmlns="http://soap.sforce.com/2006/04/metadata">
   <fields\>
      <fullName\>AlphaSort\_\_c</fullName\>
      <defaultValue\>false</defaultValue\>
      <externalId\>false</externalId\>
      <label\>Sorted Alphabetically</label\>
      <type\>Checkbox</type\>
   </fields\>
   <label\>Reusable Picklist</label\>
   <pluralLabel\>Reusable Picklist</pluralLabel\>
   <visibility\>Public</visibility\>
</CustomObject\>

This excerpt from a package.xml file shows the use of dot notation and the \_\_mdt suffix. If you’re using a namespace, for example picklist1234,​ the full name of ReusablePicklistOption\_\_mdt would be picklist1234​\_\_ReusablePicklistOption\_\_mdt.

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
...
   <types\>
      <members\>PicklistTest\_\_c.PicklistTestField\_\_c</members\>
      <members\>ReusablePicklistOption\_\_mdt.Picklist\_\_c</members\>
      <members\>ReusablePicklistOption\_\_mdt.SortOrder\_\_c</members\>
      <members\>PicklistUsage\_\_mdt.Field\_\_c</members\>
      <members\>PicklistUsage\_\_mdt.Picklist\_\_c</members\>
      <members\>PicklistUsage\_\_mdt.SObjectType\_\_c</members\>
      <members\>ReusablePicklist\_\_mdt.AlphaSort\_\_c</members\>
      <name\>CustomField</name\>
   </types\>
...
   <types\>
      <members\>PicklistTest\_\_c</members\>
      <members\>ReusablePicklistOption\_\_mdt</members\>
      <members\>PicklistUsage\_\_mdt</members\>
      <members\>ReusablePicklist\_\_mdt</members\>
      <name\>CustomObject</name\>
   </types\>
...
   <version\>68.0</version\>
</Package\>

## Wildcard Support in the Manifest File

This metadata type supports the wildcard character \* (asterisk) in the package.xml manifest file. For information about using the manifest file, see [Deploying and Retrieving Metadata with the Zip File](https://developer.salesforce.com/docs/atlas.en-us.264.0.api_meta.meta/api_meta/file_based_zip_file.htm).

1. [CustomMetadata](https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_custommetadata.htm)  
    Represents a record of a custom metadata type.