---
title: Create postmortem attachment
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: Docs > API Reference > Incidents
---

# Create postmortem attachment{% #create-postmortem-attachment %}

{% tab title="v2" %}
**Note**: This endpoint is in public beta and it's subject to change. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).
| Datadog site      | API endpoint                                                                              |
| ----------------- | ----------------------------------------------------------------------------------------- |
| ap1.datadoghq.com | POST https://api.ap1.datadoghq.com/api/v2/incidents/{incident_id}/attachments/postmortems |
| ap2.datadoghq.com | POST https://api.ap2.datadoghq.com/api/v2/incidents/{incident_id}/attachments/postmortems |
| app.datadoghq.eu  | POST https://api.datadoghq.eu/api/v2/incidents/{incident_id}/attachments/postmortems      |
| app.ddog-gov.com  | POST https://api.ddog-gov.com/api/v2/incidents/{incident_id}/attachments/postmortems      |
| us2.ddog-gov.com  | POST https://api.us2.ddog-gov.com/api/v2/incidents/{incident_id}/attachments/postmortems  |
| app.datadoghq.com | POST https://api.datadoghq.com/api/v2/incidents/{incident_id}/attachments/postmortems     |
| us3.datadoghq.com | POST https://api.us3.datadoghq.com/api/v2/incidents/{incident_id}/attachments/postmortems |
| us5.datadoghq.com | POST https://api.us5.datadoghq.com/api/v2/incidents/{incident_id}/attachments/postmortems |

### Overview



Create a postmortem attachment for an incident.

The endpoint accepts markdown for notebooks created in Confluence or Google Docs. Postmortems created from notebooks need to be formatted using frontend notebook cells, in addition to markdown format.



### Arguments

#### Path Parameters

| Name                          | Type   | Description            |
| ----------------------------- | ------ | ---------------------- |
| incident_id [*required*] | string | The ID of the incident |

### Request

#### Body Data (required)



{% tab title="Model" %}

| Parent field | Field                        | Type     | Description                                                                        |
| ------------ | ---------------------------- | -------- | ---------------------------------------------------------------------------------- |
|              | data [*required*]       | object   | Postmortem attachment data                                                         |
| data         | attributes [*required*] | object   | Postmortem attachment attributes                                                   |
| attributes   | cells                        | [object] | The cells of the postmortem                                                        |
| cells        | attributes                   | object   | Attributes of a postmortem cell                                                    |
| attributes   | definition                   | object   | Definition of a postmortem cell                                                    |
| definition   | content                      | string   | The content of the cell in markdown format                                         |
| cells        | id                           | string   | The unique identifier of the cell                                                  |
| cells        | type                         | enum     | The postmortem cell resource type. Allowed enum values: `markdown`                 |
| attributes   | content                      | string   | The content of the postmortem                                                      |
| attributes   | postmortem_template_id       | string   | The ID of the postmortem template                                                  |
| attributes   | title                        | string   | The title of the postmortem                                                        |
| data         | type [*required*]       | enum     | The incident attachment resource type. Allowed enum values: `incident_attachments` |

{% /tab %}

{% tab title="Example" %}

```json
{
  "data": {
    "attributes": {
      "cells": [
        {
          "attributes": {
            "definition": {
              "content": "## Incident Summary\nThis incident was caused by..."
            }
          },
          "id": "cell-1",
          "type": "markdown"
        }
      ],
      "content": "# Incident Report - IR-123\n[...]",
      "postmortem_template_id": "93645509-874e-45c4-adfa-623bfeaead89-123",
      "title": "Postmortem-IR-123"
    },
    "type": "incident_attachments"
  }
}
```

{% /tab %}

### Response

{% tab title="201" %}
Created
{% tab title="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`                           |
| 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`                                  |
| data                  | type [*required*]          | enum            | The incident attachment resource type. Allowed enum values: `incident_attachments` |
|                       | included                        | [ <oneOf>] | A list of related objects included in the response.                                |
| included              | Option 1                        | object          | User object returned by the API.                                                   |
| Option 1              | 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.                                                                  |
| Option 1              | id                              | string          | ID of the user.                                                                    |
| Option 1              | type                            | enum            | Users resource type. Allowed enum values: `users`                                  |

{% /tab %}

{% tab title="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 %}

{% /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="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 incident_id="00000000-0000-0000-0000-000000000000" \# Curl command curl -X POST "https://api.datadoghq.com/api/v2/incidents/${incident_id}/attachments/postmortems" \
-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": {
      "cells": [
        {
          "id": "cell-1",
          "type": "markdown"
        }
      ],
      "content": "# Incident Report - IR-123\n[...]",
      "postmortem_template_id": "93645509-874e-45c4-adfa-623bfeaead89-123",
      "title": "Postmortem-IR-123"
    },
    "type": "incident_attachments"
  }
}
EOF 
                
##### 

```python
"""
Create postmortem attachment returns "Created" response
"""

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.postmortem_attachment_request import PostmortemAttachmentRequest
from datadog_api_client.v2.model.postmortem_attachment_request_attributes import PostmortemAttachmentRequestAttributes
from datadog_api_client.v2.model.postmortem_attachment_request_data import PostmortemAttachmentRequestData
from datadog_api_client.v2.model.postmortem_cell import PostmortemCell
from datadog_api_client.v2.model.postmortem_cell_attributes import PostmortemCellAttributes
from datadog_api_client.v2.model.postmortem_cell_definition import PostmortemCellDefinition
from datadog_api_client.v2.model.postmortem_cell_type import PostmortemCellType

body = PostmortemAttachmentRequest(
    data=PostmortemAttachmentRequestData(
        attributes=PostmortemAttachmentRequestAttributes(
            cells=[
                PostmortemCell(
                    attributes=PostmortemCellAttributes(
                        definition=PostmortemCellDefinition(
                            content="## Incident Summary\nThis incident was caused by...",
                        ),
                    ),
                    id="cell-1",
                    type=PostmortemCellType.MARKDOWN,
                ),
            ],
            content="# Incident Report - IR-123\n[...]",
            postmortem_template_id="93645509-874e-45c4-adfa-623bfeaead89-123",
            title="Postmortem-IR-123",
        ),
        type=IncidentAttachmentType.INCIDENT_ATTACHMENTS,
    ),
)

configuration = Configuration()
configuration.unstable_operations["create_incident_postmortem_attachment"] = True
with ApiClient(configuration) as api_client:
    api_instance = IncidentsApi(api_client)
    response = api_instance.create_incident_postmortem_attachment(
        incident_id="00000000-0000-0000-0000-000000000000", body=body
    )

    print(response)
```

#### 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="<API-KEY>" DD_APP_KEY="<APP-KEY>" python3 "example.py"
##### 

```ruby
# Create postmortem attachment returns "Created" response

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

body = DatadogAPIClient::V2::PostmortemAttachmentRequest.new({
  data: DatadogAPIClient::V2::PostmortemAttachmentRequestData.new({
    attributes: DatadogAPIClient::V2::PostmortemAttachmentRequestAttributes.new({
      cells: [
        DatadogAPIClient::V2::PostmortemCell.new({
          attributes: DatadogAPIClient::V2::PostmortemCellAttributes.new({
            definition: DatadogAPIClient::V2::PostmortemCellDefinition.new({
              content: '## Incident Summary\nThis incident was caused by...',
            }),
          }),
          id: "cell-1",
          type: DatadogAPIClient::V2::PostmortemCellType::MARKDOWN,
        }),
      ],
      content: '# Incident Report - IR-123\n[...]',
      postmortem_template_id: "93645509-874e-45c4-adfa-623bfeaead89-123",
      title: "Postmortem-IR-123",
    }),
    type: DatadogAPIClient::V2::IncidentAttachmentType::INCIDENT_ATTACHMENTS,
  }),
})
p api_instance.create_incident_postmortem_attachment("00000000-0000-0000-0000-000000000000", 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="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"
##### 

```go
// Create postmortem attachment returns "Created" 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() {
	body := datadogV2.PostmortemAttachmentRequest{
		Data: datadogV2.PostmortemAttachmentRequestData{
			Attributes: datadogV2.PostmortemAttachmentRequestAttributes{
				Cells: []datadogV2.PostmortemCell{
					{
						Attributes: &datadogV2.PostmortemCellAttributes{
							Definition: &datadogV2.PostmortemCellDefinition{
								Content: datadog.PtrString(`## Incident Summary
This incident was caused by...`),
							},
						},
						Id:   datadog.PtrString("cell-1"),
						Type: datadogV2.POSTMORTEMCELLTYPE_MARKDOWN.Ptr(),
					},
				},
				Content: datadog.PtrString(`# Incident Report - IR-123
[...]`),
				PostmortemTemplateId: datadog.PtrString("93645509-874e-45c4-adfa-623bfeaead89-123"),
				Title:                datadog.PtrString("Postmortem-IR-123"),
			},
			Type: datadogV2.INCIDENTATTACHMENTTYPE_INCIDENT_ATTACHMENTS,
		},
	}
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	configuration.SetUnstableOperationEnabled("v2.CreateIncidentPostmortemAttachment", true)
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV2.NewIncidentsApi(apiClient)
	resp, r, err := api.CreateIncidentPostmortemAttachment(ctx, "00000000-0000-0000-0000-000000000000", body)

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

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

#### 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="<API-KEY>" DD_APP_KEY="<APP-KEY>" go run "main.go"
##### 

```java
// Create postmortem attachment returns "Created" 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.PostmortemAttachmentRequest;
import com.datadog.api.client.v2.model.PostmortemAttachmentRequestAttributes;
import com.datadog.api.client.v2.model.PostmortemAttachmentRequestData;
import com.datadog.api.client.v2.model.PostmortemCell;
import com.datadog.api.client.v2.model.PostmortemCellAttributes;
import com.datadog.api.client.v2.model.PostmortemCellDefinition;
import com.datadog.api.client.v2.model.PostmortemCellType;
import java.util.Collections;

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

    PostmortemAttachmentRequest body =
        new PostmortemAttachmentRequest()
            .data(
                new PostmortemAttachmentRequestData()
                    .attributes(
                        new PostmortemAttachmentRequestAttributes()
                            .cells(
                                Collections.singletonList(
                                    new PostmortemCell()
                                        .attributes(
                                            new PostmortemCellAttributes()
                                                .definition(
                                                    new PostmortemCellDefinition()
                                                        .content(
                                                            """
## Incident Summary
This incident was caused by...
""")))
                                        .id("cell-1")
                                        .type(PostmortemCellType.MARKDOWN)))
                            .content("""
# Incident Report - IR-123
[...]
""")
                            .postmortemTemplateId("93645509-874e-45c4-adfa-623bfeaead89-123")
                            .title("Postmortem-IR-123"))
                    .type(IncidentAttachmentType.INCIDENT_ATTACHMENTS));

    try {
      Attachment result =
          apiInstance.createIncidentPostmortemAttachment(
              "00000000-0000-0000-0000-000000000000", body);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling IncidentsApi#createIncidentPostmortemAttachment");
      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="<API-KEY>" DD_APP_KEY="<APP-KEY>" java "Example.java"
##### 

```rust
// Create postmortem attachment returns "Created" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_incidents::IncidentsAPI;
use datadog_api_client::datadogV2::model::IncidentAttachmentType;
use datadog_api_client::datadogV2::model::PostmortemAttachmentRequest;
use datadog_api_client::datadogV2::model::PostmortemAttachmentRequestAttributes;
use datadog_api_client::datadogV2::model::PostmortemAttachmentRequestData;
use datadog_api_client::datadogV2::model::PostmortemCell;
use datadog_api_client::datadogV2::model::PostmortemCellAttributes;
use datadog_api_client::datadogV2::model::PostmortemCellDefinition;
use datadog_api_client::datadogV2::model::PostmortemCellType;

#[tokio::main]
async fn main() {
    let body = PostmortemAttachmentRequest::new(PostmortemAttachmentRequestData::new(
        PostmortemAttachmentRequestAttributes::new()
            .cells(vec![PostmortemCell::new()
                .attributes(
                    PostmortemCellAttributes::new().definition(
                        PostmortemCellDefinition::new().content(
                            r#"## Incident Summary
This incident was caused by..."#
                                .to_string(),
                        ),
                    ),
                )
                .id("cell-1".to_string())
                .type_(PostmortemCellType::MARKDOWN)])
            .content(
                r#"# Incident Report - IR-123
[...]"#
                    .to_string(),
            )
            .postmortem_template_id("93645509-874e-45c4-adfa-623bfeaead89-123".to_string())
            .title("Postmortem-IR-123".to_string()),
        IncidentAttachmentType::INCIDENT_ATTACHMENTS,
    ));
    let mut configuration = datadog::Configuration::new();
    configuration.set_unstable_operation_enabled("v2.CreateIncidentPostmortemAttachment", true);
    let api = IncidentsAPI::with_config(configuration);
    let resp = api
        .create_incident_postmortem_attachment(
            "00000000-0000-0000-0000-000000000000".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="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo run
##### 

```typescript
/**
 * Create postmortem attachment returns "Created" response
 */

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

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

const params: v2.IncidentsApiCreateIncidentPostmortemAttachmentRequest = {
  body: {
    data: {
      attributes: {
        cells: [
          {
            attributes: {
              definition: {
                content: "## Incident Summary\nThis incident was caused by...",
              },
            },
            id: "cell-1",
            type: "markdown",
          },
        ],
        content: "# Incident Report - IR-123\n[...]",
        postmortemTemplateId: "93645509-874e-45c4-adfa-623bfeaead89-123",
        title: "Postmortem-IR-123",
      },
      type: "incident_attachments",
    },
  },
  incidentId: "00000000-0000-0000-0000-000000000000",
};

apiInstance
  .createIncidentPostmortemAttachment(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://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="<API-KEY>" DD_APP_KEY="<APP-KEY>" tsc "example.ts"
{% /tab %}
