---
title: Patch a deployment event by version
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: Docs > API Reference > DORA Metrics
---

> For the complete documentation index, see [llms.txt](https://docs.datadoghq.com/llms.txt).

# Patch a deployment event by version{% #patch-a-deployment-event-by-version %}
Copy pageCopied
{% tab title="v2" %}
**Note**: This endpoint is in preview and is subject to change. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).
| Datadog site      | API endpoint                                                |
| ----------------- | ----------------------------------------------------------- |
| ap1.datadoghq.com | PATCH https://api.ap1.datadoghq.com/api/v2/dora/deployments |
| ap2.datadoghq.com | PATCH https://api.ap2.datadoghq.com/api/v2/dora/deployments |
| app.datadoghq.eu  | PATCH https://api.datadoghq.eu/api/v2/dora/deployments      |
| app.ddog-gov.com  | PATCH https://api.ddog-gov.com/api/v2/dora/deployments      |
| us2.ddog-gov.com  | PATCH https://api.us2.ddog-gov.com/api/v2/dora/deployments  |
| uk1.datadoghq.com | PATCH https://api.uk1.datadoghq.com/api/v2/dora/deployments |
| app.datadoghq.com | PATCH https://api.datadoghq.com/api/v2/dora/deployments     |
| us3.datadoghq.com | PATCH https://api.us3.datadoghq.com/api/v2/dora/deployments |
| us5.datadoghq.com | PATCH https://api.us5.datadoghq.com/api/v2/dora/deployments |

### Overview

Update a deployment's change failure status, identifying the deployment by its service, environment, and version instead of its ID. Use this to mark a deployment as a change failure or back to stable. You can optionally include remediation details to enable failed deployment recovery time calculation. If multiple deployments match the given service, environment, and version, the most recently finished one is updated. This endpoint requires the `dora_metrics_write` permission.

### Request

#### Body Data (required)



{% tab title="Model" %}

| Parent field | Field                            | Type          | Description                                                                                                                                                                                         |
| ------------ | -------------------------------- | ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|              | data [*required*]           | object        | The JSON:API data for patching a deployment identified by service, environment, and version.                                                                                                        |
| data         | attributes [*required*]     | object        | Attributes for patching a DORA deployment event identified by service, environment, and version.                                                                                                    |
| attributes   | change_failure [*required*] | boolean       | Indicates whether the deployment resulted in a change failure.                                                                                                                                      |
| attributes   | env [*required*]            | string        | The environment the deployment was performed in.                                                                                                                                                    |
| attributes   | remediation                      |  <oneOf> | Remediation details for the deployment. Optional, but required to calculate failed deployment recovery time. Specify either `id` or `version` to identify the remediation deployment, but not both. |
| remediation  | Object 1                         | object        | Remediation details identified by the ID of the remediation deployment.                                                                                                                             |
| Object 1     | id [*required*]             | string        | The ID of the remediation deployment.                                                                                                                                                               |
| Object 1     | type [*required*]           | enum          | The type of remediation action taken. Required when the failed deployment must be linked to a remediation deployment. Allowed enum values: `rollback,rollforward`                                   |
| remediation  | Object 2                         | object        | Remediation details identified by the version of the remediation deployment, matched against the same service and environment as the failed deployment.                                             |
| Object 2     | type [*required*]           | enum          | The type of remediation action taken. Required when the failed deployment must be linked to a remediation deployment. Allowed enum values: `rollback,rollforward`                                   |
| Object 2     | version [*required*]        | string        | The version of the remediation deployment.                                                                                                                                                          |
| attributes   | service [*required*]        | string        | The name of the service that was deployed.                                                                                                                                                          |
| attributes   | version [*required*]        | string        | The version deployed. This can be seen in the Service Catalog or in the APM Deployment Tracking.                                                                                                    |
| data         | type [*required*]           | enum          | JSON:API type for DORA deployment patch request. Allowed enum values: `dora_deployment_patch_request`                                                                                               |

{% /tab %}

{% tab title="Example" %}

```json
{
  "data": {
    "attributes": {
      "change_failure": true,
      "env": "prod",
      "remediation": {
        "id": "eG42zNIkVjM",
        "type": "rollback"
      },
      "service": "my-service",
      "version": "v1.2.3"
    },
    "type": "dora_deployment_patch_request"
  }
}
```

{% /tab %}

### Response

{% tab title="202" %}
Accepted
{% /tab %}

{% tab title="400" %}
Bad Request
{% tab title="Model" %}
API error response.

| Parent field | Field                    | Type     | Description                                                                     |
| ------------ | ------------------------ | -------- | ------------------------------------------------------------------------------- |
|              | errors [*required*] | [object] | A list of errors.                                                               |
| errors       | detail                   | string   | A human-readable explanation specific to this occurrence of the error.          |
| errors       | meta                     | object   | Non-standard meta-information about the error                                   |
| errors       | source                   | object   | References to the source of the error.                                          |
| source       | header                   | string   | A string indicating the name of a single request header which caused the error. |
| source       | parameter                | string   | A string indicating which URI query parameter caused the error.                 |
| source       | pointer                  | string   | A JSON pointer to the value in the request document that caused the error.      |
| errors       | status                   | string   | Status code of the response.                                                    |
| errors       | title                    | string   | Short human-readable summary of the error.                                      |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    {
      "detail": "Missing required attribute in body",
      "meta": {},
      "source": {
        "header": "Authorization",
        "parameter": "limit",
        "pointer": "/data/attributes/title"
      },
      "status": "400",
      "title": "Bad Request"
    }
  ]
}
```

{% /tab %}

{% /tab %}

{% tab title="403" %}
Not Authorized
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    "Bad Request"
  ]
}
```

{% /tab %}

{% /tab %}

{% tab title="429" %}
Too many requests
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    "Bad Request"
  ]
}
```

{% /tab %}

{% /tab %}

### Code Example

##### 
                  \## default
# 
 \# Curl command curl -X PATCH "https://api.datadoghq.com/api/v2/dora/deployments" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "change_failure": true,
      "env": "production",
      "service": "my-service",
      "version": "v1.2.3"
    },
    "type": "dora_deployment_patch_request"
  }
}
EOF 
                
##### 

```python
"""
Patch a deployment event by version returns "Accepted" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.dora_metrics_api import DORAMetricsApi
from datadog_api_client.v2.model.dora_deployment_patch_by_version_remediation_by_version import (
    DORADeploymentPatchByVersionRemediationByVersion,
)
from datadog_api_client.v2.model.dora_deployment_patch_by_version_request import DORADeploymentPatchByVersionRequest
from datadog_api_client.v2.model.dora_deployment_patch_by_version_request_attributes import (
    DORADeploymentPatchByVersionRequestAttributes,
)
from datadog_api_client.v2.model.dora_deployment_patch_by_version_request_data import (
    DORADeploymentPatchByVersionRequestData,
)
from datadog_api_client.v2.model.dora_deployment_patch_remediation_type import DORADeploymentPatchRemediationType
from datadog_api_client.v2.model.dora_deployment_patch_request_data_type import DORADeploymentPatchRequestDataType

body = DORADeploymentPatchByVersionRequest(
    data=DORADeploymentPatchByVersionRequestData(
        attributes=DORADeploymentPatchByVersionRequestAttributes(
            change_failure=True,
            env="production",
            remediation=DORADeploymentPatchByVersionRemediationByVersion(
                type=DORADeploymentPatchRemediationType.ROLLBACK,
                version="v1.2.2",
            ),
            service="my-service",
            version="v1.2.3",
        ),
        type=DORADeploymentPatchRequestDataType.DORA_DEPLOYMENT_PATCH_REQUEST,
    ),
)

configuration = Configuration()
configuration.unstable_operations["patch_dora_deployment_by_version"] = True
with ApiClient(configuration) as api_client:
    api_instance = DORAMetricsApi(api_client)
    api_instance.patch_dora_deployment_by_version(body=body)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=python) and then save the example to `example.py` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
##### 

```ruby
# Patch a deployment event by version returns "Accepted" response

require "datadog_api_client"
DatadogAPIClient.configure do |config|
  config.unstable_operations["v2.patch_dora_deployment_by_version".to_sym] = true
end
api_instance = DatadogAPIClient::V2::DORAMetricsAPI.new

body = DatadogAPIClient::V2::DORADeploymentPatchByVersionRequest.new({
  data: DatadogAPIClient::V2::DORADeploymentPatchByVersionRequestData.new({
    attributes: DatadogAPIClient::V2::DORADeploymentPatchByVersionRequestAttributes.new({
      change_failure: true,
      env: "production",
      remediation: DatadogAPIClient::V2::DORADeploymentPatchByVersionRemediationByVersion.new({
        type: DatadogAPIClient::V2::DORADeploymentPatchRemediationType::ROLLBACK,
        version: "v1.2.2",
      }),
      service: "my-service",
      version: "v1.2.3",
    }),
    type: DatadogAPIClient::V2::DORADeploymentPatchRequestDataType::DORA_DEPLOYMENT_PATCH_REQUEST,
  }),
})
p api_instance.patch_dora_deployment_by_version(body)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=ruby) and then save the example to `example.rb` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
##### 

```go
// Patch a deployment event by version returns "Accepted" response

package main

import (
	"context"
	"fmt"
	"os"

	"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
	"github.com/DataDog/datadog-api-client-go/v2/api/datadogV2"
)

func main() {
	body := datadogV2.DORADeploymentPatchByVersionRequest{
		Data: datadogV2.DORADeploymentPatchByVersionRequestData{
			Attributes: datadogV2.DORADeploymentPatchByVersionRequestAttributes{
				ChangeFailure: true,
				Env:           "production",
				Remediation: &datadogV2.DORADeploymentPatchByVersionRemediation{
					DORADeploymentPatchByVersionRemediationByVersion: &datadogV2.DORADeploymentPatchByVersionRemediationByVersion{
						Type:    datadogV2.DORADEPLOYMENTPATCHREMEDIATIONTYPE_ROLLBACK,
						Version: "v1.2.2",
					}},
				Service: "my-service",
				Version: "v1.2.3",
			},
			Type: datadogV2.DORADEPLOYMENTPATCHREQUESTDATATYPE_DORA_DEPLOYMENT_PATCH_REQUEST,
		},
	}
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	configuration.SetUnstableOperationEnabled("v2.PatchDORADeploymentByVersion", true)
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV2.NewDORAMetricsApi(apiClient)
	r, err := api.PatchDORADeploymentByVersion(ctx, body)

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `DORAMetricsApi.PatchDORADeploymentByVersion`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=go) and then save the example to `main.go` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
##### 

```java
// Patch a deployment event by version returns "Accepted" response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.DoraMetricsApi;
import com.datadog.api.client.v2.model.DORADeploymentPatchByVersionRemediation;
import com.datadog.api.client.v2.model.DORADeploymentPatchByVersionRemediationByVersion;
import com.datadog.api.client.v2.model.DORADeploymentPatchByVersionRequest;
import com.datadog.api.client.v2.model.DORADeploymentPatchByVersionRequestAttributes;
import com.datadog.api.client.v2.model.DORADeploymentPatchByVersionRequestData;
import com.datadog.api.client.v2.model.DORADeploymentPatchRemediationType;
import com.datadog.api.client.v2.model.DORADeploymentPatchRequestDataType;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = ApiClient.getDefaultApiClient();
    defaultClient.setUnstableOperationEnabled("v2.patchDORADeploymentByVersion", true);
    DoraMetricsApi apiInstance = new DoraMetricsApi(defaultClient);

    DORADeploymentPatchByVersionRequest body =
        new DORADeploymentPatchByVersionRequest()
            .data(
                new DORADeploymentPatchByVersionRequestData()
                    .attributes(
                        new DORADeploymentPatchByVersionRequestAttributes()
                            .changeFailure(true)
                            .env("production")
                            .remediation(
                                new DORADeploymentPatchByVersionRemediation(
                                    new DORADeploymentPatchByVersionRemediationByVersion()
                                        .type(DORADeploymentPatchRemediationType.ROLLBACK)
                                        .version("v1.2.2")))
                            .service("my-service")
                            .version("v1.2.3"))
                    .type(DORADeploymentPatchRequestDataType.DORA_DEPLOYMENT_PATCH_REQUEST));

    try {
      apiInstance.patchDORADeploymentByVersion(body);
    } catch (ApiException e) {
      System.err.println("Exception when calling DoraMetricsApi#patchDORADeploymentByVersion");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=java) and then save the example to `Example.java` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
##### 

```rust
// Patch a deployment event by version returns "Accepted" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_dora_metrics::DORAMetricsAPI;
use datadog_api_client::datadogV2::model::DORADeploymentPatchByVersionRemediation;
use datadog_api_client::datadogV2::model::DORADeploymentPatchByVersionRemediationByVersion;
use datadog_api_client::datadogV2::model::DORADeploymentPatchByVersionRequest;
use datadog_api_client::datadogV2::model::DORADeploymentPatchByVersionRequestAttributes;
use datadog_api_client::datadogV2::model::DORADeploymentPatchByVersionRequestData;
use datadog_api_client::datadogV2::model::DORADeploymentPatchRemediationType;
use datadog_api_client::datadogV2::model::DORADeploymentPatchRequestDataType;

#[tokio::main]
async fn main() {
    let body =
        DORADeploymentPatchByVersionRequest::new(
            DORADeploymentPatchByVersionRequestData::new(
                DORADeploymentPatchByVersionRequestAttributes::new(
                    true,
                    "production".to_string(),
                    "my-service".to_string(),
                    "v1.2.3".to_string(),
                ).remediation(
                    DORADeploymentPatchByVersionRemediation::DORADeploymentPatchByVersionRemediationByVersion(
                        Box::new(
                            DORADeploymentPatchByVersionRemediationByVersion::new(
                                DORADeploymentPatchRemediationType::ROLLBACK,
                                "v1.2.2".to_string(),
                            ),
                        ),
                    ),
                ),
                DORADeploymentPatchRequestDataType::DORA_DEPLOYMENT_PATCH_REQUEST,
            ),
        );
    let mut configuration = datadog::Configuration::new();
    configuration.set_unstable_operation_enabled("v2.PatchDORADeploymentByVersion", true);
    let api = DORAMetricsAPI::with_config(configuration);
    let resp = api.patch_dora_deployment_by_version(body).await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=rust) and then save the example to `src/main.rs` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run
##### 

```typescript
/**
 * Patch a deployment event by version returns "Accepted" response
 */

import { client, v2 } from "@datadog/datadog-api-client";

const configuration = client.createConfiguration();
configuration.unstableOperations["v2.patchDORADeploymentByVersion"] = true;
const apiInstance = new v2.DORAMetricsApi(configuration);

const params: v2.DORAMetricsApiPatchDORADeploymentByVersionRequest = {
  body: {
    data: {
      attributes: {
        changeFailure: true,
        env: "production",
        remediation: {
          type: "rollback",
          version: "v1.2.2",
        },
        service: "my-service",
        version: "v1.2.3",
      },
      type: "dora_deployment_patch_request",
    },
  },
};

apiInstance
  .patchDORADeploymentByVersion(params)
  .then((data: any) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=typescript) and then save the example to `example.ts` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
{% /tab %}
