---
schema_version: "1"
id: 58e832b66e5bdb77ba4e1dd83a043ee2c87c3bf5f2ec4e94423396f00f6df91e
title: Deploy Apex Using Metadata API
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexcode/apex_deploying_metadataAPI.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_deploying_metadataAPI.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: b789191439520a56ba0a209953070305dbfa0013ebe9b6afbc03ec15ec3e3fa7
description: Use Metadata API to deploy customization information, such as custom object definitions for your org.
---
# Deploy Apex Using Metadata API

Use Metadata API to deploy customization information, such as custom object definitions for your org.

To deploy custom metadata, use the Metadata.Operations.enqueueDeployment() method to asynchronously deploy metadata to the current org. For more information, see [Operations Class](https://developer.salesforce.com/docs/atlas.en-us.264.0.apexref.meta/apexref/apex_class_Metadata_Operations.htm).

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

#### Note

If a single deployment has over 2,000 Apex classes, [ApexCodeCoverage](https://developer.salesforce.com/docs/atlas.en-us.264.0.api_tooling.meta/api_tooling/tooling_api_objects_apexcodecoverage.htm "HTML (New Window)") objects for the deployed classes are deleted even if the deployment fails or is rolled back. ApexCodeCoverageAggregate objects aren’t affected.

- [← Previous](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_deploying_ide.htm "Deploy Apex Using Salesforce Extensions for Visual Studio Code and Code Builder")
- [Next →](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_deploying_toolingAPI.htm "Deploy Apex Using Tooling API")

#### See Also

- [_Metadata API Developer Guide_: deploy()](https://developer.salesforce.com/docs/atlas.en-us.264.0.api_meta.meta/api_meta/meta_deploy.htm "Metadata API Developer Guide: deploy() - HTML (New Window)")
- [_Using Salesforce Features with Apex_: Metadata](https://developer.salesforce.com/docs/atlas.en-us.264.0.apexcode.meta/apexcode/apex_metadata.htm "Using Salesforce Features with Apex: Metadata - HTML (New Window)")