---
title: Update incident attachment
description: Update incident attachment endpoint in the Datadog API.
breadcrumbs: Documentación > API > Update incident attachment
---

> For the complete documentation index, see [llms.txt](https://dnd37xeb23o8n.cloudfront.net/jen.gilbert/astro-base/llms.txt).

# Update incident attachment

## v2 (latest)

{% alert level="warning" %}
**Note**: This endpoint is in Preview.
If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help.md).
{% /alert %}

| Datadog site      | API endpoint                                                                                   |
| ----------------- | ---------------------------------------------------------------------------------------------- |
| app.datadoghq.com | PATCH https://api.datadoghq.com/api/v2/incidents/{incident_id}/attachments/{attachment_id}     |
| us3.datadoghq.com | PATCH https://api.us3.datadoghq.com/api/v2/incidents/{incident_id}/attachments/{attachment_id} |
| us5.datadoghq.com | PATCH https://api.us5.datadoghq.com/api/v2/incidents/{incident_id}/attachments/{attachment_id} |
| app.datadoghq.eu  | PATCH https://api.datadoghq.eu/api/v2/incidents/{incident_id}/attachments/{attachment_id}      |
| ap1.datadoghq.com | PATCH https://api.ap1.datadoghq.com/api/v2/incidents/{incident_id}/attachments/{attachment_id} |
| ap2.datadoghq.com | PATCH https://api.ap2.datadoghq.com/api/v2/incidents/{incident_id}/attachments/{attachment_id} |
| uk1.datadoghq.com | PATCH https://api.uk1.datadoghq.com/api/v2/incidents/{incident_id}/attachments/{attachment_id} |
| app.ddog-gov.com  | PATCH https://api.ddog-gov.com/api/v2/incidents/{incident_id}/attachments/{attachment_id}      |
| us2.ddog-gov.com  | PATCH https://api.us2.ddog-gov.com/api/v2/incidents/{incident_id}/attachments/{attachment_id}  |

### Overview

This endpoint requires the `incident_write` permission.

OAuth apps require the `incident_write` authorization [scope](https://dnd37xeb23o8n.cloudfront.net/jen.gilbert/astro-base/es/api/latest/scopes.md#incidents) to access this endpoint.

### Arguments

#### Path Parameters

| Field                      | Type   | Description               |
| -------------------------- | ------ | ------------------------- |
| incident_id [*required*]   | string | The UUID of the incident. |
| attachment_id [*required*] | string | The ID of the attachment. |

#### Query Strings

| Field   | Type   | Description                                                                    |
| ------- | ------ | ------------------------------------------------------------------------------ |
| include | string | Resource to include in the response. Supported value: `last_modified_by_user`. |

### Request

#### Body Data (required)

{% tabs %}
{% tab label="Model" %}
| Parent field | Field             | Type   | Description                                                                                                          |
| ------------ | ----------------- | ------ | -------------------------------------------------------------------------------------------------------------------- |
|              | data              | object | Attachment data for an update request.                                                                               |
| data         | attributes        | object | The attributes for updating an attachment.                                                                           |
| attributes   | attachment        | object | The updated attachment object.                                                                                       |
| attachment   | documentUrl       | string | The updated URL for the attachment.                                                                                  |
| attachment   | title             | string | The updated title for the attachment.                                                                                |
| data         | id                | string | The unique identifier of the attachment.                                                                             |
| data         | type [*required*] | enum   | The incident attachment resource type. Allowed enum values: `incident_attachments`. Default: `incident_attachments`. |
{% /tab %}

{% tab label="Example" %}
```json
{
  "data": {
    "attributes": {
      "attachment": {
        "documentUrl": "https://app.datadoghq.com/notebook/124/Example-Incident",
        "title": "Example-Incident"
      }
    },
    "id": "00000000-abcd-0002-0000-000000000000",
    "type": "incident_attachments"
  }
}
```
{% /tab %}
{% /tabs %}

### Response

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

{% tabs %}
{% tab label="Model" %}
An attachment response containing the attachment data and related objects.

| Parent field          | Field                      | Type      | Description                                                                                                          |
| --------------------- | -------------------------- | --------- | -------------------------------------------------------------------------------------------------------------------- |
|                       | data                       | object    | Attachment data from a response.                                                                                     |
| data                  | attributes [*required*]    | object    | The attachment's attributes.                                                                                         |
| attributes            | attachment                 | object    | The attachment object.                                                                                               |
| attachment            | documentUrl                | string    | The URL of the attachment.                                                                                           |
| attachment            | title                      | string    | The title of the attachment.                                                                                         |
| attributes            | attachment_type            | enum      | The type of the attachment. Allowed enum values: `postmortem`, `link`.                                               |
| attributes            | modified                   | date-time | Timestamp when the attachment was last modified.                                                                     |
| data                  | id [*required*]            | string    | The unique identifier of the attachment.                                                                             |
| data                  | relationships [*required*] | object    | The attachment's resource relationships.                                                                             |
| relationships         | incident                   | object    | Relationship to incident.                                                                                            |
| incident              | data [*required*]          | object    | Relationship to incident object.                                                                                     |
| data                  | id [*required*]            | string    | A unique identifier that represents the incident.                                                                    |
| data                  | type [*required*]          | enum      | Incident resource type. Allowed enum values: `incidents`. Default: `incidents`.                                      |
| relationships         | last_modified_by_user      | object    | Relationship to user.                                                                                                |
| last_modified_by_user | data [*required*]          | object    | Relationship to user object.                                                                                         |
| data                  | id [*required*]            | string    | A unique identifier that represents the user.                                                                        |
| data                  | type [*required*]          | enum      | Users resource type. Allowed enum values: `users`. Default: `users`.                                                 |
| data                  | type [*required*]          | enum      | The incident attachment resource type. Allowed enum values: `incident_attachments`. Default: `incident_attachments`. |
|                       | included                   | [<oneOf>] | A list of related objects included in the response.                                                                  |
| included              | <type=users>               | object    | User object returned by the API.                                                                                     |
| <type=users>          | attributes                 | object    | Attributes of user object returned by the API.                                                                       |
| attributes            | email                      | string    | Email of the user.                                                                                                   |
| attributes            | handle                     | string    | Handle of the user.                                                                                                  |
| attributes            | icon                       | string    | URL of the user's icon.                                                                                              |
| attributes            | name                       | string    | Name of the user.                                                                                                    |
| attributes            | uuid                       | string    | UUID of the user.                                                                                                    |
| <type=users>          | id                         | string    | ID of the user.                                                                                                      |
| <type=users>          | type                       | enum      | Users resource type. Allowed enum values: `users`. Default: `users`.                                                 |
{% /tab %}

{% tab label="Example" %}
```json
{
  "data": {
    "attributes": {
      "attachment": {
        "documentUrl": "https://app.datadoghq.com/notebook/123/Postmortem-IR-123",
        "title": "Postmortem IR-123"
      },
      "attachment_type": "postmortem",
      "modified": "2025-01-01T01:01:01.000000001Z"
    },
    "id": "00000000-abcd-0002-0000-000000000000",
    "relationships": {
      "incident": {
        "data": {
          "id": "00000000-0000-0000-1234-000000000000",
          "type": "incidents"
        }
      },
      "last_modified_by_user": {
        "data": {
          "id": "00000000-0000-0000-2345-000000000000",
          "type": "users"
        }
      }
    },
    "type": "incident_attachments"
  },
  "included": [
    {
      "attributes": {
        "email": "string",
        "handle": "string",
        "icon": "string",
        "name": "string",
        "uuid": "string"
      },
      "id": "string",
      "type": "users"
    }
  ]
}
```
{% /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="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 incident_id="CHANGE_ME"
export attachment_id="00000000-0000-0000-0000-000000000001"

# 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 PATCH "https://api.${DD_SITE}/api/v2/incidents/${incident_id}/attachments/${attachment_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "attachment": {
        "documentUrl": "https://app.datadoghq.com/notebook/124/Example-Incident",
        "title": "Example-Incident"
      }
    },
    "id": "00000000-abcd-0002-0000-000000000000",
    "type": "incident_attachments"
  }
}
EOF
```
{% /tab %}

{% tab label="Go" %}
```go
// Update incident attachment 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 "incident" in the system
	IncidentDataID := os.Getenv("INCIDENT_DATA_ID")

	// there is a valid "incident_attachment" in the system
	IncidentAttachmentDataID := os.Getenv("INCIDENT_ATTACHMENT_DATA_ID")

	body := datadogV2.PatchAttachmentRequest{
		Data: &datadogV2.PatchAttachmentRequestData{
			Attributes: &datadogV2.PatchAttachmentRequestDataAttributes{
				Attachment: &datadogV2.PatchAttachmentRequestDataAttributesAttachment{
					DocumentUrl: datadog.PtrString("https://app.datadoghq.com/notebook/124/Example-Incident"),
					Title:       datadog.PtrString("Example-Incident"),
				},
			},
			Id:   datadog.PtrString(IncidentAttachmentDataID),
			Type: datadogV2.INCIDENTATTACHMENTTYPE_INCIDENT_ATTACHMENTS,
		},
	}
	ctx := datadog.NewDefaultContext(context.Background())
	ctx = context.WithValue(ctx, datadog.ContextAccessToken, os.Getenv("DD_BEARER_TOKEN"))
	configuration := datadog.NewConfiguration()
	configuration.SetUnstableOperationEnabled("v2.UpdateIncidentAttachment", true)
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV2.NewIncidentsApi(apiClient)
	resp, r, err := api.UpdateIncidentAttachment(ctx, IncidentDataID, IncidentAttachmentDataID, body, *datadogV2.NewUpdateIncidentAttachmentOptionalParameters())

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

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `IncidentsApi.UpdateIncidentAttachment`:\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
// Update incident attachment returns "OK" response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.IncidentsApi;
import com.datadog.api.client.v2.model.Attachment;
import com.datadog.api.client.v2.model.IncidentAttachmentType;
import com.datadog.api.client.v2.model.PatchAttachmentRequest;
import com.datadog.api.client.v2.model.PatchAttachmentRequestData;
import com.datadog.api.client.v2.model.PatchAttachmentRequestDataAttributes;
import com.datadog.api.client.v2.model.PatchAttachmentRequestDataAttributesAttachment;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = ApiClient.getDefaultApiClient();
    defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
    defaultClient.setUnstableOperationEnabled("v2.updateIncidentAttachment", true);
    IncidentsApi apiInstance = new IncidentsApi(defaultClient);

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

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

    PatchAttachmentRequest body =
        new PatchAttachmentRequest()
            .data(
                new PatchAttachmentRequestData()
                    .attributes(
                        new PatchAttachmentRequestDataAttributes()
                            .attachment(
                                new PatchAttachmentRequestDataAttributesAttachment()
                                    .documentUrl(
                                        "https://app.datadoghq.com/notebook/124/Example-Incident")
                                    .title("Example-Incident")))
                    .id(INCIDENT_ATTACHMENT_DATA_ID)
                    .type(IncidentAttachmentType.INCIDENT_ATTACHMENTS));

    try {
      Attachment result =
          apiInstance.updateIncidentAttachment(INCIDENT_DATA_ID, INCIDENT_ATTACHMENT_DATA_ID, body);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling IncidentsApi#updateIncidentAttachment");
      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
"""
Update incident attachment returns "OK" response
"""

from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.incidents_api import IncidentsApi
from datadog_api_client.v2.model.incident_attachment_type import IncidentAttachmentType
from datadog_api_client.v2.model.patch_attachment_request import PatchAttachmentRequest
from datadog_api_client.v2.model.patch_attachment_request_data import PatchAttachmentRequestData
from datadog_api_client.v2.model.patch_attachment_request_data_attributes import PatchAttachmentRequestDataAttributes
from datadog_api_client.v2.model.patch_attachment_request_data_attributes_attachment import (
    PatchAttachmentRequestDataAttributesAttachment,
)

# there is a valid "incident" in the system
INCIDENT_DATA_ID = environ["INCIDENT_DATA_ID"]

# there is a valid "incident_attachment" in the system
INCIDENT_ATTACHMENT_DATA_ID = environ["INCIDENT_ATTACHMENT_DATA_ID"]

body = PatchAttachmentRequest(
    data=PatchAttachmentRequestData(
        attributes=PatchAttachmentRequestDataAttributes(
            attachment=PatchAttachmentRequestDataAttributesAttachment(
                document_url="https://app.datadoghq.com/notebook/124/Example-Incident",
                title="Example-Incident",
            ),
        ),
        id=INCIDENT_ATTACHMENT_DATA_ID,
        type=IncidentAttachmentType.INCIDENT_ATTACHMENTS,
    ),
)

configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
configuration.unstable_operations["update_incident_attachment"] = True
with ApiClient(configuration) as api_client:
    api_instance = IncidentsApi(api_client)
    response = api_instance.update_incident_attachment(
        incident_id=INCIDENT_DATA_ID, attachment_id=INCIDENT_ATTACHMENT_DATA_ID, body=body
    )

    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
# Update incident attachment returns "OK" response

require "datadog_api_client"
DatadogAPIClient.configure do |config|
  config.access_token = ENV["DD_BEARER_TOKEN"]
  config.unstable_operations["v2.update_incident_attachment".to_sym] = true
end
api_instance = DatadogAPIClient::V2::IncidentsAPI.new

# there is a valid "incident" in the system
INCIDENT_DATA_ID = ENV["INCIDENT_DATA_ID"]

# there is a valid "incident_attachment" in the system
INCIDENT_ATTACHMENT_DATA_ID = ENV["INCIDENT_ATTACHMENT_DATA_ID"]

body = DatadogAPIClient::V2::PatchAttachmentRequest.new({
  data: DatadogAPIClient::V2::PatchAttachmentRequestData.new({
    attributes: DatadogAPIClient::V2::PatchAttachmentRequestDataAttributes.new({
      attachment: DatadogAPIClient::V2::PatchAttachmentRequestDataAttributesAttachment.new({
        document_url: "https://app.datadoghq.com/notebook/124/Example-Incident",
        title: "Example-Incident",
      }),
    }),
    id: INCIDENT_ATTACHMENT_DATA_ID,
    type: DatadogAPIClient::V2::IncidentAttachmentType::INCIDENT_ATTACHMENTS,
  }),
})
p api_instance.update_incident_attachment(INCIDENT_DATA_ID, INCIDENT_ATTACHMENT_DATA_ID, body)
```

#### 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
// Update incident attachment returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_incidents::IncidentsAPI;
use datadog_api_client::datadogV2::api_incidents::UpdateIncidentAttachmentOptionalParams;
use datadog_api_client::datadogV2::model::IncidentAttachmentType;
use datadog_api_client::datadogV2::model::PatchAttachmentRequest;
use datadog_api_client::datadogV2::model::PatchAttachmentRequestData;
use datadog_api_client::datadogV2::model::PatchAttachmentRequestDataAttributes;
use datadog_api_client::datadogV2::model::PatchAttachmentRequestDataAttributesAttachment;

#[tokio::main]
async fn main() {
    // there is a valid "incident" in the system
    let incident_data_id = std::env::var("INCIDENT_DATA_ID").unwrap();

    // there is a valid "incident_attachment" in the system
    let incident_attachment_data_id = std::env::var("INCIDENT_ATTACHMENT_DATA_ID").unwrap();
    let body = PatchAttachmentRequest::new().data(
        PatchAttachmentRequestData::new(IncidentAttachmentType::INCIDENT_ATTACHMENTS)
            .attributes(
                PatchAttachmentRequestDataAttributes::new().attachment(
                    PatchAttachmentRequestDataAttributesAttachment::new()
                        .document_url(
                            "https://app.datadoghq.com/notebook/124/Example-Incident".to_string(),
                        )
                        .title("Example-Incident".to_string()),
                ),
            )
            .id(incident_attachment_data_id.clone()),
    );
    let mut configuration = datadog::Configuration::new();
    configuration.set_unstable_operation_enabled("v2.update_incident_attachment", true);
    let api = IncidentsAPI::with_config(configuration);
    let resp = api
        .update_incident_attachment(
            incident_data_id.clone(),
            incident_attachment_data_id.clone(),
            body,
            UpdateIncidentAttachmentOptionalParams::default(),
        )
        .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
/**
 * Update incident attachment 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,
    },
  },
});
configuration.unstableOperations["v2.updateIncidentAttachment"] = true;
const apiInstance = new v2.IncidentsApi(configuration);

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

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

const params: v2.IncidentsApiUpdateIncidentAttachmentRequest = {
  body: {
    data: {
      attributes: {
        attachment: {
          documentUrl:
            "https://app.datadoghq.com/notebook/124/Example-Incident",
          title: "Example-Incident",
        },
      },
      id: INCIDENT_ATTACHMENT_DATA_ID,
      type: "incident_attachments",
    },
  },
  incidentId: INCIDENT_DATA_ID,
  attachmentId: INCIDENT_ATTACHMENT_DATA_ID,
};

apiInstance
  .updateIncidentAttachment(params)
  .then((data: v2.Attachment) => {
    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 %}
