Create postmortem attachment
https://api.datadoghq.com/api/v2/incidents/{incident_id}/attachments/postmortemshttps://api.us3.datadoghq.com/api/v2/incidents/{incident_id}/attachments/postmortemshttps://api.us5.datadoghq.com/api/v2/incidents/{incident_id}/attachments/postmortemshttps://api.datadoghq.eu/api/v2/incidents/{incident_id}/attachments/postmortemshttps://api.ap1.datadoghq.com/api/v2/incidents/{incident_id}/attachments/postmortemshttps://api.ap2.datadoghq.com/api/v2/incidents/{incident_id}/attachments/postmortemshttps://api.uk1.datadoghq.com/api/v2/incidents/{incident_id}/attachments/postmortemshttps://api.ddog-gov.com/api/v2/incidents/{incident_id}/attachments/postmortemshttps://api.us2.ddog-gov.com/api/v2/incidents/{incident_id}/attachments/postmortemsOverview
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
incident_id [required]The ID of the incident
Request
Body Data (required)
data [required]Postmortem attachment data
attributes [required]Postmortem attachment attributes
cellsThe cells of the postmortem
attributesAttributes of a postmortem cell
definitionDefinition of a postmortem cell
contentThe content of the cell in markdown format
idThe unique identifier of the cell
typeThe postmortem cell resource type.
markdowncontentThe content of the postmortem
postmortem_template_idThe ID of the postmortem template
titleThe title of the postmortem
type [required]The incident attachment resource type.
incident_attachmentsincident_attachments{
"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"
}
}Response
Created
An attachment response containing the attachment data and related objects.
dataAttachment data from a response.
attributes [required]The attachment's attributes.
attachmentThe attachment object.
documentUrlThe URL of the attachment.
titleThe title of the attachment.
attachment_typeThe type of the attachment.
postmortem, linkmodifiedTimestamp when the attachment was last modified.
id [required]The unique identifier of the attachment.
relationships [required]The attachment's resource relationships.
incidentRelationship to incident.
data [required]Relationship to incident object.
id [required]A unique identifier that represents the incident.
type [required]Incident resource type.
incidentsincidentslast_modified_by_userRelationship to user.
data [required]Relationship to user object.
id [required]A unique identifier that represents the user.
type [required]Users resource type.
usersuserstype [required]The incident attachment resource type.
incident_attachmentsincident_attachmentsincludedA list of related objects included in the response.
<type=users>User object returned by the API.
attributesAttributes of user object returned by the API.
emailEmail of the user.
handleHandle of the user.
iconURL of the user's icon.
nameName of the user.
uuidUUID of the user.
idID of the user.
typeUsers resource type.
usersusers{
"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"
}
]
}Bad Request
API error response.
errors [required]A list of errors.
detailA human-readable explanation specific to this occurrence of the error.
metaNon-standard meta-information about the error
sourceReferences to the source of the error.
headerA string indicating the name of a single request header which caused the error.
parameterA string indicating which URI query parameter caused the error.
pointerA JSON pointer to the value in the request document that caused the error.
statusStatus code of the response.
titleShort human-readable summary of the error.
{
"errors": [
{
"detail": "Missing required attribute in body",
"meta": {},
"source": {
"header": "Authorization",
"parameter": "limit",
"pointer": "/data/attributes/title"
},
"status": "400",
"title": "Bad Request"
}
]
}Too many requests
API error response.
errors [required]A list of errors.
{
"errors": [
"Bad Request"
]
}Code Example
# Path parameters
export incident_id="00000000-0000-0000-0000-000000000000"
# Set your Datadog site and credentials
export DD_SITE="datadoghq.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/incidents/${incident_id}/attachments/postmortems" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-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# Path parameters
export incident_id="00000000-0000-0000-0000-000000000000"
# Set your Datadog site and credentials
export DD_SITE="us3.datadoghq.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/incidents/${incident_id}/attachments/postmortems" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-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# Path parameters
export incident_id="00000000-0000-0000-0000-000000000000"
# Set your Datadog site and credentials
export DD_SITE="us5.datadoghq.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/incidents/${incident_id}/attachments/postmortems" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-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# Path parameters
export incident_id="00000000-0000-0000-0000-000000000000"
# Set your Datadog site and credentials
export DD_SITE="datadoghq.eu"
# 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/incidents/${incident_id}/attachments/postmortems" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-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# Path parameters
export incident_id="00000000-0000-0000-0000-000000000000"
# Set your Datadog site and credentials
export DD_SITE="ap1.datadoghq.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/incidents/${incident_id}/attachments/postmortems" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-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# Path parameters
export incident_id="00000000-0000-0000-0000-000000000000"
# Set your Datadog site and credentials
export DD_SITE="ap2.datadoghq.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/incidents/${incident_id}/attachments/postmortems" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-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# Path parameters
export incident_id="00000000-0000-0000-0000-000000000000"
# Set your Datadog site and credentials
export DD_SITE="uk1.datadoghq.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/incidents/${incident_id}/attachments/postmortems" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-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# Path parameters
export incident_id="00000000-0000-0000-0000-000000000000"
# Set your Datadog site and credentials
export DD_SITE="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/incidents/${incident_id}/attachments/postmortems" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-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# Path parameters
export incident_id="00000000-0000-0000-0000-000000000000"
# Set your Datadog site and credentials
export DD_SITE="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/incidents/${incident_id}/attachments/postmortems" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-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// 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())
ctx = context.WithValue(ctx, datadog.ContextAccessToken, os.Getenv("DD_BEARER_TOKEN"))
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 and then save the example to main.go and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"// 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.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
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 and then save the example to Example.java and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java""""
Create postmortem attachment returns "Created" 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.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.access_token = environ["DD_BEARER_TOKEN"]
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 and then save the example to example.py and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"# Create postmortem attachment returns "Created" response
require "datadog_api_client"
DatadogAPIClient.configure do |config|
config.access_token = ENV["DD_BEARER_TOKEN"]
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 and then save the example to example.rb and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"// 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.create_incident_postmortem_attachment", 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 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 runDD_SITE="us3.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="us5.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="datadoghq.eu" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="ap1.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="ap2.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="uk1.datadoghq.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo runDD_SITE="us2.ddog-gov.com" DD_API_KEY="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo run/**
* Create postmortem attachment returns "Created" 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.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 and then save the example to example.ts and run following commands:
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us3.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us5.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="datadoghq.eu" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ap1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ap2.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="uk1.datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"DD_SITE="us2.ddog-gov.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"