---
schema_version: "1"
id: b7838dea2856aab211a05e91cc142d50d53a18eae0205b295f7e39df35470874
title: DeployCallback Interface
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexref/apex_interface_Metadata_DeployCallback.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_interface_Metadata_DeployCallback.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: e51ed1ba4249b6bbb566a3055ec1f26f5abf2a34a4886f592d08e8dac3813205
description: An interface for metadata deployment callback classes.Method that is called when the asynchronous deployment of custom metadata completes.
---
# DeployCallback Interface

An interface for metadata deployment callback classes.

## Namespace

[Metadata](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_namespace_Metadata.htm "The Metadata namespace provides classes and methods for working with custom metadata in Salesforce")

## Usage

You must provide a callback class for the asynchronous deployment of custom metadata through Apex. This class must implement the Metadata.DeployCallback interface.

Salesforce calls your DeployCallback.handleResult() method asynchronously once the queued deployment completes. Because the callback is called as asynchronous Apex after deployment, there may be a brief period where the deploy has completed, but your callback has not been called yet.

- **[DeployCallback Methods](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_interface_Metadata_DeployCallback.htm#apex_Metadata_DeployCallback_methods)**
- **[DeployCallback Example Implementation](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_interface_Metadata_DeployCallback.htm#apex_interface_Metadata_DeployCallback_Example)**

## DeployCallback Methods

The following are methods for DeployCallback.

- **[handleResult(var1, var2)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_interface_Metadata_DeployCallback.htm#apex_Metadata_DeployCallback_handleResult)**  
    Method that is called when the asynchronous deployment of custom metadata completes.

### handleResult(var1, var2)

Method that is called when the asynchronous deployment of custom metadata completes.

#### Signature

public void handleResult(Metadata.DeployResult var1, Metadata.DeployCallbackContext var2)

#### Parameters

- **var1**:
    
    Type: [Metadata.DeployResult](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_Metadata_DeployResult.htm#apex_class_Metadata_DeployResult "Represents the results of a metadata deployment.")
    
    The results of the asynchronous deployment.
- **var2**:
    
    Type: [Metadata.DeployCallbackContext](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_Metadata_DeployCallbackContext.htm#apex_class_Metadata_DeployCallbackContext "Represents context information for a deployment job.")
    
    The context for the queued asynchronous deployment job.

#### Return Value

Type: void

## DeployCallback Example Implementation

This is an example implementation of the Metadata.DeployCallback interface.

public with sharing class MyCallback implements Metadata.DeployCallback {
    public void handleResult(Metadata.DeployResult result,
                             Metadata.DeployCallbackContext context) {
        if (result.status == Metadata.DeployStatus.Succeeded) {
            // Deployment was successful
        } else {
            // Deployment was not successful
        }
    }
}

The following example uses this implementation for a deployment.

// Setup callback and deploy
MyCallback callback = new MyCallback();
Metadata.Operations.enqueueDeployment(mdContainer, callback);