---
schema_version: "1"
id: 7d6093979d8ef720928f08dab931101182a75b343ddb7006bd07a5b6e193c75d
title: renameMetadata()
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/api_meta/meta_renameMetadata.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_renameMetadata.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 39aa3073ef07c36b422280b79b884263f6ef9a21a1733cc9374350d141b4c4ff
description: Renames a metadata component in your organization synchronously.
---
# renameMetadata()

Renames a metadata component in your organization synchronously.

## Syntax

[SaveResult](https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_saveResult.htm#meta_saveResult "Contains result information for the createMetadata, updateMetadata, or renameMetadata call.") = metadataConnection.renameMetadata(string metadataType, String oldFullname, String newFullname);

## Usage

Use the renameMetadata() call to rename one metadata component in your organization. This call executes synchronously, meaning the call returns only when the operation completes.

You can use this call to rename any of the objects that extend [Metadata](https://developer.salesforce.com/docs/atlas.en-us.264.0.api_meta.meta/api_meta/metadata.htm). For more details, see [Metadata Components and Types](https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_objects_intro.htm "Metadata components are not based on sObjects, like objects in the API. Instead, they are based on metadata types, such as ApexClass and CustomObject, which extend Metadata, the base class for all metadata types. A component is an instance of a metadata type.").

## Version

Available in API version 30.0 and later.

## 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.

## Basic Steps for Renaming Metadata Components

Use this process to rename a metadata component.

1. Determine the metadata type of the component you want to rename, its current full name, and the new full name. See [Metadata](https://developer.salesforce.com/docs/atlas.en-us.264.0.api_meta.meta/api_meta/metadata.htm) for more details on the fullName field.
2. Invoke the renameMetadata() call. For the first argument, pass in the name of the metadata type. Pass in the old full name as the second argument and the new full name as the last argument.
    
    A SaveResult object that contains information about whether the operation was successful is returned. If successful, the object contains the name of the renamed component, which is the new name. If it wasn’t successful, the object returns any errors.

## Sample Code—Java

public void renameCustomObjectSync() {
 try {
    SaveResult\[\] results = metadataConnection.renameMetadata(
        "CustomObject", "MyCustomObject1\_\_c","MyCustomObject1New\_\_c");
    for (SaveResult r : results) {
    	if (r.isSuccess()) {
    		System.out.println("Renamed component: " + r.getName());
    	}
    	else {
    		System.out.println("Errors were encountered while renaming " + r.getName());
    		for(Error e : r.getErrors()) {
    			System.out.println("Error message: " + e.getMessage());
    			System.out.println("Status code: " + e.getStatusCode());
    		}
    	}
    }
  } catch (ConnectionException ce) {
    ce.printStackTrace();
  } catch (InterruptedException ie) {
    ie.printStackTrace();
  }
}

## Arguments

### metadataType

- **Type**: string
- **Description**: The metadata type of the components to rename.

### oldFullName

- **Type**: string
- **Description**: The current component full name.

### newFullName

- **Type**: string
- **Description**: The full name of the new component.

## Response

[SaveResult](https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_saveResult.htm "Contains result information for the createMetadata, updateMetadata, or renameMetadata call.")