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

# Patch a deployment event{% #patch-a-deployment-event %}

{% tab title="v2" %}

| Datadog site      | API endpoint                                                                |
| ----------------- | --------------------------------------------------------------------------- |
| ap1.datadoghq.com | PATCH https://api.ap1.datadoghq.com/api/v2/dora/deployments/{deployment_id} |
| ap2.datadoghq.com | PATCH https://api.ap2.datadoghq.com/api/v2/dora/deployments/{deployment_id} |
| app.datadoghq.eu  | PATCH https://api.datadoghq.eu/api/v2/dora/deployments/{deployment_id}      |
| app.ddog-gov.com  | PATCH https://api.ddog-gov.com/api/v2/dora/deployments/{deployment_id}      |
| us2.ddog-gov.com  | PATCH https://api.us2.ddog-gov.com/api/v2/dora/deployments/{deployment_id}  |
| app.datadoghq.com | PATCH https://api.datadoghq.com/api/v2/dora/deployments/{deployment_id}     |
| us3.datadoghq.com | PATCH https://api.us3.datadoghq.com/api/v2/dora/deployments/{deployment_id} |
| us5.datadoghq.com | PATCH https://api.us5.datadoghq.com/api/v2/dora/deployments/{deployment_id} |

### Overview

Update a deployment's change failure status. 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. This endpoint requires the `dora_metrics_write` permission.

### Arguments

#### Path Parameters

| Name                            | Type   | Description                     |
| ------------------------------- | ------ | ------------------------------- |
| deployment_id [*required*] | string | The ID of the deployment event. |

### Request

#### Body Data (required)



{% tab title="Model" %}

| Parent field | Field                        | Type    | Description                                                                                                                                                       |
| ------------ | ---------------------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|              | data [*required*]       | object  | The JSON:API data for patching a deployment.                                                                                                                      |
| data         | attributes [*required*] | object  | Attributes for patching a DORA deployment event.                                                                                                                  |
| attributes   | change_failure               | boolean | Indicates whether the deployment resulted in a change failure.                                                                                                    |
| attributes   | remediation                  | object  | Remediation details for the deployment. Optional, but required to calculate failed deployment recovery time.                                                      |
| remediation  | id                           | string  | The ID of the remediation deployment. Required when the failed deployment must be linked to a remediation deployment.                                             |
| remediation  | type                         | enum    | The type of remediation action taken. Required when the failed deployment must be linked to a remediation deployment. Allowed enum values: `rollback,rollforward` |
| data         | id [*required*]         | string  | The ID of the deployment to patch.                                                                                                                                |
| 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,
      "remediation": {
        "id": "eG42zNIkVjM",
        "type": "rollback"
      }
    },
    "id": "z_RwVLi7v4Y",
    "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
# 
 \# Path parameters export deployment_id="CHANGE_ME" \# Curl command curl -X PATCH "https://api.datadoghq.com/api/v2/dora/deployments/${deployment_id}" \
-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,
      "remediation": {
        "id": "eG42zNIkVjM",
        "type": "rollback"
      }
    },
    "id": "z_RwVLi7v4Y",
    "type": "dora_deployment_patch_request"
  }
}
EOF 
                
##### 

```python
"""
Patch a deployment event 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_remediation import DORADeploymentPatchRemediation
from datadog_api_client.v2.model.dora_deployment_patch_remediation_type import DORADeploymentPatchRemediationType
from datadog_api_client.v2.model.dora_deployment_patch_request import DORADeploymentPatchRequest
from datadog_api_client.v2.model.dora_deployment_patch_request_attributes import DORADeploymentPatchRequestAttributes
from datadog_api_client.v2.model.dora_deployment_patch_request_data import DORADeploymentPatchRequestData
from datadog_api_client.v2.model.dora_deployment_patch_request_data_type import DORADeploymentPatchRequestDataType

body = DORADeploymentPatchRequest(
    data=DORADeploymentPatchRequestData(
        attributes=DORADeploymentPatchRequestAttributes(
            change_failure=True,
            remediation=DORADeploymentPatchRemediation(
                id="eG42zNIkVjM",
                type=DORADeploymentPatchRemediationType.ROLLBACK,
            ),
        ),
        id="z_RwVLi7v4Y",
        type=DORADeploymentPatchRequestDataType.DORA_DEPLOYMENT_PATCH_REQUEST,
    ),
)

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = DORAMetricsApi(api_client)
    api_instance.patch_dora_deployment(deployment_id="deployment_id", 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 returns "Accepted" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V2::DORAMetricsAPI.new

body = DatadogAPIClient::V2::DORADeploymentPatchRequest.new({
  data: DatadogAPIClient::V2::DORADeploymentPatchRequestData.new({
    attributes: DatadogAPIClient::V2::DORADeploymentPatchRequestAttributes.new({
      change_failure: true,
      remediation: DatadogAPIClient::V2::DORADeploymentPatchRemediation.new({
        id: "eG42zNIkVjM",
        type: DatadogAPIClient::V2::DORADeploymentPatchRemediationType::ROLLBACK,
      }),
    }),
    id: "z_RwVLi7v4Y",
    type: DatadogAPIClient::V2::DORADeploymentPatchRequestDataType::DORA_DEPLOYMENT_PATCH_REQUEST,
  }),
})
p api_instance.patch_dora_deployment("deployment_id", 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 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.DORADeploymentPatchRequest{
		Data: datadogV2.DORADeploymentPatchRequestData{
			Attributes: datadogV2.DORADeploymentPatchRequestAttributes{
				ChangeFailure: datadog.PtrBool(true),
				Remediation: &datadogV2.DORADeploymentPatchRemediation{
					Id:   datadog.PtrString("eG42zNIkVjM"),
					Type: datadogV2.DORADEPLOYMENTPATCHREMEDIATIONTYPE_ROLLBACK.Ptr(),
				},
			},
			Id:   "z_RwVLi7v4Y",
			Type: datadogV2.DORADEPLOYMENTPATCHREQUESTDATATYPE_DORA_DEPLOYMENT_PATCH_REQUEST,
		},
	}
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV2.NewDORAMetricsApi(apiClient)
	r, err := api.PatchDORADeployment(ctx, "deployment_id", body)

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `DORAMetricsApi.PatchDORADeployment`: %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 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.DORADeploymentPatchRemediation;
import com.datadog.api.client.v2.model.DORADeploymentPatchRemediationType;
import com.datadog.api.client.v2.model.DORADeploymentPatchRequest;
import com.datadog.api.client.v2.model.DORADeploymentPatchRequestAttributes;
import com.datadog.api.client.v2.model.DORADeploymentPatchRequestData;
import com.datadog.api.client.v2.model.DORADeploymentPatchRequestDataType;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = ApiClient.getDefaultApiClient();
    DoraMetricsApi apiInstance = new DoraMetricsApi(defaultClient);

    DORADeploymentPatchRequest body =
        new DORADeploymentPatchRequest()
            .data(
                new DORADeploymentPatchRequestData()
                    .attributes(
                        new DORADeploymentPatchRequestAttributes()
                            .changeFailure(true)
                            .remediation(
                                new DORADeploymentPatchRemediation()
                                    .id("eG42zNIkVjM")
                                    .type(DORADeploymentPatchRemediationType.ROLLBACK)))
                    .id("z_RwVLi7v4Y")
                    .type(DORADeploymentPatchRequestDataType.DORA_DEPLOYMENT_PATCH_REQUEST));

    try {
      apiInstance.patchDORADeployment("deployment_id", body);
    } catch (ApiException e) {
      System.err.println("Exception when calling DoraMetricsApi#patchDORADeployment");
      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 returns "Accepted" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_dora_metrics::DORAMetricsAPI;
use datadog_api_client::datadogV2::model::DORADeploymentPatchRemediation;
use datadog_api_client::datadogV2::model::DORADeploymentPatchRemediationType;
use datadog_api_client::datadogV2::model::DORADeploymentPatchRequest;
use datadog_api_client::datadogV2::model::DORADeploymentPatchRequestAttributes;
use datadog_api_client::datadogV2::model::DORADeploymentPatchRequestData;
use datadog_api_client::datadogV2::model::DORADeploymentPatchRequestDataType;

#[tokio::main]
async fn main() {
    let body = DORADeploymentPatchRequest::new(DORADeploymentPatchRequestData::new(
        DORADeploymentPatchRequestAttributes::new()
            .change_failure(true)
            .remediation(
                DORADeploymentPatchRemediation::new()
                    .id("eG42zNIkVjM".to_string())
                    .type_(DORADeploymentPatchRemediationType::ROLLBACK),
            ),
        "z_RwVLi7v4Y".to_string(),
        DORADeploymentPatchRequestDataType::DORA_DEPLOYMENT_PATCH_REQUEST,
    ));
    let configuration = datadog::Configuration::new();
    let api = DORAMetricsAPI::with_config(configuration);
    let resp = api
        .patch_dora_deployment("deployment_id".to_string(), 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 returns "Accepted" response
 */

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

const configuration = client.createConfiguration();
const apiInstance = new v2.DORAMetricsApi(configuration);

const params: v2.DORAMetricsApiPatchDORADeploymentRequest = {
  body: {
    data: {
      attributes: {
        changeFailure: true,
        remediation: {
          id: "eG42zNIkVjM",
          type: "rollback",
        },
      },
      id: "z_RwVLi7v4Y",
      type: "dora_deployment_patch_request",
    },
  },
  deploymentId: "deployment_id",
};

apiInstance
  .patchDORADeployment(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 %}
