Is it possible to query deployment status->Deployment details start time and end time?

Deployment Details


In 2021, the query is available using tooling API:

SELECT Id, Status, StartDate, CompletedDate FROM DeployRequest

enter image description here

P.S: Added as answer because I spent more than an hour by simply assuming it's not possible using Tooling API


You can't query it, but there is an API call: checkDeployStatus. This returns a DeployResult object that includes things like start date/time, end date/time, status, who cancelled it, number of tests run, errors, and so on.

  • can i call the api inside an aura component and display the record details? as there is very less information in the documentation so is there any sample code available.
    – Raj SF
    Jun 25 '20 at 11:20
  • @Ananga It should be possible, though I haven't specifically tried it. It would probably be worth asking a new question if you haven't already, perhaps someone's already built this.
    – sfdcfox
    Jun 25 '20 at 14:10
  • i already did it but not getting proper solution.salesforce.stackexchange.com/questions/310722/…
    – Raj SF
    Jun 26 '20 at 7:45

If you investigate the Id value you will see that the object type is DeployRequest:

system.debug(Id.valueOf('0Af'.rightPad(15, '0')).getSObjectType());

This object is not currently available for query in SOQL, nor via the Tooling API or Metadata API.

  • 1
    I think you're being too literal.
    – sfdcfox
    Mar 7 '18 at 19:01
  • 1
    Is the deploymentID same as what we get from ant deployment? via Ant we can check the status of deployment, probably that can be used :/ Mar 7 '18 at 19:03
  • 4
    For anyone stumbling upon this, DeployRequest does now appear to be available to query in Tooling API, e.g. SELECT Id, Status, StartDate, CompletedDate FROM DeployRequest Sep 14 '20 at 16:47

You can't currently get these details via SOQL. Instead, as sfdcfox answered, you can use the checkDeployStatus Metadata API to get this data.

Examples of calling this from Apex:

public void checkDeployStatus(Id deployRequestId) {
    HttpRequest req = new HttpRequest();
    req.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionID());
    req.setHeader('Content-Type', 'application/json');

    String instanceName = System.Url.getSalesforceBaseUrl().toExternalForm();
    // Visualforce can't make the direct API calls. Might need to massage the instanceName
    req.setEndpoint(instanceName + '/services/data/v49.0/metadata/deployRequest/' + deployRequestId + '?includeDetails=true');
    Http http = new Http();
    try {
        HTTPResponse res = http.send(req);                 
        System.debug('STATUS:' + res.getStatus());
        System.debug('STATUS_CODE:' + res.getStatusCode());
        String responseBody = res.getBody(); 

        if(res.getStatusCode() == 200) {

            DeployResultJson jsonResult = (DeployResultJson)JSON.deserialize(responseBody, DeployResultJson.class);

            if(jsonResult.deployResult.details != null) {
                for(Metadata.DeployMessage dm : jsonResult.deployResult.details.componentSuccesses) {
                    if(dm.fileName == 'package.xml') {

                    // Do something with the DeployMessage

    } catch(System.CalloutException e) {
        // Exception handling goes here

// Support unpacking via JSON.deserialize from deployRequest metadata api call
public class DeployResultJson {       
    public String id;
    public Object validatedDeployRequestId;
    public Object deployOptions;
    public Metadata.DeployResult deployResult;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.