---
title: 배포 취소
description: 활성 배포를 취소하고 보류 중인 모든 작업을 중지합니다. 배포를 취소하면 다음과 같습니다.
breadcrumbs: 문서 > API > 배포 취소
---

> For the complete documentation index, see [llms.txt](https://dnd37xeb23o8n.cloudfront.net/stefon.simmons/docs-astro-web-10435/llms.txt).

# 배포 취소

## v2 (latest)

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

### Overview

활성 배포를 취소하고 보류 중인 모든 작업을 중지합니다.
배포를 취소하면 다음과 같습니다.

- 아직 시작되지 않은 호스트의 모든 보류 중인 작업이 중지됩니다.
- 호스트에서 현재 진행 중인 작업은 현재 상태에 따라 완료되거나 중단될 수 있습니다.
- 호스트에 이미 적용된 구성 변경 사항이나 패키지 업그레이드는 롤백되지 않습니다.

취소 후 GET 엔드포인트를 사용하여 배포의 최종 상태를 조회하고 어떤 호스트가
취소 전에 성공적으로 업데이트되었는지 확인할 수 있습니다.

`pending` 또는 `running` 상태인 배포만 취소할 수 있습니다. 배포가 취소 가능한 상태가 아닌 경우 400을 반환합니다. 지정된 ID와 일치하는 배포가 없거나 해당 배포에 대한 액세스 권한이 없는 경우 404를 반환합니다.

This endpoint requires all of the following permissions:

- `agent_upgrade_write`
- `fleet_policies_write`

### Arguments

#### Path Parameters

| Field                      | Type   | Description                                        |
| -------------------------- | ------ | -------------------------------------------------- |
| deployment_id [*required*] | string | The unique identifier of the deployment to cancel. |

### Response

{% tabs %}
{% tab label="200" %}
OK

{% tabs %}
{% tab label="Model" %}
Response containing the result of a deployment cancellation request.

| Parent field | Field                   | Type   | Description                                                                                |
| ------------ | ----------------------- | ------ | ------------------------------------------------------------------------------------------ |
|              | data [*required*]       | object | A deployment cancellation response.                                                        |
| data         | attributes [*required*] | object | Attributes of a deployment cancellation response.                                          |
| attributes   | message                 | string | Human-readable message describing the outcome of the cancellation request.                 |
| attributes   | status                  | string | Status of the deployment after the cancellation request.                                   |
| data         | id [*required*]         | string | Unique identifier for the deployment.                                                      |
| data         | type [*required*]       | enum   | The type of deployment resource. Allowed enum values: `deployment`. Default: `deployment`. |
{% /tab %}

{% tab label="Example" %}
```json
{
  "data": {
    "attributes": {
      "message": "Cancellation has been requested; the deployment is stopping.",
      "status": "stopping"
    },
    "id": "k7Q-3mX-p9Z",
    "type": "deployment"
  }
}
```
{% /tab %}
{% /tabs %}
{% /tab %}

{% tab label="400" %}
Bad Request

{% tabs %}
{% tab label="Model" %}
API error response.

| Field               | Type     | Description       |
| ------------------- | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |
{% /tab %}

{% tab label="Example" %}
```json
{
  "errors": [
    "Bad Request"
  ]
}
```
{% /tab %}
{% /tabs %}
{% /tab %}

{% tab label="401" %}
Unauthorized

{% tabs %}
{% tab label="Model" %}
API error response.

| Field               | Type     | Description       |
| ------------------- | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |
{% /tab %}

{% tab label="Example" %}
```json
{
  "errors": [
    "Bad Request"
  ]
}
```
{% /tab %}
{% /tabs %}
{% /tab %}

{% tab label="403" %}
Forbidden

{% tabs %}
{% tab label="Model" %}
API error response.

| Field               | Type     | Description       |
| ------------------- | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |
{% /tab %}

{% tab label="Example" %}
```json
{
  "errors": [
    "Bad Request"
  ]
}
```
{% /tab %}
{% /tabs %}
{% /tab %}

{% tab label="404" %}
Not Found

{% tabs %}
{% tab label="Model" %}
API error response.

| Field               | Type     | Description       |
| ------------------- | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |
{% /tab %}

{% tab label="Example" %}
```json
{
  "errors": [
    "Bad Request"
  ]
}
```
{% /tab %}
{% /tabs %}
{% /tab %}

{% tab label="429" %}
Too many requests

{% tabs %}
{% tab label="Model" %}
API error response.

| Field               | Type     | Description       |
| ------------------- | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |
{% /tab %}

{% tab label="Example" %}
```json
{
  "errors": [
    "Bad Request"
  ]
}
```
{% /tab %}
{% /tabs %}
{% /tab %}
{% /tabs %}

### Code Example

{% tabs %}
{% tab label="Curl" %}
```bash
# Path parameters
export deployment_id="k7Q-3mX-p9Z"

# Set your Datadog site and credentials
export DD_SITE="datadoghq.com" # Or us3.datadoghq.com, us5.datadoghq.com, datadoghq.eu, ap1.datadoghq.com, ap2.datadoghq.com, uk1.datadoghq.com, ddog-gov.com, us2.ddog-gov.com
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X POST "https://api.${DD_SITE}/api/v2/fleet/deployments/${deployment_id}/cancel" \
-H "Accept: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}"
```
{% /tab %}

{% tab label="Go" %}
```go
// Cancel a deployment returns "OK" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"

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

func main() {
	// there is a valid "deployment" in the system
	DeploymentID := os.Getenv("DEPLOYMENT_ID")

	ctx := datadog.NewDefaultContext(context.Background())
	ctx = context.WithValue(ctx, datadog.ContextAccessToken, os.Getenv("DD_BEARER_TOKEN"))
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV2.NewFleetAutomationApi(apiClient)
	resp, r, err := api.CancelFleetDeploymentV2(ctx, DeploymentID)

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

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `FleetAutomationApi.CancelFleetDeploymentV2`:\n%s\n", responseContent)
}
```

#### Instructions

First [install the library and its dependencies](https://dnd37xeb23o8n.cloudfront.net/api/latest.md?code-lang=go) and then save the example to `main.go` and run following commands:

```bash
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"
```
{% /tab %}

{% tab label="Java" %}
```java
// Cancel a deployment returns "OK" response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.FleetAutomationApi;
import com.datadog.api.client.v2.model.FleetDeploymentV2CancelResponse;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = ApiClient.getDefaultApiClient();
    defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
    FleetAutomationApi apiInstance = new FleetAutomationApi(defaultClient);

    // there is a valid "deployment" in the system
    String DEPLOYMENT_ID = System.getenv("DEPLOYMENT_ID");

    try {
      FleetDeploymentV2CancelResponse result = apiInstance.cancelFleetDeploymentV2(DEPLOYMENT_ID);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling FleetAutomationApi#cancelFleetDeploymentV2");
      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://dnd37xeb23o8n.cloudfront.net/api/latest.md?code-lang=java) and then save the example to `Example.java` and run following commands:

```bash
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"
```
{% /tab %}

{% tab label="Python" %}
```python
"""
Cancel a deployment returns "OK" response
"""

from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.fleet_automation_api import FleetAutomationApi

# there is a valid "deployment" in the system
DEPLOYMENT_ID = environ["DEPLOYMENT_ID"]

configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
    api_instance = FleetAutomationApi(api_client)
    response = api_instance.cancel_fleet_deployment_v2(
        deployment_id=DEPLOYMENT_ID,
    )

    print(response)
```

#### Instructions

First [install the library and its dependencies](https://dnd37xeb23o8n.cloudfront.net/api/latest.md?code-lang=python) and then save the example to `example.py` and run following commands:

```bash
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"
```
{% /tab %}

{% tab label="Ruby" %}
```ruby
# Cancel a deployment returns "OK" response

require "datadog_api_client"
DatadogAPIClient.configure do |config|
  config.access_token = ENV["DD_BEARER_TOKEN"]
end
api_instance = DatadogAPIClient::V2::FleetAutomationAPI.new

# there is a valid "deployment" in the system
DEPLOYMENT_ID = ENV["DEPLOYMENT_ID"]
p api_instance.cancel_fleet_deployment_v2(DEPLOYMENT_ID)
```

#### Instructions

First [install the library and its dependencies](https://dnd37xeb23o8n.cloudfront.net/api/latest.md?code-lang=ruby) and then save the example to `example.rb` and run following commands:

```bash
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"
```
{% /tab %}

{% tab label="Rust" %}
```rust
// Cancel a deployment returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_fleet_automation::FleetAutomationAPI;

#[tokio::main]
async fn main() {
    // there is a valid "deployment" in the system
    let deployment_id = std::env::var("DEPLOYMENT_ID").unwrap();
    let configuration = datadog::Configuration::new();
    let api = FleetAutomationAPI::with_config(configuration);
    let resp = api.cancel_fleet_deployment_v2(deployment_id.clone()).await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}
```

#### Instructions

First [install the library and its dependencies](https://dnd37xeb23o8n.cloudfront.net/api/latest.md?code-lang=rust) and then save the example to `src/main.rs` and run following commands:

```bash
DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run
```
{% /tab %}

{% tab label="TypeScript" %}
```typescript
/**
 * Cancel a deployment returns "OK" response
 */

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

const configuration = client.createConfiguration({
  authMethods: {
    AuthZ: {
      accessToken: process.env.DD_BEARER_TOKEN as string,
    },
  },
});
const apiInstance = new v2.FleetAutomationApi(configuration);

// there is a valid "deployment" in the system
const DEPLOYMENT_ID = process.env.DEPLOYMENT_ID as string;

const params: v2.FleetAutomationApiCancelFleetDeploymentV2Request = {
  deploymentId: DEPLOYMENT_ID,
};

apiInstance
  .cancelFleetDeploymentV2(params)
  .then((data: v2.FleetDeploymentV2CancelResponse) => {
    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://dnd37xeb23o8n.cloudfront.net/api/latest.md?code-lang=typescript) and then save the example to `example.ts` and run following commands:

```bash
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"
```
{% /tab %}
{% /tabs %}
